http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java index 707f8c6..e2fe73f 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRegions.java @@ -47,7 +47,7 @@ public final class ParseRegions extends ParseJson<ListPage<Region>> { final ListOptions options) { return new Function<String, ListPage<Region>>() { @Override public ListPage<Region> apply(String input) { - return api.getRegionApi(projectName).listAtMarker(input, options); + return api.getRegionApi(projectName).listPage(input, options); } }; }
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java index 59053e5..c56c9e4 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseRoutes.java @@ -48,7 +48,7 @@ public final class ParseRoutes extends ParseJson<ListPage<Route>> { final ListOptions options) { return new Function<String, ListPage<Route>>() { @Override public ListPage<Route> apply(String input) { - return api.getRouteApi(projectName).listAtMarker(input, options); + return api.getRouteApi(projectName).listPage(input, options); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java index a5df763..2265012 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseSnapshots.java @@ -47,7 +47,7 @@ public final class ParseSnapshots extends ParseJson<ListPage<Snapshot>> { final ListOptions options) { return new Function<String, ListPage<Snapshot>>() { @Override public ListPage<Snapshot> apply(String input) { - return api.getSnapshotApi(projectName).listAtMarker(input, options); + return api.getSnapshotApi(projectName).listPage(input, options); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java index 466a859..d23ab07 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseTargetPools.java @@ -52,7 +52,7 @@ public final class ParseTargetPools extends ParseJson<ListPage<TargetPool>> { @Override public ListPage<TargetPool> apply(String input) { - return api.getTargetPoolApi(projectName, regionName).list(options); + return api.getTargetPoolApi(projectName, regionName).listPage(input, options); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java index 5bad3df..de2e6ec 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZoneOperations.java @@ -48,7 +48,7 @@ public final class ParseZoneOperations extends ParseJson<ListPage<Operation>> { return new Function<String, ListPage<Operation>>() { @Override public ListPage<Operation> apply(String input) { - return api.getZoneOperationApi(projectName).listAtMarkerInZone(zoneName, input, options); + return api.getZoneOperationApi(projectName, zoneName).listPage(input, options); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java index 0253f9e..fee1fdc 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/functions/internal/ParseZones.java @@ -48,7 +48,7 @@ public final class ParseZones extends ParseJson<ListPage<Zone>> { final ListOptions options) { return new Function<String, ListPage<Zone>>() { @Override public ListPage<Zone> apply(String input) { - return api.getZoneApi(projectName).listAtMarker(input, options); + return api.getZoneApi(projectName).listPage(input, options); } }; } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java index 5ad2846..4f85702 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/AttachDiskOptions.java @@ -23,7 +23,7 @@ import java.net.URI; * * @see <a href="https://developers.google.com/compute/docs/reference/latest/instances/attachDisk"/> */ -public class AttachDiskOptions { +public final class AttachDiskOptions { public enum DiskType { SCRATCH, @@ -41,53 +41,31 @@ public class AttachDiskOptions { private String deviceName; private boolean boot; - /** - * The disk type - * - * @return the disk type. - */ - public DiskType getType() { + public DiskType type() { return type; } - /** - * The disk mode - * - * @return the disk mode - */ - public DiskMode getMode() { + public DiskMode mode() { return mode; } - /** - * The URI of the source disk - optional, if DiskType.SCRATCH is used. - * - * @return the URI - */ - public URI getSource() { + /** The URI of the source disk - optional, if DiskType.SCRATCH is used. */ + public URI source() { return source; } - /** - * The device name on the instance - optional. - * - * @return the device name - */ - public String getDeviceName() { + /** The device name on the instance - optional. */ + public String deviceName() { return deviceName; } - /** - * Indicates that this is a boot disk. VM will use the first partition of the disk for its root filesystem. - * - * @return true if this is a boot disk, false otherwise - */ - public boolean getBoot() { + /** True if this is a boot disk. VM will use the first partition of the disk for its root filesystem. */ + public boolean boot() { return boot; } /** - * @see AttachDiskOptions#getType() + * @see AttachDiskOptions#type() */ public AttachDiskOptions type(DiskType type) { this.type = type; @@ -95,7 +73,7 @@ public class AttachDiskOptions { } /** - * @see AttachDiskOptions#getMode() + * @see AttachDiskOptions#mode() */ public AttachDiskOptions mode(DiskMode mode) { this.mode = mode; @@ -103,7 +81,7 @@ public class AttachDiskOptions { } /** - * @see AttachDiskOptions#getSource() + * @see AttachDiskOptions#source() */ public AttachDiskOptions source(URI source) { this.source = source; @@ -111,7 +89,7 @@ public class AttachDiskOptions { } /** - * @see AttachDiskOptions#getDeviceName() + * @see AttachDiskOptions#deviceName() */ public AttachDiskOptions deviceName(String deviceName) { this.deviceName = deviceName; @@ -119,7 +97,7 @@ public class AttachDiskOptions { } /** - * @see org.jclouds.googlecomputeengine.options.AttachDiskOptions#getBoot() + * @see AttachDiskOptions#boot() */ public AttachDiskOptions boot(boolean boot) { this.boot = boot; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java index 7c70586..2dd215c 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/DiskCreationOptions.java @@ -18,16 +18,8 @@ package org.jclouds.googlecomputeengine.options; import java.net.URI; -/** - * Options for attaching disks to instances. - * - * @see <a href="https://cloud.google.com/compute/docs/reference/latest/disks/insert"/> - */ -public class DiskCreationOptions { +public final class DiskCreationOptions { - /** - * DiskCreationBinder extends this class to add name and sizeGb - */ private URI type; private URI sourceImage; private URI sourceSnapshot; @@ -37,7 +29,7 @@ public class DiskCreationOptions { * * @return the disk type */ - public URI getType(){ + public URI type(){ return type; } @@ -46,7 +38,7 @@ public class DiskCreationOptions { * * @return sourceImage, fully qualified URL for the image to be copied. */ - public URI getSourceImage(){ + public URI sourceImage(){ return sourceImage; } @@ -55,12 +47,12 @@ public class DiskCreationOptions { * * @return sourceSnapshot, fully qualified URL for the snapshot to be copied. */ - public URI getSourceSnapshot(){ + public URI sourceSnapshot(){ return sourceSnapshot; } /** - * @see DiskCreationOptions#getType() + * @see DiskCreationOptions#type() */ public DiskCreationOptions type(URI type){ this.type = type; @@ -68,7 +60,7 @@ public class DiskCreationOptions { } /** - * @see DiskCreationOptions#getSourceImage() + * @see DiskCreationOptions#sourceImage() */ public DiskCreationOptions sourceImage(URI sourceImage){ this.sourceImage = sourceImage; @@ -76,7 +68,7 @@ public class DiskCreationOptions { } /** - * @see DiskCreationOptions#getSourceSnapshot() + * @see DiskCreationOptions#sourceSnapshot() */ public DiskCreationOptions sourceSnapshot(URI sourceSnapshot){ this.sourceSnapshot = sourceSnapshot; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java index 3944486..0c46000 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/options/ListOptions.java @@ -23,7 +23,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions; /** * Allows to optionally specify a filter, max results and a page token for <code>listFirstPage()</code> REST methods. */ -public class ListOptions extends BaseHttpRequestOptions { +public final class ListOptions extends BaseHttpRequestOptions { /** * Optional. Filter expression for filtering listed resources, in the form filter={expression}. Your {expression} @@ -70,7 +70,7 @@ public class ListOptions extends BaseHttpRequestOptions { return this; } - public static class Builder { + public static final class Builder { /** * @see ListOptions#filter(String) @@ -85,5 +85,8 @@ public class ListOptions extends BaseHttpRequestOptions { public static ListOptions maxResults(Integer maxResults) { return new ListOptions().maxResults(maxResults); } + + private Builder(){ + } } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java index 2ebfaa3..1eb3f4d 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/RegionOperationDonePredicate.java @@ -22,6 +22,8 @@ import java.net.URI; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; +import javax.inject.Inject; + import org.jclouds.collect.Memoized; import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.config.UserProject; @@ -30,10 +32,8 @@ import org.jclouds.googlecomputeengine.domain.Region; import com.google.common.base.Predicate; import com.google.common.base.Supplier; -import com.google.inject.Inject; public final class RegionOperationDonePredicate implements Predicate<AtomicReference<Operation>> { - private final GoogleComputeEngineApi api; private final Supplier<String> project; private final Supplier<Map<URI, Region>> regions; @@ -46,11 +46,10 @@ public final class RegionOperationDonePredicate implements Predicate<AtomicRefer } @Override public boolean apply(AtomicReference<Operation> input) { - checkNotNull(input, "input"); - - Operation current = api.getRegionOperationApi(project.get()) - .getInRegion(regions.get().get(input.get().region()).name(), - input.get().name()); + checkNotNull(input.get(), "input"); + URI region = checkNotNull(input.get().region(), "region of %s", input.get()); + String locationId = checkNotNull(regions.get().get(region), "location of %s", region).id(); + Operation current = api.getRegionOperationApi(project.get(), locationId).get(input.get().name()); switch (current.status()) { case DONE: input.set(current); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java index 1f60dd9..9c727ed 100644 --- a/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java +++ b/google-compute-engine/src/main/java/org/jclouds/googlecomputeengine/predicates/ZoneOperationDonePredicate.java @@ -52,7 +52,7 @@ public final class ZoneOperationDonePredicate implements Predicate<AtomicReferen checkNotNull(input.get(), "input"); URI zone = checkNotNull(input.get().zone(), "zone of %s", input.get()); String locationId = checkNotNull(zones.get().get(zone), "location of %s", zone).getId(); - Operation current = api.getZoneOperationApi(project.get()).getInZone(locationId, input.get().name()); + Operation current = api.getZoneOperationApi(project.get(), locationId).get(input.get().name()); switch (current.status()) { case DONE: input.set(current); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java deleted file mode 100644 index 7f2ed9d..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/PageSystemExpectTest.java +++ /dev/null @@ -1,111 +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; - -import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertSame; - -import java.util.Iterator; - -import org.jclouds.googlecomputeengine.domain.Image; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.features.ImageApi; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; -import org.jclouds.googlecomputeengine.options.ListOptions; -import org.jclouds.http.HttpRequest; -import org.jclouds.http.HttpResponse; -import org.testng.annotations.Test; - -/** - * A test specifically for the paging system. The code used is common to all list() methods so we're using Images - * but it could be anything else. - */ -@Test(groups = "unit") -public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest { - - public void testGetSinglePage() { - HttpRequest list = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/images") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse operationResponse = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_single_page.json")).build(); - - ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getImageApi("myproject"); - - Iterator<ListPage<Image>> images = imageApi.list(); - - assertEquals(images.next().size(), 3); - } - - public void testGetMultiplePages() { - HttpRequest list1 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/images?maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest list2 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/images?pageToken" + - "=CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx&maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpRequest list3 = HttpRequest - .builder() - .method("GET") - .endpoint("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/images?pageToken" + - "=CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2&maxResults=3") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - HttpResponse list1response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_multiple_page_1.json")).build(); - - HttpResponse list2Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_multiple_page_2.json")).build(); - - HttpResponse list3Response = HttpResponse.builder().statusCode(200) - .payload(payloadFromResource("/image_list_single_page.json")).build(); - - - ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response) - .getImageApi("myproject"); - - Iterator<ListPage<Image>> images = imageApi.list(new ListOptions.Builder().maxResults(3)); - - int imageCounter = 0; - while (images.hasNext()) { - imageCounter += images.next().size(); - } - assertSame(imageCounter, 9); - } - -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java index 5075cdb..86ea1a0 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/DiskCreationBinderTest.java @@ -24,44 +24,29 @@ import java.util.Map; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest; import org.jclouds.googlecomputeengine.options.DiskCreationOptions; import org.jclouds.http.HttpRequest; -import org.jclouds.json.Json; -import org.jclouds.json.internal.GsonWrapper; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; -/** - * Tests behavior of {@code BindToJsonPayload} - */ @Test(groups = "unit", testName = "DiskCreationBinderTest") public class DiskCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{ private static final String FAKE_SOURCE_IMAGE = "https://www.googleapis.com/compute/v1/projects/" + "debian-cloud/global/images/backports-debian-7-wheezy-v20141017"; - Json json = new GsonWrapper(new Gson()); + DiskCreationBinder binder = new DiskCreationBinder(); @Test public void testMap() throws SecurityException, NoSuchMethodException { - DiskCreationBinder binder = new DiskCreationBinder(json); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(FAKE_SOURCE_IMAGE)); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build(); Map<String, Object> postParams = ImmutableMap.of("name", "testName", "sizeGb", 15, "options", diskCreationOptions); - binder.bindToRequest(request, postParams); + request = binder.bindToRequest(request, postParams); assertEquals(request.getPayload().getRawContent(), "{\"name\":\"testName\",\"sizeGb\":15,\"sourceImage\":\"" + FAKE_SOURCE_IMAGE + "\"}"); assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testNullIsBad() { - DiskCreationBinder binder = new DiskCreationBinder(json); - binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java index 66f8b3d..3a480d8 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/ForwardingRuleCreationBinderTest.java @@ -32,10 +32,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; - -/** - * Tests behavior of {@code BindToJsonPayload} - */ @Test(groups = "unit", testName = "ForwardingRuleCreationBinderTest") public class ForwardingRuleCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{ @@ -72,13 +68,5 @@ public class ForwardingRuleCreationBinderTest extends BaseGoogleComputeEngineExp + "\"target\":\"" + TARGET + "\"" + "}"); assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testNullIsBad() { - ForwardingRuleCreationBinder binder = new ForwardingRuleCreationBinder(json); - binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java index 1dec9dc..e9a8fe4 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/HttpHealthCheckCreationBinderTest.java @@ -30,10 +30,6 @@ import org.testng.annotations.Test; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; - -/** - * Tests behavior of {@code BindToJsonPayload} - */ @Test(groups = "unit", testName = "HttpHealthCheckCreationBinderTest") public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{ @@ -68,13 +64,5 @@ public class HttpHealthCheckCreationBinderTest extends BaseGoogleComputeEngineEx + "\"description\":\"" + DESCRIPTION + "\"" + "}"); assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testNullIsBad() { - DiskCreationBinder binder = new DiskCreationBinder(json); - binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java index 129d006..d20fb22 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolAddInstanceBinderTest.java @@ -24,13 +24,10 @@ import java.util.Map; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest; import org.jclouds.http.HttpRequest; -import org.jclouds.json.Json; -import org.jclouds.json.internal.GsonWrapper; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.gson.Gson; @Test(groups = "unit", testName = "TargetPoolAddInstanceBinderTest") public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{ @@ -40,12 +37,11 @@ public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpe "projects/project/zones/us-central1-a/instances/instance-1"), URI.create("https://www.googleapis.com/compute/v1/" + "projects/project/zones/us-central1-a/instances/instance-2")); - - Json json = new GsonWrapper(new Gson()); + + TargetPoolChangeInstancesBinder binder = new TargetPoolChangeInstancesBinder(); @Test public void testMap() throws SecurityException, NoSuchMethodException { - TargetPoolChangeInstancesBinder binder = new TargetPoolChangeInstancesBinder(json); HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build(); Map<String, Object> postParams = ImmutableMap.of("instances", (Object) FAKE_INSTANCES); @@ -59,12 +55,5 @@ public class TargetPoolAddInstanceBinderTest extends BaseGoogleComputeEngineExpe + "]" + "}"); assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); - - } - - @Test(expectedExceptions = NullPointerException.class) - public void testNullIsBad() { - DiskCreationBinder binder = new DiskCreationBinder(json); - binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java index 2c756c0..f55e938 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/binders/TargetPoolCreationBinderTest.java @@ -34,10 +34,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.gson.Gson; - -/** - * Tests behavior of {@code BindToJsonPayload} - */ @Test(groups = "unit", testName = "TargetPoolCreationBinderTest") public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectTest<Object>{ @@ -72,13 +68,5 @@ public class TargetPoolCreationBinderTest extends BaseGoogleComputeEngineExpectT + "\"description\":\"This is a test!\"" + "}"); assertEquals(request.getPayload().getContentMetadata().getContentType(), "application/json"); - } - - @Test(expectedExceptions = NullPointerException.class) - public void testNullIsBad() { - DiskCreationBinder binder = new DiskCreationBinder(json); - binder.bindToRequest(HttpRequest.builder().method("GET").endpoint("http://momma").build(), null); - } - } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java index e7470e7..5a9f52e 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/GoogleComputeEngineServiceLiveTest.java @@ -22,7 +22,6 @@ import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import java.util.Properties; -import java.util.Set; import org.jclouds.compute.domain.Hardware; import org.jclouds.compute.domain.NodeMetadata; @@ -66,17 +65,13 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe Supplier<String> userProject = context.utils().injector().getInstance(Key.get(new TypeLiteral<Supplier<String>>() { }, UserProject.class)); ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder(); - for (MachineType machine : api.getMachineTypeApi(userProject.get()) - .listInZone(DEFAULT_ZONE_NAME).next()) { + for (MachineType machine : api.getMachineTypeApi(userProject.get(), DEFAULT_ZONE_NAME).list().next()) { if (machine.deprecated() != null) { deprecatedMachineTypes.add(machine.id()); } } ImmutableSet<String> deprecatedMachineTypeIds = deprecatedMachineTypes.build(); - Set<? extends Hardware> hardwareProfiles = client.listHardwareProfiles(); - System.out.println(hardwareProfiles.size()); - for (Hardware hardwareProfile : hardwareProfiles) { - System.out.println(hardwareProfile); + for (Hardware hardwareProfile : client.listHardwareProfiles()) { assertFalse(contains(deprecatedMachineTypeIds, hardwareProfile.getId())); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java index 76454d4..891a5a9 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/compute/functions/NetworkToSecurityGroupTest.java @@ -22,6 +22,7 @@ import static org.easymock.EasyMock.expect; import static org.easymock.EasyMock.replay; import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasProtocol; import static org.jclouds.googlecomputeengine.compute.functions.FirewallToIpPermissionTest.hasStartAndEndPort; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -33,7 +34,6 @@ import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Network; import org.jclouds.googlecomputeengine.features.FirewallApi; import org.jclouds.googlecomputeengine.options.ListOptions; -import org.jclouds.googlecomputeengine.options.ListOptions.Builder; import org.jclouds.net.domain.IpProtocol; import org.testng.annotations.Test; @@ -58,7 +58,7 @@ public class NetworkToSecurityGroupTest { GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class); FirewallApi fwApi = createMock(FirewallApi.class); - ListOptions options = new Builder().filter("network eq .*/jclouds-test"); + ListOptions options = filter("network eq .*/jclouds-test"); expect(api.getFirewallApi(projectSupplier.get())) .andReturn(fwApi); expect(fwApi.list(options)).andReturn( http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java index 09e9057..ef18d2b 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiExpectTest.java @@ -47,10 +47,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/address_get.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject", "us-central1"); - assertEquals(api.getInRegion("us-central1", "test-ip1"), - new ParseAddressTest().expected()); + assertEquals(api.get("test-ip1"), new ParseAddressTest().expected()); } public void testGetAddressResponseIs4xx() throws Exception { @@ -64,9 +63,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject", "us-central1"); - assertNull(api.getInRegion("us-central1", "test-ip1")); + assertNull(api.get("test-ip1")); } public void testInsertAddressResponseIs2xx() { @@ -84,9 +83,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertAddressResponse).getAddressApi("myproject"); + insertAddressResponse).getAddressApi("myproject", "us-central1"); - assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseRegionOperationTest().expected()); + assertEquals(api.create("test-ip1"), new ParseRegionOperationTest().expected()); } public void testDeleteAddressResponseIs2xx() { @@ -101,10 +100,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/region_operation.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject", "us-central1"); - assertEquals(api.deleteInRegion("us-central1", "test-ip1"), - new ParseRegionOperationTest().expected()); + assertEquals(api.delete("test-ip1"), new ParseRegionOperationTest().expected()); } public void testDeleteAddressResponseIs4xx() { @@ -118,9 +116,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject", "us-central1"); - assertNull(api.deleteInRegion("us-central1", "test-ip1")); + assertNull(api.delete("test-ip1")); } public void testListAddresssResponseIs2xx() { @@ -135,9 +133,9 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/address_list.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject", "us-central1"); - assertEquals(api.listInRegion("us-central1").next().toString(), new ParseAddressListTest().expected().toString()); + assertEquals(api.list().next().toString(), new ParseAddressListTest().expected().toString()); } public void testListAddresssResponseIs4xx() { @@ -151,8 +149,8 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject"); + TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject", "us-central1"); - assertFalse(api.listInRegion("us-central1").hasNext()); + assertFalse(api.list().hasNext()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java index cbd707c..f076687 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/AddressApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -24,7 +25,6 @@ import java.util.Iterator; import org.jclouds.googlecomputeengine.domain.Address; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @@ -33,18 +33,18 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final int TIME_WAIT = 30; private AddressApi api() { - return api.getAddressApi(userProject.get()); + return api.getAddressApi(userProject.get(), DEFAULT_REGION_NAME); } @Test(groups = "live") public void testInsertAddress() { - assertRegionOperationDoneSucessfully(api().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT); + assertRegionOperationDoneSucessfully(api().create(ADDRESS_NAME), TIME_WAIT); } @Test(groups = "live", dependsOnMethods = "testInsertAddress") public void testGetAddress() { - Address address = api().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME); + Address address = api().get(ADDRESS_NAME); assertNotNull(address); assertEquals(address.name(), ADDRESS_NAME); } @@ -52,15 +52,13 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testGetAddress") public void testListAddress() { - Iterator<ListPage<Address>> addresses = api().listInRegion(DEFAULT_REGION_NAME, new ListOptions.Builder() - .filter("name eq " + ADDRESS_NAME)); - + Iterator<ListPage<Address>> addresses = api().list(filter("name eq " + ADDRESS_NAME)); assertEquals(addresses.next().size(), 1); } @Test(groups = "live", dependsOnMethods = "testListAddress") public void testDeleteAddress() { - assertRegionOperationDoneSucessfully(api().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT); + assertRegionOperationDoneSucessfully(api().delete(ADDRESS_NAME), TIME_WAIT); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java index d11f26d..6122b2b 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiExpectTest.java @@ -53,9 +53,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/disk_get.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject", "us-central1-a"); - assertEquals(api.getInZone("us-central1-a", "testimage1"), + assertEquals(api.get("testimage1"), new ParseDiskTest().expected()); } @@ -70,9 +70,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject", "us-central1-a"); - assertNull(api.getInZone("us-central1-a", "testimage1")); + assertNull(api.get("testimage1")); } public void testInsertDiskResponseIs2xx() { @@ -90,9 +90,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApi("myproject"); + insertDiskResponse).getDiskApi("myproject", "us-central1-a"); - assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseZoneOperationTest().expected()); + assertEquals(api.create("testimage1", 1), new ParseZoneOperationTest().expected()); } public void testInsertDiskFromImageResponseIs2xx() { @@ -110,11 +110,10 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApi("myproject"); + insertDiskResponse).getDiskApi("myproject", "us-central1-a"); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL)); - assertEquals(api.createInZone("testimage1", 1, "us-central1-a", diskCreationOptions), - new ParseZoneOperationTest().expected()); + assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected()); } public void testInsertDiskSSDResponseIs2xx(){ @@ -132,11 +131,10 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApi("myproject"); + insertDiskResponse).getDiskApi("myproject", "us-central1-a"); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL)); - assertEquals(api.createInZone("testimage1", 1, - "us-central1-a", diskCreationOptions), new ParseZoneOperationTest().expected()); + assertEquals(api.create("testimage1", 1, diskCreationOptions), new ParseZoneOperationTest().expected()); } public void testCreateSnapshotResponseIs2xx() { @@ -154,9 +152,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createSnapshotRequest, - createSnapshotResponse).getDiskApi("myproject"); + createSnapshotResponse).getDiskApi("myproject", "us-central1-a"); - assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), + assertEquals(api.createSnapshot("testimage1", "test-snap"), new ParseZoneOperationTest().expected()); } @@ -175,9 +173,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createSnapshotRequest, - createSnapshotResponse).getDiskApi("myproject"); + createSnapshotResponse).getDiskApi("myproject", "us-central1-a"); - api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"); + api.createSnapshot("testimage1", "test-snap"); } public void testDeleteDiskResponseIs2xx() { @@ -192,9 +190,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/zone_operation.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject", "us-central1-a"); - assertEquals(api.deleteInZone("us-central1-a", "testimage1"), + assertEquals(api.delete("testimage1"), new ParseZoneOperationTest().expected()); } @@ -209,9 +207,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject", "us-central1-a"); - assertNull(api.deleteInZone("us-central1-a", "testimage1")); + assertNull(api.delete("testimage1")); } public void testListDisksResponseIs2xx() { @@ -226,9 +224,9 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/disk_list.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject", "us-central1-a"); - assertEquals(api.listInZone("us-central1-a").next().toString(), new ParseDiskListTest().expected().toString()); + assertEquals(api.list().next().toString(), new ParseDiskListTest().expected().toString()); } public void testListDisksResponseIs4xx() { @@ -242,8 +240,8 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject"); + TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject", "us-central1-a"); - assertFalse(api.listInZone("us-central1-a").hasNext()); + assertFalse(api.list().hasNext()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java index d05454a..ad771d9 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Disk; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.DiskCreationOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @@ -38,40 +38,35 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public static final int sizeGb = 1; private DiskApi api() { - return api.getDiskApi(userProject.get()); + return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME); } @Test(groups = "live") public void testInsertDisk() { - assertZoneOperationDoneSuccessfully(api().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT); + assertZoneOperationDoneSuccessfully(api().create(DISK_NAME, sizeGb), TIME_WAIT); } @Test(groups = "live", dependsOnMethods = "testInsertDisk") public void testGetDisk() { - - Disk disk = api().getInZone(DEFAULT_ZONE_NAME, DISK_NAME); + Disk disk = api().get(DISK_NAME); assertNotNull(disk); assertDiskEquals(disk); } @Test(groups = "live", dependsOnMethods = "testGetDisk") public void testListDisk() { - - Iterator<ListPage<Disk>> disks = api().listInZone(DEFAULT_ZONE_NAME, new ListOptions.Builder() - .filter("name eq " + DISK_NAME)); + Iterator<ListPage<Disk>> disks = api().list(filter("name eq " + DISK_NAME)); List<Disk> disksAsList = disks.next(); assertEquals(disksAsList.size(), 1); assertDiskEquals(disksAsList.get(0)); - } @Test(groups = "live", dependsOnMethods = "testListDisk") public void testDeleteDisk() { - - assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT); + assertZoneOperationDoneSuccessfully(api().delete(DISK_NAME), TIME_WAIT); } private void assertDiskEquals(Disk result) { @@ -84,22 +79,19 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public void testInsertSSDDisk() { URI diskType = getDiskTypeUrl(userProject.get(), DEFAULT_ZONE_NAME, "pd-ssd"); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(diskType); - assertZoneOperationDoneSuccessfully( - api().createInZone(SSD_DISK_NAME, sizeGb, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT); + assertZoneOperationDoneSuccessfully(api().create(SSD_DISK_NAME, sizeGb, diskCreationOptions), TIME_WAIT); } @Test(groups = "live", dependsOnMethods = "testInsertSSDDisk") public void testGetSSDDisk() { - - Disk disk = api().getInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME); + Disk disk = api().get(SSD_DISK_NAME); assertNotNull(disk); assertSSDDiskEquals(disk); } @Test(groups = "live", dependsOnMethods = "testGetSSDDisk") public void testDeleteSSDDisk() { - - assertZoneOperationDoneSuccessfully(api().deleteInZone(DEFAULT_ZONE_NAME, SSD_DISK_NAME), TIME_WAIT); + assertZoneOperationDoneSuccessfully(api().delete(SSD_DISK_NAME), TIME_WAIT); } private void assertSSDDiskEquals(Disk result) { http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java index b62a251..a6ae5ac 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiExpectTest.java @@ -17,6 +17,7 @@ package org.jclouds.googlecomputeengine.features; import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; @@ -43,18 +44,6 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(staticPayloadFromResource("/disktype_list.json")) .build(); - public static final HttpRequest LIST_CENTRAL1B_DISK_TYPES_REQUEST = HttpRequest - .builder() - .method("GET") - .endpoint(BASE_URL + "/myproject/zones/us-central1-b/diskTypes") - .addHeader("Accept", "application/json") - .addHeader("Authorization", "Bearer " + TOKEN).build(); - - public static final HttpResponse LIST_CENTRAL1B_DISK_TYPES_RESPONSE = HttpResponse.builder() - .statusCode(200) - .payload(staticPayloadFromResource("/disktype_list_central1b.json")) - .build(); - public void testGetDiskTypeResponseIs2xx() throws Exception { HttpRequest get = HttpRequest .builder() @@ -67,9 +56,9 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/disktype.json")).build(); DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject", "us-central1-a"); - assertEquals(diskTypeApi.getInZone("us-central1-a", "pd-standard"), + assertEquals(diskTypeApi.get("pd-standard"), new ParseDiskTypeTest().expected()); } @@ -84,28 +73,30 @@ public class DiskTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskTypeApi("myproject", "us-central1-a"); - assertNull(diskTypeApi.getInZone("us-central1-a", "pd-standard")); + assertNull(diskTypeApi.get("pd-standard")); } public void testListDiskTypeNoOptionsResponseIs2xx() throws Exception { DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi - ("myproject"); + TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, LIST_DISK_TYPES_RESPONSE).getDiskTypeApi + ("myproject", "us-central1-a"); - assertEquals(diskTypeApi.listInZone("us-central1-a").next().toString(), - new ParseDiskTypeListTest().expected().toString()); + assertEquals(diskTypeApi.list().next().toString(), new ParseDiskTypeListTest().expected().toString()); } - public void testLisOperationWithPaginationOptionsResponseIs4xx() { + public void testListDiskTypesWithPaginationOptionsResponseIs4xx() { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); + HttpRequest listRequestWithOptions = LIST_DISK_TYPES_REQUEST.toBuilder() + .endpoint(LIST_DISK_TYPES_REQUEST.getEndpoint() + "?maxResults=1").build(); + DiskTypeApi diskTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_DISK_TYPES_REQUEST, operationResponse).getDiskTypeApi("myproject"); + TOKEN_RESPONSE, listRequestWithOptions, operationResponse).getDiskTypeApi("myproject", "us-central1-a"); - assertFalse(diskTypeApi.listInZone("us-central1-a").hasNext()); + assertFalse(diskTypeApi.list(maxResults(1)).hasNext()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java index 03c7b36..5e252f8 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/DiskTypeApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertTrue; @@ -25,7 +26,6 @@ import java.util.Iterator; import org.jclouds.googlecomputeengine.domain.DiskType; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @@ -33,14 +33,13 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private DiskType diskType; private DiskTypeApi api() { - return api.getDiskTypeApi(userProject.get()); + return api.getDiskTypeApi(userProject.get(), DEFAULT_ZONE_NAME); } @Test(groups = "live") public void testDiskType() { - Iterator<ListPage<DiskType>> pageIterator = api().listInZone(DEFAULT_ZONE_NAME, - new ListOptions.Builder().maxResults(1)); + Iterator<ListPage<DiskType>> pageIterator = api().list(maxResults(1)); assertTrue(pageIterator.hasNext()); ListPage<DiskType> page = pageIterator.next(); @@ -52,7 +51,7 @@ public class DiskTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testDiskType") public void testGetDiskType() { - DiskType diskType = api().getInZone(DEFAULT_ZONE_NAME, this.diskType.name()); + DiskType diskType = api().get(this.diskType.name()); assertNotNull(diskType); assertDiskTypeEquals(diskType, this.diskType); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java index f17c69e..6cc6ec7 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiLiveTest.java @@ -17,6 +17,7 @@ package org.jclouds.googlecomputeengine.features; import static com.google.common.collect.Iterables.getOnlyElement; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Firewall; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.FirewallOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; import com.google.common.collect.ImmutableList; @@ -110,8 +110,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testGetFirewall") public void testListFirewall() { - Iterator<ListPage<Firewall>> firewalls = api().list(new ListOptions.Builder() - .filter("name eq " + FIREWALL_NAME)); + Iterator<ListPage<Firewall>> firewalls = api().list(filter("name eq " + FIREWALL_NAME)); List<Firewall> firewallsAsList = firewalls.next(); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java index 380bfbb..9b361ee 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -25,7 +26,6 @@ import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.TargetPool; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.ForwardingRuleCreationOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.googlecomputeengine.options.TargetPoolCreationOptions; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -56,7 +56,7 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes } private AddressApi addressApi(){ - return api.getAddressApi(userProject.get()); + return api.getAddressApi(userProject.get(), DEFAULT_REGION_NAME); } @BeforeClass @@ -68,15 +68,15 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes assertRegionOperationDoneSucessfully(targetPoolApi().create(TARGETPOOL_NAME_NEW, targetPoolCreationOptions), TIME_WAIT); newTargetPool = targetPoolApi().get(TARGETPOOL_NAME_NEW); - assertRegionOperationDoneSucessfully(addressApi().createInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT); - address = addressApi().getInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME); + assertRegionOperationDoneSucessfully(addressApi().create(ADDRESS_NAME), TIME_WAIT); + address = addressApi().get(ADDRESS_NAME); } @AfterClass public void tearDown() { assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME), TIME_WAIT); assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME_NEW), TIME_WAIT); - assertRegionOperationDoneSucessfully(addressApi().deleteInRegion(DEFAULT_REGION_NAME, ADDRESS_NAME), TIME_WAIT); + assertRegionOperationDoneSucessfully(addressApi().delete(ADDRESS_NAME), TIME_WAIT); } @Test(groups = "live") @@ -111,9 +111,7 @@ public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTes @Test(groups = "live", dependsOnMethods = "testInsertForwardingRule") public void testListForwardingRule() { - - ListPage<ForwardingRule> forwardingRule = api().list(new ListOptions.Builder() - .filter("name eq " + FORWARDING_RULE_NAME)); + ListPage<ForwardingRule> forwardingRule = api().list(filter("name eq " + FORWARDING_RULE_NAME)).next(); assertEquals(forwardingRule.size(), 1); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java index d66532a..8209741 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiExpectTest.java @@ -18,12 +18,12 @@ package org.jclouds.googlecomputeengine.features; import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNull; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationListTest; import org.jclouds.googlecomputeengine.parse.ParseGlobalOperationTest; import org.jclouds.http.HttpRequest; @@ -69,6 +69,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe .builder() .method("DELETE") .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279") + .addHeader("Accept", "application/json") .addHeader("Authorization", "Bearer " + TOKEN).build(); HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build(); @@ -84,6 +85,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe .builder() .method("DELETE") .endpoint(OPERATIONS_URL_PREFIX + "/operation-1352178598164-4cdcc9d031510-4aa46279") + .addHeader("Accept", "application/json") .addHeader("Authorization", "Bearer " + TOKEN).build(); HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); @@ -131,9 +133,9 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject"); - assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" + + assertEquals(globalOperationApi.listPage("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" + "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz", - new ListOptions.Builder().filter("status eq done").maxResults(3)).toString(), + filter("status eq done").maxResults(3)).toString(), new ParseGlobalOperationListTest().expected().toString()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java index 0d40738..5205589 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/GlobalOperationApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -24,7 +25,6 @@ import java.util.Iterator; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.domain.Operation; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.SkipException; import org.testng.annotations.Test; @@ -38,9 +38,7 @@ public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe } public void testListOperationsWithFiltersAndPagination() { - Iterator<ListPage<Operation>> operations = api().list(new ListOptions.Builder() - // .filter("operationType eq insert") - .maxResults(1)); + Iterator<ListPage<Operation>> operations = api().list(maxResults(1)); // make sure that in spite of having only one result per page we get at least two results int count = 0; http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java index bebe700..9b70697 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.filter; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; import static org.testng.Assert.assertNotNull; @@ -24,7 +25,6 @@ import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.HttpHealthCheckCreationOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; import com.google.common.collect.Iterables; @@ -69,8 +69,7 @@ public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTe @Test(groups = "live", dependsOnMethods = "testInsertHttpHealthCheck") public void testListHttpHealthCheck() { - ListPage<HttpHealthCheck> httpHealthCheck = api().list(new ListOptions.Builder() - .filter("name eq " + HTTP_HEALTH_CHECK_NAME)); + ListPage<HttpHealthCheck> httpHealthCheck = api().list(filter("name eq " + HTTP_HEALTH_CHECK_NAME)).next(); assertEquals(Iterables.size(httpHealthCheck), 1); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java index 039adec..3383125 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiExpectTest.java @@ -168,7 +168,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject"); - assertEquals(imageApi.createImageFromPD("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"), + assertEquals(imageApi.createFromDisk("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"), new ParseOperationTest().expected()); } @@ -188,6 +188,6 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject"); - imageApi.createImageFromPD("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"); + imageApi.createFromDisk("my-image", BASE_URL + "/myproject/zones/us-central1-a/disks/mydisk"); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d7403236/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java index c9e34c9..2fc56a1 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ImageApiLiveTest.java @@ -16,6 +16,7 @@ */ package org.jclouds.googlecomputeengine.features; +import static org.jclouds.googlecomputeengine.options.ListOptions.Builder.maxResults; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; @@ -27,7 +28,6 @@ import org.jclouds.googlecomputeengine.domain.Disk; import org.jclouds.googlecomputeengine.domain.Image; import org.jclouds.googlecomputeengine.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.testng.annotations.Test; public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @@ -49,13 +49,12 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { } private DiskApi diskApi() { - return api.getDiskApi(userProject.get()); + return api.getDiskApi(userProject.get(), DEFAULT_ZONE_NAME); } @Test(groups = "live") public void testListImage() { - - Iterator<ListPage<Image>> images = api().list(new ListOptions.Builder().maxResults(1)); + Iterator<ListPage<Image>> images = api().list(maxResults(1)); List<Image> imageAsList = images.next(); @@ -78,14 +77,14 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live") public void testInsertDisk() { - assertZoneOperationDoneSuccessfully(diskApi().createInZone(DISK_NAME, sizeGb, DEFAULT_ZONE_NAME), TIME_WAIT); - Disk disk = diskApi().getInZone(DEFAULT_ZONE_NAME, DISK_NAME); + assertZoneOperationDoneSuccessfully(diskApi().create(DISK_NAME, sizeGb), TIME_WAIT); + Disk disk = diskApi().get(DISK_NAME); diskURI = disk.selfLink(); } @Test(groups = "live", dependsOnMethods = "testInsertDisk") public void testCreateImageFromPD(){ - assertGlobalOperationDoneSucessfully(imageApi().createImageFromPD(IMAGE_NAME, diskURI.toString()), TIME_WAIT); + assertGlobalOperationDoneSucessfully(imageApi().createFromDisk(IMAGE_NAME, diskURI.toString()), TIME_WAIT); } @Test(groups = "live", dependsOnMethods = "testCreateImageFromPD") @@ -97,7 +96,7 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testGetCreatedImage") public void testCleanup(){ assertGlobalOperationDoneSucessfully(imageApi().delete(IMAGE_NAME), TIME_WAIT); - assertZoneOperationDoneSuccessfully(diskApi().deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT); + assertZoneOperationDoneSuccessfully(diskApi().delete(DISK_NAME), TIME_WAIT); } private void assertImageEquals(Image result) {
