jclouds git commit: JCLOUDS-1381: Add unit tests
Repository: jclouds Updated Branches: refs/heads/master d17487b22 -> 22cfbb86f JCLOUDS-1381: Add unit tests Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/22cfbb86 Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/22cfbb86 Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/22cfbb86 Branch: refs/heads/master Commit: 22cfbb86f2e67c4dbb0636de823b336ad08e1123 Parents: d17487b Author: Ignasi BarreraAuthored: Fri Mar 2 08:57:45 2018 +0100 Committer: Ignasi Barrera Committed: Fri Mar 2 08:57:45 2018 +0100 -- .../compute/loaders/DiskURIToImageTest.java | 127 +++ 1 file changed, 127 insertions(+) -- http://git-wip-us.apache.org/repos/asf/jclouds/blob/22cfbb86/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java -- diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java new file mode 100644 index 000..e1f00cd --- /dev/null +++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.googlecomputeengine.compute.loaders; + +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.mock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.Date; +import java.util.concurrent.ExecutionException; + +import org.jclouds.googlecomputeengine.compute.functions.Resources; +import org.jclouds.googlecomputeengine.domain.Disk; +import org.jclouds.googlecomputeengine.domain.Disk.Status; +import org.jclouds.googlecomputeengine.domain.Image; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "DiskURIToImageTest") +public class DiskURIToImageTest { + + private static final URI DISK_URI = URI.create("http://localhost/disk/1;); + private static final URI IMAGE_URI = URI.create("http://localhost/image/1;); + + public void testLoadNotFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(null); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageSourceMissing() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(null)); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageNotFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(IMAGE_URI)); + expect(resources.image(IMAGE_URI)).andReturn(null); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(IMAGE_URI)); + expect(resources.image(IMAGE_URI)).andReturn(image()); + replay(resources); + + DiskURIToImage diskURIToImage = new
jclouds git commit: JCLOUDS-1381: Add unit tests
Repository: jclouds Updated Branches: refs/heads/2.1.x 91bb9e8d4 -> 873c15eb1 JCLOUDS-1381: Add unit tests Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/873c15eb Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/873c15eb Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/873c15eb Branch: refs/heads/2.1.x Commit: 873c15eb12afd72f85651bfb6347456c9c4cba7f Parents: 91bb9e8 Author: Ignasi BarreraAuthored: Fri Mar 2 08:57:45 2018 +0100 Committer: Ignasi Barrera Committed: Fri Mar 2 10:31:53 2018 +0100 -- .../compute/loaders/DiskURIToImageTest.java | 127 +++ 1 file changed, 127 insertions(+) -- http://git-wip-us.apache.org/repos/asf/jclouds/blob/873c15eb/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java -- diff --git a/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java new file mode 100644 index 000..e1f00cd --- /dev/null +++ b/providers/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/loaders/DiskURIToImageTest.java @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.jclouds.googlecomputeengine.compute.loaders; + +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.mock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +import java.net.URI; +import java.util.Date; +import java.util.concurrent.ExecutionException; + +import org.jclouds.googlecomputeengine.compute.functions.Resources; +import org.jclouds.googlecomputeengine.domain.Disk; +import org.jclouds.googlecomputeengine.domain.Disk.Status; +import org.jclouds.googlecomputeengine.domain.Image; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "DiskURIToImageTest") +public class DiskURIToImageTest { + + private static final URI DISK_URI = URI.create("http://localhost/disk/1;); + private static final URI IMAGE_URI = URI.create("http://localhost/image/1;); + + public void testLoadNotFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(null); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageSourceMissing() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(null)); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageNotFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(IMAGE_URI)); + expect(resources.image(IMAGE_URI)).andReturn(null); + replay(resources); + + DiskURIToImage diskURIToImage = new DiskURIToImage(resources); + assertFalse(diskURIToImage.load(DISK_URI).isPresent()); + + verify(resources); + } + + public void testImageFound() throws ExecutionException { + Resources resources = mock(Resources.class); + expect(resources.disk(DISK_URI)).andReturn(disk(IMAGE_URI)); + expect(resources.image(IMAGE_URI)).andReturn(image()); + replay(resources); + + DiskURIToImage diskURIToImage = new