http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java index 7fd29c4..52f2e82 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetPoolApiLiveTest.java @@ -16,16 +16,20 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotEquals; +import static org.testng.Assert.assertNotNull; + import java.net.URI; -import java.util.HashSet; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; -import org.jclouds.collect.IterableWithMarker; import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; import org.jclouds.googlecomputeengine.domain.Image; import org.jclouds.googlecomputeengine.domain.Instance; -import org.jclouds.googlecomputeengine.domain.InstanceTemplate; +import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.TargetPool; +import org.jclouds.googlecomputeengine.domain.templates.InstanceTemplate; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.DiskCreationOptions; import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions; @@ -37,11 +41,6 @@ import org.testng.annotations.Test; import com.google.common.base.Predicate; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertNotNull; -import static com.google.common.base.Optional.fromNullable; - public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final String BACKUP_TARGETPOOL_NAME = "targetpool-api-live-test-backup"; @@ -60,8 +59,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final int DEFAULT_DISK_SIZE_GB = 10; private static final int TIME_WAIT_LONG = 600; - private Set<URI> instances; - private Set<URI> httpHealthChecks; + private List<URI> instances; + private List<URI> httpHealthChecks; private TargetPoolApi api() { return api.getTargetPoolApi(userProject.get(), DEFAULT_REGION_NAME); @@ -80,19 +79,19 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Override public boolean apply(Image input) { // filter out all deprecated images - return !(input.getDeprecated().isPresent() && input.getDeprecated().get().getState().isPresent()); + return !(input.deprecated() != null && input.deprecated().state() != null); } }) - .first().get().getSelfLink(); + .first().get().selfLink(); // Make and instanceTemplate - InstanceTemplate instanceTemplate = InstanceTemplate.builder() - .forMachineType(getDefaultMachineTypeUrl(userProject.get())) + InstanceTemplate instanceTemplate = new InstanceTemplate() + .machineType(getDefaultMachineTypeUrl(userProject.get())) .addNetworkInterface(getNetworkUrl(userProject.get(), INSTANCE_NETWORK_NAME), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT) .addMetadata("mykey", "myvalue") .description("a description") - .addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), BOOT_DISK_NAME), + .addDisk(Instance.AttachedDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), BOOT_DISK_NAME), null, true, true) .image(imageUri); @@ -102,7 +101,7 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT_LONG); // Create a disk. - DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instanceTemplate.getImage()); + DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instanceTemplate.image()); assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()) .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT_LONG); @@ -113,8 +112,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { instanceTemplate), TIME_WAIT_LONG); Instance instance = instanceApi.getInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME); - instances = new HashSet<URI>(); - instances.add(instance.getSelfLink()); + instances = new ArrayList<URI>(); + instances.add(instance.selfLink()); // Create a healthCheck HttpHealthCheckCreationOptions options = new HttpHealthCheckCreationOptions() @@ -123,8 +122,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { .description("A test HealthCheck for adding to targetPools"); assertGlobalOperationDoneSucessfully(httpHealthCheckApi.insert(HEALTHCHECK_NAME, options), TIME_WAIT); HttpHealthCheck healthCheck = httpHealthCheckApi.get(HEALTHCHECK_NAME); - httpHealthChecks = new HashSet<URI>(); - httpHealthChecks.add(healthCheck.getSelfLink()); + httpHealthChecks = new ArrayList<URI>(); + httpHealthChecks.add(healthCheck.selfLink()); } @Test(groups = "live") @@ -143,25 +142,25 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { TargetPoolCreationOptions targetPoolCreationOptions = new TargetPoolCreationOptions() .description(DESCRIPTION) .sessionAffinity(SessionAffinityValue.CLIENT_IP) - .backupPool(targetPool.getSelfLink()) + .backupPool(targetPool.selfLink()) .failoverRatio((float) 0.5); assertRegionOperationDoneSucessfully(api().create(TARGETPOOL_NAME, targetPoolCreationOptions), TIME_WAIT); TargetPool targetPool2 = api().get(TARGETPOOL_NAME); assertNotNull(targetPool2); - assertEquals(targetPool2.getName(), TARGETPOOL_NAME); - assertEquals(targetPool2.getDescription(), fromNullable(DESCRIPTION)); - assertEquals(targetPool2.getFailoverRatio(), (float) 0.5); - assertEquals(targetPool2.getBackupPool(), fromNullable(targetPool.getSelfLink())); - assertEquals(targetPool2.getSessionAffinity(), fromNullable(SessionAffinityValue.CLIENT_IP)); + assertEquals(targetPool2.name(), TARGETPOOL_NAME); + assertEquals(targetPool2.description(), DESCRIPTION); + assertEquals(targetPool2.failoverRatio(), (float) 0.5); + assertEquals(targetPool2.backupPool(), targetPool.selfLink()); + assertEquals(targetPool2.sessionAffinity(), SessionAffinityValue.CLIENT_IP); } @Test(groups = "live", dependsOnMethods = "testInsertTargetPool") public void testGetTargetPool() { TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), BACKUP_TARGETPOOL_NAME); - assertEquals(targetPool.getDescription(), fromNullable(DESCRIPTION_BACKUP)); - assertEquals(targetPool.getSessionAffinity(), fromNullable(SessionAffinityValue.CLIENT_IP)); + assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME); + assertEquals(targetPool.description(), DESCRIPTION_BACKUP); + assertEquals(targetPool.sessionAffinity(), SessionAffinityValue.CLIENT_IP); } @Test(groups = "live", dependsOnMethods = {"testInsertTargetPool", "testCreateInstanceAndHealthCheck"}) @@ -169,8 +168,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { assertRegionOperationDoneSucessfully(api().addInstance(BACKUP_TARGETPOOL_NAME, instances), TIME_WAIT); TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), BACKUP_TARGETPOOL_NAME); - assertEquals(targetPool.getInstances(), instances); + assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME); + assertEquals(targetPool.instances(), instances); } @Test(groups = "live", dependsOnMethods = "testAddInstanceTargetPool") @@ -180,8 +179,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { TargetPool targetPool = api().get(BACKUP_TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), BACKUP_TARGETPOOL_NAME); - assertNotEquals(targetPool.getInstances(), fromNullable(instances)); + assertEquals(targetPool.name(), BACKUP_TARGETPOOL_NAME); + assertNotEquals(targetPool.instances(), instances); } @Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2", "testCreateInstanceAndHealthCheck"}) @@ -189,8 +188,8 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { assertRegionOperationDoneSucessfully(api().addHealthCheck(TARGETPOOL_NAME, httpHealthChecks), TIME_WAIT); TargetPool targetPool = api().get(TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), TARGETPOOL_NAME); - assertEquals(targetPool.getHealthChecks(), httpHealthChecks); + assertEquals(targetPool.name(), TARGETPOOL_NAME); + assertEquals(targetPool.healthChecks(), httpHealthChecks); } @Test(groups = "live", dependsOnMethods = "testAddHealthCheckTargetPool") @@ -200,43 +199,43 @@ public class TargetPoolApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { TargetPool targetPool = api().get(TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), TARGETPOOL_NAME); - assertNotEquals(targetPool.getHealthChecks(), fromNullable(httpHealthChecks)); + assertEquals(targetPool.name(), TARGETPOOL_NAME); + assertNotEquals(targetPool.healthChecks(), httpHealthChecks); } @Test(groups = "live", dependsOnMethods = "testInsertTargetPool") public void testListTargetPool() { - IterableWithMarker<TargetPool> targetPool = api().list(new ListOptions.Builder() + ListPage<TargetPool> targetPool = api().list(new ListOptions.Builder() .filter("name eq " + BACKUP_TARGETPOOL_NAME)); - assertEquals(targetPool.toList().size(), 1); + assertEquals(targetPool.size(), 1); } @Test(groups = "live", dependsOnMethods = {"testInsertTargetPool2"}) - public void testSetBackupTargetPool() { + public void testListBackupTargetPool() { TargetPoolCreationOptions options = new TargetPoolCreationOptions().description("A targetPool for testing setBackup."); assertRegionOperationDoneSucessfully(api().create(THIRD_TARGETPOOL_NAME, options), TIME_WAIT); TargetPool targetPool = api().get(THIRD_TARGETPOOL_NAME); assertNotNull(targetPool); - assertEquals(targetPool.getName(), THIRD_TARGETPOOL_NAME); - assertEquals(targetPool.getBackupPool(), fromNullable(null)); + assertEquals(targetPool.name(), THIRD_TARGETPOOL_NAME); + assertEquals(targetPool.backupPool(), null); - URI selfLink = api().get(TARGETPOOL_NAME).getSelfLink(); + URI selfLink = api().get(TARGETPOOL_NAME).selfLink(); Float failoverRatio = Float.valueOf((float) 0.5); assertRegionOperationDoneSucessfully(api().setBackup(THIRD_TARGETPOOL_NAME, failoverRatio, selfLink), TIME_WAIT); TargetPool targetPoolUpdated = api().get(THIRD_TARGETPOOL_NAME); assertNotNull(targetPoolUpdated); - assertEquals(targetPoolUpdated.getName(), THIRD_TARGETPOOL_NAME); - assertEquals(targetPoolUpdated.getBackupPool(), fromNullable(selfLink)); + assertEquals(targetPoolUpdated.name(), THIRD_TARGETPOOL_NAME); + assertEquals(targetPoolUpdated.backupPool(), selfLink); } @Test(groups = "live", dependsOnMethods = {"testListTargetPool", "testGetTargetPool", "testRemoveInstanceTargetPool", "testRemoveHealthCheckTargetPool", - "testSetBackupTargetPool"}, alwaysRun = true) + "testListBackupTargetPool"}, alwaysRun = true) public void testDeleteTargetPool() { // Note: This ordering matters due one being the backup of the other ect. assertRegionOperationDoneSucessfully(api().delete(THIRD_TARGETPOOL_NAME), TIME_WAIT);
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java index 19036dd..4091678 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiExpectTest.java @@ -28,10 +28,10 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.testng.annotations.Test; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ZoneApiExpectTest") public class ZoneApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { - public static final String ZONES_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/zones"; + public static final String ZONES_URL_PREFIX = BASE_URL + "/myproject/zones"; public static final HttpRequest GET_ZONE_REQ = HttpRequest .builder() http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java index a6b56d4..fb7d0ee 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneApiLiveTest.java @@ -32,7 +32,6 @@ import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @@ -52,7 +51,7 @@ public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { assertTrue(pageIterator.hasNext()); IterableWithMarker<Zone> singlePageIterator = pageIterator.next(); - List<Zone> zoneAsList = Lists.newArrayList(singlePageIterator); + List<Zone> zoneAsList = singlePageIterator.toList(); assertSame(zoneAsList.size(), 1); @@ -62,13 +61,13 @@ public class ZoneApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testListZone") public void testGetZone() { - Zone zone = api().get(this.zone.getName()); + Zone zone = api().get(this.zone.name()); assertNotNull(zone); assertZoneEquals(zone, this.zone); } private void assertZoneEquals(Zone result, Zone expected) { - assertEquals(result.getName(), expected.getName()); + assertEquals(result.name(), expected.name()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java index 8866770..7608a71 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiExpectTest.java @@ -22,23 +22,21 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; import static org.testng.Assert.assertTrue; -import java.net.URI; - -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; import org.jclouds.googlecomputeengine.options.ListOptions; +import org.jclouds.googlecomputeengine.parse.ParseZoneOperationTest; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.testng.annotations.Test; -@Test(groups = "unit") +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ZoneOperationApiExpectTest") public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { - private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" + - ".com/compute/v1/projects/myproject/zones/us-central1-a/operations"; + private static final String OPERATIONS_URL_PREFIX = BASE_URL + "/myproject/zones/us-central1-a/operations"; public static final HttpRequest GET_ZONE_OPERATION_REQUEST = HttpRequest .builder() @@ -50,41 +48,13 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect public static final HttpResponse GET_ZONE_OPERATION_RESPONSE = HttpResponse.builder().statusCode(200) .payload(staticPayloadFromResource("/zone_operation.json")).build(); - private Operation expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return Operation.builder().id("13053095055850848306") - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8" + - "-bbbb12cb")) - .name("operation-1354084865060-4cf88735faeb8-bbbb12cb") - .targetLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance")) - .targetId("13053094017547040099") - .status(Operation.Status.DONE) - .user("[email protected]") - .progress(100) - .insertTime(dateService.iso8601DateParse("2012-11-28T06:41:05.060")) - .startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142")) - .endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142")) - .operationType("insert") - .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a")) - .build(); - } - - private ListPage<Operation> expectedList() { - return ListPage.<Operation>builder() - .kind(Resource.Kind.OPERATION_LIST) - .addItem(expected()) - .build(); - } - public void testGetOperationResponseIs2xx() throws Exception { ZoneOperationApi zoneOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, GET_ZONE_OPERATION_REQUEST, GET_ZONE_OPERATION_RESPONSE).getZoneOperationApi("myproject"); assertEquals(zoneOperationApi.getInZone("us-central1-a", "operation-1354084865060-4cf88735faeb8-bbbb12cb"), - expected()); + new ParseZoneOperationTest().expected()); } public void testGetOperationResponseIs4xx() throws Exception { @@ -127,6 +97,14 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect zoneOperationApi.deleteInZone("us-central1-a", "operation-1352178598164-4cdcc9d031510-4aa46279"); } + private static ListPage<Operation> expectedList() { + return ListPage.create( // + ImmutableList.of(new ParseZoneOperationTest().expected()), // items + null, // nextPageToken + null // prefixes + ); + } + public void testListOperationWithNoOptionsResponseIs2xx() { HttpRequest get = HttpRequest .builder() @@ -186,6 +164,4 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect assertTrue(zoneOperationApi.listInZone("us-central1-a").concat().isEmpty()); } - - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java index 9dd5c93..542bbf3 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ZoneOperationApiLiveTest.java @@ -59,7 +59,7 @@ public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest @Test(groups = "live", dependsOnMethods = "testCreateOperations") public void testGetOperation() { - Operation operation = api().getInZone(DEFAULT_ZONE_NAME, addOperation.getName()); + Operation operation = api().getInZone(DEFAULT_ZONE_NAME, addOperation.name()); assertNotNull(operation); assertOperationEquals(operation, this.addOperation); } @@ -73,9 +73,7 @@ public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest // make sure that in spite of having only one result per page we get at least two results final AtomicInteger counter = new AtomicInteger(); operations.firstMatch(new Predicate<IterableWithMarker<Operation>>() { - - @Override - public boolean apply(IterableWithMarker<Operation> input) { + @Override public boolean apply(IterableWithMarker<Operation> input) { counter.addAndGet(Iterables.size(input)); return counter.get() == 2; } @@ -83,7 +81,7 @@ public class ZoneOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTest } private void assertOperationEquals(Operation result, Operation expected) { - assertEquals(result.getName(), expected.getName()); + assertEquals(result.name(), expected.name()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java deleted file mode 100644 index e77f35a..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/functions/CreateNetworkIfNeededTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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.functions; - -import static com.google.common.base.Optional.fromNullable; -import static org.easymock.EasyMock.createMock; -import static org.easymock.EasyMock.expect; -import static org.easymock.EasyMock.replay; -import static org.easymock.EasyMock.verify; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; -import org.jclouds.googlecomputeengine.domain.Network; -import org.jclouds.googlecomputeengine.domain.Operation; -import org.jclouds.googlecomputeengine.domain.internal.NetworkAndAddressRange; -import org.jclouds.googlecomputeengine.features.GlobalOperationApi; -import org.jclouds.googlecomputeengine.features.NetworkApi; -import org.jclouds.googlecomputeengine.predicates.GlobalOperationDonePredicate; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; - -public class CreateNetworkIfNeededTest { - - @Test - public void testApply() { - final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class); - final NetworkApi nwApi = createMock(NetworkApi.class); - final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class); - - Network network = Network.builder().IPv4Range("0.0.0.0/0") - .id("abcd").name("this-network") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network")) - .build(); - - Operation createOp = createMock(Operation.class); - - final Supplier<String> userProject = new Supplier<String>() { - @Override - public String get() { - return "myproject"; - } - }; - - expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce(); - expect(api.getGlobalOperationApi(userProject.get())).andReturn(globalApi).atLeastOnce(); - - expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0")) - .andReturn(createOp); - expect(globalApi.get("insert-op")).andReturn(createOp); - expect(nwApi.get("this-network")).andReturn(null); - expect(nwApi.get("this-network")).andReturn(network); - - expect(createOp.getName()).andReturn("insert-op"); - expect(createOp.getStatus()).andReturn(Operation.Status.DONE); - expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null)); - replay(api, nwApi, createOp, globalApi); - - NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", null); - - GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject); - - CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l); - - assertEquals(creator.apply(input), network); - - verify(api, nwApi, globalApi, createOp); - } - - @Test - public void testApplyWithGateway() { - final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class); - final NetworkApi nwApi = createMock(NetworkApi.class); - final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class); - - Network network = Network.builder().IPv4Range("0.0.0.0/0") - .id("abcd").name("this-network").gatewayIPv4("1.2.3.4") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network")) - .build(); - - Operation createOp = createMock(Operation.class); - - final Supplier<String> userProject = new Supplier<String>() { - @Override - public String get() { - return "myproject"; - } - }; - - expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce(); - expect(api.getGlobalOperationApi(userProject.get())).andReturn(globalApi).atLeastOnce(); - - expect(nwApi.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4")) - .andReturn(createOp); - expect(globalApi.get("insert-op")).andReturn(createOp); - expect(nwApi.get("this-network")).andReturn(null); - expect(nwApi.get("this-network")).andReturn(network); - - expect(createOp.getName()).andReturn("insert-op"); - expect(createOp.getStatus()).andReturn(Operation.Status.DONE); - expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null)); - replay(api, nwApi, createOp, globalApi); - - NetworkAndAddressRange input = new NetworkAndAddressRange("this-network", "0.0.0.0/0", "1.2.3.4"); - - GlobalOperationDonePredicate pred = new GlobalOperationDonePredicate(api, userProject); - - CreateNetworkIfNeeded creator = new CreateNetworkIfNeeded(api, userProject, pred, 100l, 100l); - - assertEquals(creator.apply(input), network); - - verify(api, nwApi, globalApi, createOp); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java index 972f591..c5780b1 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java @@ -46,25 +46,15 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo protected static final String API_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/"; protected static final String ZONE_API_URL_SUFFIX = "/zones/"; protected static final String DEFAULT_ZONE_NAME = "us-central1-a"; - - protected static final String REGION_API_URL_SUFFIX = "/region/"; protected static final String DEFAULT_REGION_NAME = "us-central1"; - protected static final String NETWORK_API_URL_SUFFIX = "/global/networks/"; protected static final String DEFAULT_NETWORK_NAME = "live-test-network"; - protected static final String MACHINE_TYPE_API_URL_SUFFIX = "/machineTypes/"; protected static final String DEFAULT_MACHINE_TYPE_NAME = "n1-standard-1"; - protected static final String GATEWAY_API_URL_SUFFIX = "/global/gateways/"; protected static final String DEFAULT_GATEWAY_NAME = "default-internet-gateway"; - protected static final String IMAGE_API_URL_SUFFIX = "/global/images/"; - protected static final String DISK_TYPE_API_URL_SUFFIX = "/diskTypes/"; - protected static final String DEFAULT_DISK_NAME = "pd-standard"; - - protected static final String GOOGLE_PROJECT = "google"; protected Supplier<String> userProject; protected Predicate<AtomicReference<Operation>> globalOperationDonePredicate; @@ -97,8 +87,8 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo protected Operation assertGlobalOperationDoneSucessfully(Operation operation, long maxWaitSeconds) { operation = waitGlobalOperationDone(operation, maxWaitSeconds); - assertEquals(operation.getStatus(), Operation.Status.DONE); - assertTrue(operation.getErrors().isEmpty()); + assertEquals(operation.status(), Operation.Status.DONE); + assertTrue(operation.errors().isEmpty()); return operation; } @@ -108,8 +98,8 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo protected Operation assertRegionOperationDoneSucessfully(Operation operation, long maxWaitSeconds) { operation = waitRegionOperationDone(operation, maxWaitSeconds); - assertEquals(operation.getStatus(), Operation.Status.DONE); - assertTrue(operation.getErrors().isEmpty()); + assertEquals(operation.status(), Operation.Status.DONE); + assertTrue(operation.errors().isEmpty()); return operation; } @@ -119,8 +109,8 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo protected Operation assertZoneOperationDoneSucessfully(Operation operation, long maxWaitSeconds) { operation = waitZoneOperationDone(operation, maxWaitSeconds); - assertEquals(operation.getStatus(), Operation.Status.DONE); - assertTrue(operation.getErrors().isEmpty()); + assertEquals(operation.status(), Operation.Status.DONE); + assertTrue(operation.errors().isEmpty()); return operation; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java index 47a4245..e58c5f6 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineExpectTest.java @@ -27,6 +27,7 @@ import static org.jclouds.crypto.Pems.privateKeySpec; import static org.jclouds.crypto.Pems.publicKeySpec; import static org.jclouds.crypto.PemsTest.PRIVATE_KEY; import static org.jclouds.crypto.PemsTest.PUBLIC_KEY; +import static org.jclouds.util.Strings2.toStringAndClose; import java.io.IOException; import java.net.URI; @@ -44,10 +45,9 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MediaType; -import org.jclouds.collect.PagedIterable; -import org.jclouds.collect.PagedIterables; +import org.jclouds.apis.ApiMetadata; import org.jclouds.crypto.Crypto; -import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.jclouds.io.Payload; @@ -55,7 +55,6 @@ import org.jclouds.oauth.v2.OAuthConstants; import org.jclouds.oauth.v2.config.OAuthProperties; import org.jclouds.rest.internal.BaseRestApiExpectTest; import org.jclouds.ssh.SshKeys; -import org.jclouds.util.Strings2; import com.google.common.base.Joiner; import com.google.common.base.Supplier; @@ -66,6 +65,7 @@ import com.google.inject.Module; import com.google.inject.TypeLiteral; public class BaseGoogleComputeEngineExpectTest<T> extends BaseRestApiExpectTest<T> { + protected static final String BASE_URL = "https://www.googleapis.com/compute/v1/projects"; private static final String header = "{\"alg\":\"none\",\"typ\":\"JWT\"}"; @@ -92,14 +92,17 @@ public class BaseGoogleComputeEngineExpectTest<T> extends BaseRestApiExpectTest< provider = "google-compute-engine"; } + @Override protected ApiMetadata createApiMetadata(){ + return new GoogleComputeEngineApiMetadata(); + } + @Override protected Module createModule() { - return new Module() { @Override public void configure(Binder binder) { - // Predicatable time + // Predictable time binder.bind(new TypeLiteral<Supplier<Long>>() {}).toInstance(Suppliers.ofInstance(0L)); try { KeyFactory keyfactory = KeyFactory.getInstance("RSA"); @@ -174,22 +177,12 @@ public class BaseGoogleComputeEngineExpectTest<T> extends BaseRestApiExpectTest< .build(); } - /** - * Parse tests don't apply @Transform so we need to apply the transformation to PagedIterable on the result of - * expected() - */ - protected <T> PagedIterable<T> toPagedIterable(ListPage<T> list) { - return PagedIterables.of(list); - } - protected static Payload staticPayloadFromResource(String resource) { try { - return payloadFromString(Strings2.toStringAndClose(BaseGoogleComputeEngineExpectTest.class.getResourceAsStream - (resource))); + return payloadFromString( + toStringAndClose(BaseGoogleComputeEngineExpectTest.class.getResourceAsStream(resource))); } catch (IOException e) { throw propagate(e); } } - - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java index aba1fc3..5e90a0a 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineParseTest.java @@ -16,6 +16,9 @@ */ package org.jclouds.googlecomputeengine.internal; +import java.util.Date; + +import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.config.GoogleComputeEngineParserModule; import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; @@ -25,9 +28,14 @@ import com.google.inject.Injector; public abstract class BaseGoogleComputeEngineParseTest<T> extends BaseItemParserTest<T> { + protected static final String BASE_URL = "https://www.googleapis.com/compute/v1/projects"; + @Override protected Injector injector() { return Guice.createInjector(new GsonModule(), new GoogleComputeEngineParserModule()); } + protected static Date parse(String iso8601) { + return new SimpleDateFormatDateService().iso8601DateParse(iso8601); + } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java index 1b65fc1..6d10740 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineServiceContextExpectTest.java @@ -18,9 +18,7 @@ package org.jclouds.googlecomputeengine.internal; import java.util.Properties; -import org.jclouds.apis.ApiMetadata; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.googlecomputeengine.GoogleComputeEngineApiMetadata; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -30,9 +28,7 @@ import com.google.inject.Module; public abstract class BaseGoogleComputeEngineServiceContextExpectTest<T> extends BaseGoogleComputeEngineExpectTest<T> implements Function<ComputeServiceContext, T> { - - @Override - public T createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) { + @Override public T createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) { return apply(createComputeServiceContext(fn, module, props)); } @@ -40,10 +36,4 @@ public abstract class BaseGoogleComputeEngineServiceContextExpectTest<T> extends Properties props) { return createInjector(fn, module, props).getInstance(ComputeServiceContext.class); } - - @Override - protected ApiMetadata createApiMetadata() { - return new GoogleComputeEngineApiMetadata(); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java index 3107c7b..b71726f 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressListTest.java @@ -16,19 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Address; import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource.Kind; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -@Test(groups = "unit") +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseAddressListTest") public class ParseAddressListTest extends BaseGoogleComputeEngineParseTest<ListPage<Address>> { @Override @@ -36,22 +37,23 @@ public class ParseAddressListTest extends BaseGoogleComputeEngineParseTest<ListP return "/address_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<Address> expected() { - return ListPage.<Address>builder() - .kind(Kind.ADDRESS_LIST) - .addItem(new ParseAddressTest().expected()) - .addItem(Address.builder() - .id("4881363978908129158") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T14:08:21.552-07:00")) - .status("RESERVED") - .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1")) - .name("test-ip2") - .description("") - .address("173.255.118.115") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip2")) - .build()) - .build(); + Address address1 = new ParseAddressTest().expected(); + Address address2 = Address.create( // + "4881363978908129158", // id + URI.create(BASE_URL + "/myproject/regions/us-central1/addresses/test-ip2"), // selfLink + "test-ip2", // name + "", // description + "RESERVED", // status + null, // user + URI.create(BASE_URL + "/myproject/regions/us-central1"), // region + "173.255.118.115" // address + ); + return ListPage.create( // + ImmutableList.of(address1, address2), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java index dd3c3ed..27708da 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseAddressTest.java @@ -16,17 +16,17 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Address; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseAddressTest") public class ParseAddressTest extends BaseGoogleComputeEngineParseTest<Address> { @Override @@ -34,18 +34,17 @@ public class ParseAddressTest extends BaseGoogleComputeEngineParseTest<Address> return "/address_get.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public Address expected() { - return Address.builder() - .id("4439373783165447583") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T13:57:20.204-07:00")) - .status("RESERVED") - .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1")) - .name("test-ip1") - .description("") - .address("173.255.115.190") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")) - .build(); + return Address.create( // + "4439373783165447583", // id + URI.create(BASE_URL + "/myproject/regions/us-central1/addresses/test-ip1"), // selfLink + "test-ip1", // name + "", // description + "RESERVED", // status + null, // user + URI.create(BASE_URL + "/myproject/regions/us-central1"), // region + "173.255.115.190" // address + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java index ff62d56..d2fb69c 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskListTest.java @@ -16,19 +16,18 @@ */ package org.jclouds.googlecomputeengine.parse; -import java.net.URI; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Disk; import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -@Test(groups = "unit") +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseDiskListTest") public class ParseDiskListTest extends BaseGoogleComputeEngineParseTest<ListPage<Disk>> { @Override @@ -36,22 +35,12 @@ public class ParseDiskListTest extends BaseGoogleComputeEngineParseTest<ListPage return "/disk_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<Disk> expected() { - return ListPage.<Disk>builder() - .kind(Resource.Kind.DISK_LIST) - .addItem(Disk.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")) - .name("testimage1") - .sizeGb(1) - .zone(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/zones/us-central1-a")) - .status("READY") - .build()) - .build(); + return ListPage.create( // + ImmutableList.of(new ParseDiskTest().expected()), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java index 2e29973..cb557d8 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTest.java @@ -16,17 +16,17 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Disk; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseDiskTest") public class ParseDiskTest extends BaseGoogleComputeEngineParseTest<Disk> { @Override @@ -34,18 +34,17 @@ public class ParseDiskTest extends BaseGoogleComputeEngineParseTest<Disk> { return "/disk_get.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public Disk expected() { - return Disk.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")) - .name("testimage1") - .sizeGb(1) - .zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a")) - .status("READY") - .type(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/diskTypes/pd-ssd")) - .build(); + return Disk.create( // + "13050421646334304115", // id + URI.create(BASE_URL + "/myproject/zones/us-central1-a"), // zone + "READY", // status + "testimage1", // name + null, // description + 1, // sizeGb + URI.create(BASE_URL + "/myproject/zones/us-central1-a/disks/testimage1"), // selfLink + URI.create(BASE_URL + "/studied-point-720/zones/us-central1-a/diskTypes/pd-standard") // type + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeListTest.java index ad229bf..af03d68 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeListTest.java @@ -16,18 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; -import static org.jclouds.googlecomputeengine.domain.Resource.Kind.DISK_TYPE_LIST; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.DiskType; +import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseDiskTypeListTest") public class ParseDiskTypeListTest extends BaseGoogleComputeEngineParseTest<ListPage<DiskType>> { @Override @@ -35,30 +37,23 @@ public class ParseDiskTypeListTest extends BaseGoogleComputeEngineParseTest<List return "/disktype_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<DiskType> expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return ListPage.<DiskType>builder() - .kind(DISK_TYPE_LIST) - .addItem(DiskType.builder() - .creationTimestamp(dateService.iso8601DateParse("2014-06-02T11:07:28.530-07:00")) - .name("pd-standard") - .description("Standard Persistent Disk") - .validDiskSize("10GB-10TB") - .zone("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a") - .selfLink(URI.create("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a/diskTypes/pd-standard")) - .defaultDiskSizeGb(500) - .build()) - .addItem(DiskType.builder() - .creationTimestamp(dateService.iso8601DateParse("2014-06-02T11:07:28.529-07:00")) - .name("pd-ssd") - .description("SSD Persistent Disk") - .validDiskSize("10GB-1TB") - .zone("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a") - .selfLink(URI.create("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a/diskTypes/pd-ssd")) - .defaultDiskSizeGb(100) - .build()) - .build(); + String contentBaseUrl = BASE_URL.replace("www", "content"); + DiskType diskType1 = DiskType.create( // + "pd-standard", // name + "Standard Persistent Disk", // description + "10GB-10TB", // validDiskSize + null, // deprecated + URI.create(contentBaseUrl + "/studied-point-720/zones/us-central1-a"), // zone + URI.create(contentBaseUrl + "/studied-point-720/zones/us-central1-a/diskTypes/pd-standard"), // selfLink + 500 // defaultDiskSizeGb + ); + DiskType diskType2 = new ParseDiskTypeTest().expected(); + return ListPage.create( // + ImmutableList.of(diskType1, diskType2), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeTest.java index 756586d..6064067 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseDiskTypeTest.java @@ -16,35 +16,35 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.DiskType; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; +@Test(groups = "unit", testName = "ParseDiskTypeTest") public class ParseDiskTypeTest extends BaseGoogleComputeEngineParseTest<DiskType> { - @Override public String resource() { return "/disktype.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public DiskType expected() { - SimpleDateFormatDateService dateService = new SimpleDateFormatDateService(); - return DiskType.builder() - .creationTimestamp(dateService.iso8601DateParse("2014-06-02T11:07:28.529-07:00")) - .name("pd-ssd") - .description("SSD Persistent Disk") - .validDiskSize("10GB-1TB") - .zone("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a") - .selfLink(URI.create("https://content.googleapis.com/compute/v1/projects/studied-point-720/zones/us-central1-a/diskTypes/pd-ssd")) - .defaultDiskSizeGb(100) - .build(); + String contentBaseUrl = BASE_URL.replace("www", "content"); + return DiskType.create( // + "pd-ssd", // name + "SSD Persistent Disk", // description + "10GB-1TB", // validDiskSize + null, // deprecated + URI.create(contentBaseUrl + "/studied-point-720/zones/us-central1-a"), // zone + URI.create(contentBaseUrl + "/studied-point-720/zones/us-central1-a/diskTypes/pd-ssd"), // selfLink + 100 // defaultDiskSizeGb + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java index b9ba669..e897e10 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallListTest.java @@ -16,20 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Firewall; import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.jclouds.net.domain.IpProtocol; import org.testng.annotations.Test; -@Test(groups = "unit") +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseFirewallListTest") public class ParseFirewallListTest extends BaseGoogleComputeEngineParseTest<ListPage<Firewall>> { @Override @@ -37,26 +37,24 @@ public class ParseFirewallListTest extends BaseGoogleComputeEngineParseTest<List return "/firewall_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<Firewall> expected() { - return ListPage.<Firewall>builder() - .kind(Resource.Kind.FIREWALL_LIST) - .addItem(new ParseFirewallTest().expected()) - .addItem(Firewall.builder() - .id("12862241067393040785") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/firewalls/default-ssh")) - .name("default-ssh") - .description("SSH allowed from anywhere") - .network(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/google/global/networks/default")) - .addSourceRange("0.0.0.0/0") - .addAllowed(Firewall.Rule.builder() - .IpProtocol(IpProtocol.TCP) - .addPort(22).build()) - .build()) - .build(); + Firewall firewall1 = new ParseFirewallTest().expected(); + Firewall firewall2 = Firewall.create( // + "12862241067393040785", // id + URI.create(BASE_URL + "/google/global/firewalls/default-ssh"), // selfLink + "default-ssh", // name + "SSH allowed from anywhere", // description + URI.create(BASE_URL + "/google/global/networks/default"), // network + ImmutableList.of("0.0.0.0/0"), // sourceRanges + null, // sourceTags + null, // targetTags + ImmutableList.of(Firewall.Rule.create("tcp", ImmutableList.of("22"))) // allowed + ); + return ListPage.create( // + ImmutableList.of(firewall1, firewall2), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java index 37fc794..e79ac2f 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseFirewallTest.java @@ -16,18 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.Firewall; +import org.jclouds.googlecomputeengine.domain.Firewall.Rule; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.jclouds.net.domain.IpProtocol; import org.testng.annotations.Test; -@Test(groups = "unit") +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseFirewallTest") public class ParseFirewallTest extends BaseGoogleComputeEngineParseTest<Firewall> { @Override @@ -35,26 +37,21 @@ public class ParseFirewallTest extends BaseGoogleComputeEngineParseTest<Firewall return "/firewall_get.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public Firewall expected() { - return Firewall.builder() - .id("12862241031274216284") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:02.855")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test")) - .name("jclouds-test") - .description("Internal traffic from default allowed") - .network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test")) - .addSourceRange("10.0.0.0/8") - .addAllowed(Firewall.Rule.builder() - .IpProtocol(IpProtocol.TCP) - .addPortRange(1, 65535).build()) - .addAllowed(Firewall.Rule.builder() - .IpProtocol(IpProtocol.UDP) - .addPortRange(1, 65535).build()) - .addAllowed(Firewall.Rule.builder() - .IpProtocol(IpProtocol.ICMP).build()) - .build(); - + return Firewall.create( // + "12862241031274216284", // id + URI.create(BASE_URL + "/myproject/global/firewalls/jclouds-test"), // selfLink + "jclouds-test", // name + "Internal traffic from default allowed", // description + URI.create(BASE_URL + "/myproject/global/networks/jclouds-test"), // network + ImmutableList.of("10.0.0.0/8"), // sourceRanges + null, // sourceTags + null, // targetTags + ImmutableList.of( // allowed + Rule.create("tcp", ImmutableList.of("1-65535")), // + Rule.create("udp", ImmutableList.of("1-65535")), // + Rule.create("icmp", null) // + )); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleListTest.java index e2c0f40..f3dcd74 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleListTest.java @@ -16,22 +16,18 @@ */ package org.jclouds.googlecomputeengine.parse; -import com.google.common.collect.ImmutableSet; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + +import javax.ws.rs.Consumes; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.ForwardingRule; -import org.jclouds.googlecomputeengine.domain.ForwardingRule.IPProtocolOption; import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; +import com.google.common.collect.ImmutableList; -import java.net.URI; - -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseForwardingRuleListTest") public class ParseForwardingRuleListTest extends BaseGoogleComputeEngineParseTest<ListPage<ForwardingRule>> { @Override @@ -39,24 +35,12 @@ public class ParseForwardingRuleListTest extends BaseGoogleComputeEngineParseTes return "/forwardingrule_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<ForwardingRule> expected() { - return ListPage.<ForwardingRule>builder() - .kind(Resource.Kind.FORWARDING_RULE_LIST) - .items(ImmutableSet.of(ForwardingRule.builder() - .id("6732523704970219884") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-08T06:51:10.809-08:00")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/regions/europe-west1/forwardingRules/test-forwarding-rule")) - .name("test-forwarding-rule") - .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1")) - .ipAddress("23.251.129.77") - .ipProtocol(IPProtocolOption.TCP) - .target(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/regions/europe-west1/targetPools/test-target-pool")) - .portRange("1-65535") - .build()) - ).build(); + return ListPage.create( // + ImmutableList.of(new ParseForwardingRuleTest().expected()), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java index 0f06726..ac0af80 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java @@ -16,18 +16,17 @@ */ package org.jclouds.googlecomputeengine.parse; -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ForwardingRule; -import org.jclouds.googlecomputeengine.domain.ForwardingRule.IPProtocolOption; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + +import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import java.net.URI; +import org.jclouds.googlecomputeengine.domain.ForwardingRule; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseForwardingRuleTest") public class ParseForwardingRuleTest extends BaseGoogleComputeEngineParseTest<ForwardingRule> { @Override @@ -35,19 +34,18 @@ public class ParseForwardingRuleTest extends BaseGoogleComputeEngineParseTest<Fo return "/forwardingrule_get.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ForwardingRule expected() { - return ForwardingRule.builder() - .id("6732523704970219884") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-08T06:51:10.809-08:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1/forwardingRules/test-forwarding-rule")) - .name("test-forwarding-rule") - .region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1")) - .target(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1/targetPools/test-target-pool")) - .ipAddress("23.251.129.77") - .ipProtocol(IPProtocolOption.TCP) - .portRange("1-65535") - .build(); + return ForwardingRule.create( // + "6732523704970219884", // id + URI.create(BASE_URL + "/myproject/regions/europe-west1/forwardingRules/test-forwarding-rule"), // selfLink + "test-forwarding-rule", // name + null, // description + URI.create(BASE_URL + "/myproject/regions/europe-west1"), // region + "23.251.129.77", // ipAddress + ForwardingRule.IPProtocol.TCP, // ipProtocol + "1-65535", // portRange + URI.create(BASE_URL + "/myproject/regions/europe-west1/targetPools/test-target-pool") // target + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationListTest.java new file mode 100644 index 0000000..1536545 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationListTest.java @@ -0,0 +1,46 @@ +/* + * 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.parse; + +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + +import javax.ws.rs.Consumes; + +import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableList; + +@Test(groups = "unit", testName = "ParseGlobalOperationListTest") +public class ParseGlobalOperationListTest extends BaseGoogleComputeEngineParseTest<ListPage<Operation>> { + + @Override + public String resource() { + return "/global_operation_list.json"; + } + + @Override @Consumes(APPLICATION_JSON) + public ListPage<Operation> expected() { + return ListPage.create( // + ImmutableList.of(new ParseGlobalOperationTest().expected()), // items + null, // nextPageToken + null // prefixes + ); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationTest.java new file mode 100644 index 0000000..aba9de3 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalOperationTest.java @@ -0,0 +1,62 @@ +/* + * 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.parse; + +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + +import java.net.URI; + +import javax.ws.rs.Consumes; + +import org.jclouds.googlecomputeengine.domain.Operation; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; + +@Test(groups = "unit", testName = "ParseGlobalOperationTest") +public class ParseGlobalOperationTest extends BaseGoogleComputeEngineParseTest<Operation> { + + @Override + public String resource() { + return "/global_operation.json"; + } + + @Override @Consumes(APPLICATION_JSON) + public Operation expected() { + return Operation.create( // + "13053095055850848306", // id + URI.create(BASE_URL + "/myproject/global/operations/operation-1354084865060-4cf88735faeb8-bbbb12cb"), + "operation-1354084865060-4cf88735faeb8-bbbb12cb", // name + null, // description + URI.create(BASE_URL + "/myproject/global/firewalls/jclouds-test-delete"), // targetLink + "13053094017547040099", // targetId + null, // clientOperationId + Operation.Status.DONE, // status + null, // statusMessage + "[email protected]", // user + 100, // progress + parse("2012-11-28T06:41:05.060"), // insertTime + parse("2012-11-28T06:41:05.142"), // startTime + parse("2012-11-28T06:41:06.142"), // endTime + null, // httpErrorStatusCode + null, // httpErrorMessage + "insert", // operationType + null, // errors + null, // region + null // zone + ); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckListTest.java index f726320..bb5cc39 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckListTest.java @@ -16,21 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseHttpHealthCheckListTest") public class ParseHttpHealthCheckListTest extends BaseGoogleComputeEngineParseTest<ListPage<HttpHealthCheck>> { @Override @@ -38,45 +37,41 @@ public class ParseHttpHealthCheckListTest extends BaseGoogleComputeEngineParseTe return "/httphealthcheck_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<HttpHealthCheck> expected() { - return ListPage.<HttpHealthCheck>builder() - .kind(Resource.Kind.HTTP_HEALTH_CHECK_LIST) - .items(ImmutableSet.of(HttpHealthCheck.builder() - .id("2761502483700014319") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-14T05:55:54.910-08:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/jclouds-gce/global/httpHealthChecks/http-health-check-api-live-test")) - .name("http-health-check-api-live-test") - .port(0) - .checkIntervalSec(0) - .timeoutSec(0) - .unhealthyThreshold(0) - .healthyThreshold(0) - .build(), - HttpHealthCheck.builder() - .id("1035854271083519643") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-08T14:38:29.363-08:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/jclouds-gce/global/httpHealthChecks/myname-andrea-kmzmi1bh-http-health-check")) - .name("myname-andrea-kmzmi1bh-http-health-check") - .port(0) - .checkIntervalSec(0) - .timeoutSec(5) - .unhealthyThreshold(2) - .healthyThreshold(0) - .build(), - HttpHealthCheck.builder() - .id("7006563292274658743") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-08T14:48:03.276-08:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/jclouds-gce/global/httpHealthChecks/myname-andrea-zk7gadwq-http-health-check")) - .name("myname-andrea-zk7gadwq-http-health-check") - .port(0) - .checkIntervalSec(0) - .timeoutSec(5) - .unhealthyThreshold(2) - .healthyThreshold(0) - .build() - )) - .build(); + HttpHealthCheck healthCheck1 = new ParseHttpHealthCheckTest().expected(); + HttpHealthCheck healthCheck2 = HttpHealthCheck.create( // + "1035854271083519643", // id + URI.create(BASE_URL + "/jclouds-gce/global/httpHealthChecks/myname-andrea-kmzmi1bh-http-health-check"), + // selfLink + "myname-andrea-kmzmi1bh-http-health-check", // name + null, // description + null, // host + null, // requestPath + null, // port + null, // checkIntervalSec + 5, // timeoutSec + 2, // unhealthyThreshold + null // healthyThreshold + ); + HttpHealthCheck healthCheck3 = HttpHealthCheck.create( // + "7006563292274658743", // id + URI.create(BASE_URL + "/jclouds-gce/global/httpHealthChecks/myname-andrea-zk7gadwq-http-health-check"), + // selfLink + "myname-andrea-zk7gadwq-http-health-check", // name + null, // description + null, // host + null, // requestPath + null, // port + null, // checkIntervalSec + 5, // timeoutSec + 2, // unhealthyThreshold + null // healthyThreshold + ); + return ListPage.create( // + ImmutableList.of(healthCheck1, healthCheck2, healthCheck3), // items + null, // nextPageToken + null // prefixes + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/b41b0d04/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckTest.java index d492544..c2d672e 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseHttpHealthCheckTest.java @@ -16,17 +16,17 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -@Test(groups = "unit") +@Test(groups = "unit", testName = "ParseHttpHealthCheckTest") public class ParseHttpHealthCheckTest extends BaseGoogleComputeEngineParseTest<HttpHealthCheck> { @Override @@ -34,20 +34,20 @@ public class ParseHttpHealthCheckTest extends BaseGoogleComputeEngineParseTest<H return "/httphealthcheck_get.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public HttpHealthCheck expected() { - return HttpHealthCheck.builder() - .id("2761502483700014319") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-01-14T05:55:54.910-08:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/jclouds-gce/global/httpHealthChecks/http-health-check-api-live-test")) - .name("http-health-check-api-live-test") - .port(0) - .checkIntervalSec(0) - .timeoutSec(0) - .unhealthyThreshold(0) - .healthyThreshold(0) - .build(); - + return HttpHealthCheck.create( // + "2761502483700014319", // id + URI.create(BASE_URL + "/jclouds-gce/global/httpHealthChecks/http-health-check-api-live-test"), // selfLink + "http-health-check-api-live-test", // name + null, // description + null, // host + null, // requestPath + null, // port + null, // checkIntervalSec + null, // timeoutSec + null, // unhealthyThreshold + null // healthyThreshold + ); } }
