http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 1816b78..28c3657 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,7 +47,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/address_get.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject"); assertEquals(api.getInRegion("us-central1", "test-ip1"), new ParseAddressTest().expected()); @@ -64,7 +64,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject"); assertNull(api.getInRegion("us-central1", "test-ip1")); } @@ -84,7 +84,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertAddressResponse).getAddressApiForProject("myproject"); + insertAddressResponse).getAddressApi("myproject"); assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseOperationTest().expected()); } @@ -102,7 +102,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/region_operation.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject"); assertEquals(api.deleteInRegion("us-central1", "test-ip1"), new ParseOperationTest().expected()); @@ -120,7 +120,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject"); assertNull(api.deleteInRegion("us-central1", "test-ip1")); } @@ -138,7 +138,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/address_list.json")).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject"); assertEquals(api.listFirstPageInRegion("us-central1").toString(), new ParseAddressListTest().expected().toString()); @@ -156,7 +156,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject"); assertTrue(api.listInRegion("us-central1").concat().isEmpty()); }
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 c11d04e..94f2521 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 @@ -35,7 +35,7 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final int TIME_WAIT = 30; private AddressApi api() { - return api.getAddressApiForProject(userProject.get()); + return api.getAddressApi(userProject.get()); } @Test(groups = "live") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 83b716f..560f9e6 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,7 +53,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/disk_get.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject"); assertEquals(api.getInZone("us-central1-a", "testimage1"), new ParseDiskTest().expected()); @@ -70,7 +70,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject"); assertNull(api.getInZone("us-central1-a", "testimage1")); } @@ -90,7 +90,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApiForProject("myproject"); + insertDiskResponse).getDiskApi("myproject"); assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected()); } @@ -110,7 +110,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApiForProject("myproject"); + insertDiskResponse).getDiskApi("myproject"); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL)); assertEquals(api.createInZone("testimage1", 1, "us-central1-a", diskCreationOptions), new ParseOperationTest().expected()); @@ -131,7 +131,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertDiskResponse).getDiskApiForProject("myproject"); + insertDiskResponse).getDiskApi("myproject"); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL)); assertEquals(api.createInZone("testimage1", 1, @@ -154,7 +154,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createSnapshotRequest, - createSnapshotResponse).getDiskApiForProject("myproject"); + createSnapshotResponse).getDiskApi("myproject"); assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), new ParseOperationTest().expected()); } @@ -175,7 +175,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, createSnapshotRequest, - createSnapshotResponse).getDiskApiForProject("myproject"); + createSnapshotResponse).getDiskApi("myproject"); api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"); } @@ -193,7 +193,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/zone_operation.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject"); assertEquals(api.deleteInZone("us-central1-a", "testimage1"), new ParseOperationTest().expected()); @@ -211,7 +211,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject"); assertNull(api.deleteInZone("us-central1-a", "testimage1")); } @@ -229,7 +229,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/disk_list.json")).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject"); assertEquals(api.listFirstPageInZone("us-central1-a").toString(), new ParseDiskListTest().expected().toString()); @@ -247,7 +247,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject"); assertTrue(api.listInZone("us-central1-a").concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 2d0afb4..3db43fc 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 @@ -40,7 +40,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public static final int sizeGb = 1; private DiskApi api() { - return api.getDiskApiForProject(userProject.get()); + return api.getDiskApi(userProject.get()); } @Test(groups = "live") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java index 7a5759b..29e46db 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/FirewallApiExpectTest.java @@ -65,7 +65,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest public void testGetFirewallResponseIs2xx() throws Exception { FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApi("myproject"); assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected()); } @@ -112,7 +112,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getFirewallApi("myproject"); assertNull(api.get("jclouds-test")); } @@ -138,7 +138,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/operation.json")).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApi("myproject"); assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" + ".com/compute/v1/projects/myproject/global/networks/default"), @@ -174,7 +174,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, update, - updateFirewallResponse).getFirewallApiForProject("myproject"); + updateFirewallResponse).getFirewallApi("myproject"); assertEquals(api.update("myfw", new FirewallOptions() @@ -211,7 +211,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, update, - updateFirewallResponse).getFirewallApiForProject("myproject"); + updateFirewallResponse).getFirewallApi("myproject"); assertEquals(api.patch("myfw", new FirewallOptions() @@ -240,7 +240,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/operation.json")).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("myproject"); assertEquals(api.delete("default-allow-internal"), new ParseOperationTest().expected()); @@ -258,7 +258,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("myproject"); assertNull(api.delete("default-allow-internal")); } @@ -276,7 +276,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/firewall_list.json")).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject"); assertEquals(api.listFirstPage().toString(), new ParseFirewallListTest().expected().toString()); @@ -294,7 +294,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject"); assertTrue(api.list().concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 669046f..f390d9e 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 @@ -42,14 +42,14 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final int TIME_WAIT = 30; private FirewallApi api() { - return api.getFirewallApiForProject(userProject.get()); + return api.getFirewallApi(userProject.get()); } @Test(groups = "live") public void testInsertFirewall() { - // need to create the network first - assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range + // need to insert the network first + assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range (FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT); FirewallOptions firewall = new FirewallOptions() @@ -149,7 +149,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public void testDeleteFirewall() { assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT); - assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete + assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete (FIREWALL_NETWORK_NAME), TIME_WAIT); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java new file mode 100644 index 0000000..f3f1c71 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiExpectTest.java @@ -0,0 +1,167 @@ +/* + * 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.features; + +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; +import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest; +import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest; +import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +import javax.ws.rs.core.MediaType; + +import java.net.URI; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertNull; + +@Test(groups = "unit") +public class ForwardingRuleApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { + + public void testGetForwardingRuleResponseIs2xx() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis" + + ".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/forwardingrule_get.json")).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, get, operationResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertEquals(api.get("test-forwarding-rule"), + new ParseForwardingRuleTest().expected()); + } + + public void testGetForwardingRuleResponseIs4xx() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis" + + ".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, get, operationResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertNull(api.get("test-forwarding-rule")); + } + + public void testInsertForwardingRuleResponseIs2xx() { + HttpRequest insert = HttpRequest + .builder() + .method("POST") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN) + .payload(payloadFromResourceWithContentType("/forwardingrule_insert.json", MediaType.APPLICATION_JSON)) + .build(); + + HttpResponse insertForwardingRuleResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/region_operation.json")).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, insert, + insertForwardingRuleResponse).getForwardingRuleApi("myproject", "us-central1"); + assertEquals(api.create("test-forwarding-rule", + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1/" + + "targetPools/test-target-pool")), new ParseRegionOperationTest().expected()); + } + + public void testDeleteForwardingRuleResponseIs2xx() { + HttpRequest delete = HttpRequest + .builder() + .method("DELETE") + .endpoint("https://www.googleapis" + + ".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/region_operation.json")).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, delete, deleteResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertEquals(api.delete("test-forwarding-rule"), + new ParseRegionOperationTest().expected()); + } + + public void testDeleteForwardingRuleResponseIs4xx() { + HttpRequest delete = HttpRequest + .builder() + .method("DELETE") + .endpoint("https://www.googleapis" + + ".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-targetPool") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, delete, deleteResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertNull(api.delete("test-targetPool")); + } + + public void testListForwardingRulesResponseIs2xx() { + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/forwardingrule_list.json")).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertEquals(api.list().toString(), + new ParseForwardingRuleListTest().expected().toString()); + } + + public void testListForwardingRulesResponseIs4xx() { + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); + + ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1"); + + assertTrue(api.list().concat().isEmpty()); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 new file mode 100644 index 0000000..833d455 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/ForwardingRuleApiLiveTest.java @@ -0,0 +1,85 @@ +/* + * 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.features; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.domain.ForwardingRule; +import org.jclouds.googlecomputeengine.domain.TargetPool; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { + + private static final String FORWARDING_RULE_NAME = "forwarding-rule-api-live-test"; + private static final String TARGETPOOL_NAME = "forwarding-rule-api-live-test-targetpool"; + private static final int TIME_WAIT = 30; + private TargetPool targetPool; + + /** + * The API under test + * @return + */ + private ForwardingRuleApi api() { + return api.getForwardingRuleApi(userProject.get(), DEFAULT_REGION_NAME); + } + + private TargetPoolApi targetPoolApi() { + return api.getTargetPoolApi(userProject.get(), DEFAULT_REGION_NAME); + } + + @BeforeClass + public void init() { + assertRegionOperationDoneSucessfully(targetPoolApi().create(TARGETPOOL_NAME), TIME_WAIT); + targetPool = targetPoolApi().get(TARGETPOOL_NAME); + } + + @AfterClass + public void tearDown() { + assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME), TIME_WAIT); + } + + @Test(groups = "live") + public void testInsertForwardingRule() { + assertRegionOperationDoneSucessfully(api().create(FORWARDING_RULE_NAME, targetPool.getSelfLink()), TIME_WAIT); + } + + @Test(groups = "live", dependsOnMethods = "testInsertForwardingRule") + public void testGetForwardingRule() { + ForwardingRule forwardingRule = api().get(FORWARDING_RULE_NAME); + assertNotNull(forwardingRule); + assertEquals(forwardingRule.getName(), FORWARDING_RULE_NAME); + } + + @Test(groups = "live", dependsOnMethods = "testGetForwardingRule") + public void testListForwardingRule() { + + IterableWithMarker<ForwardingRule> forwardingRule = api().list(new ListOptions.Builder() + .filter("name eq " + FORWARDING_RULE_NAME)); + assertEquals(forwardingRule.toList().size(), 1); + } + + @Test(groups = "live", dependsOnMethods = "testListForwardingRule") + public void testDeleteForwardingRule() { + assertRegionOperationDoneSucessfully(api().delete(FORWARDING_RULE_NAME), TIME_WAIT); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 7fac1d7..bf4aa21 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 @@ -49,7 +49,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe public void testGetOperationResponseIs2xx() throws Exception { GlobalOperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApi("myproject"); assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"), new ParseOperationTest().expected()); @@ -60,7 +60,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApi("myproject"); assertNull(globalOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb")); } @@ -75,7 +75,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApi("myproject"); globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279"); } @@ -90,7 +90,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApi("myproject"); globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279"); } @@ -107,7 +107,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe .payload(payloadFromResource("/global_operation_list.json")).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject"); assertEquals(globalOperationApi.listFirstPage().toString(), new ParseOperationListTest().expected().toString()); @@ -130,7 +130,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe .payload(payloadFromResource("/global_operation_list.json")).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject"); assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" + "I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz", @@ -149,7 +149,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject"); assertTrue(globalOperationApi.list().concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 704df02..010fcac 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 @@ -41,13 +41,13 @@ public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe private Operation deleteOperation; private GlobalOperationApi api() { - return api.getGlobalOperationApiForProject(userProject.get()); + return api.getGlobalOperationApi(userProject.get()); } @Test(groups = "live") public void testCreateOperations() { - //create some operations by adding and deleting metadata items + //insert some operations by adding and deleting metadata items // this will make sure there is stuff to listFirstPage addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(), userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java new file mode 100644 index 0000000..906c685 --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiExpectTest.java @@ -0,0 +1,177 @@ +/* + * 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.features; + +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE; +import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.AssertJUnit.assertNull; + +import javax.ws.rs.core.MediaType; + +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; +import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckListTest; +import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckTest; +import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.testng.annotations.Test; + +@Test(groups = "unit") +public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { + + public void testGetHttpHealthCheckResponseIs2xx() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check-api-live-test") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/httphealthcheck_get.json")).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, get, operationResponse).getHttpHealthCheckApi("myproject"); + + assertEquals(api.get("http-health-check-api-live-test"), + new ParseHttpHealthCheckTest().expected()); + } + + public void testGetHttpHealthCheckResponseIs4xx() throws Exception { + HttpRequest get = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check-test") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, get, operationResponse).getHttpHealthCheckApi("myproject"); + + assertNull(api.get("http-health-check-test")); + } + + public void testInsertHttpHealthCheckResponseIs2xx() { + HttpRequest insert = HttpRequest + .builder() + .method("POST") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN) + .payload(payloadFromResourceWithContentType("/httphealthcheck_insert.json", MediaType.APPLICATION_JSON)) + .build(); + + HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/global_operation.json")).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, insert, + insertHttpHealthCheckResponse).getHttpHealthCheckApi("myproject"); + assertEquals(api.insert("http-health-check", 0, 0), new ParseRegionOperationTest().expected()); + } + + public void testInsertHttpHealthCheckResponseIs4xx() { + HttpRequest create = HttpRequest + .builder() + .method("POST") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN) + .payload(payloadFromResourceWithContentType("/httphealthcheck_insert.json", MediaType.APPLICATION_JSON)) + .build(); + + HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(404).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, create, insertHttpHealthCheckResponse).getHttpHealthCheckApi("myproject"); + + assertNull(api.insert("http-health-check", 0, 0)); + } + + public void testDeleteHttpHealthCheckResponseIs2xx() { + HttpRequest delete = HttpRequest + .builder() + .method("DELETE") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse deleteResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/global_operation.json")).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, delete, deleteResponse).getHttpHealthCheckApi("myproject"); + + assertEquals(api.delete("http-health-check"), + new ParseRegionOperationTest().expected()); + } + + public void testDeleteHttpHealthCheckResponseIs4xx() { + HttpRequest delete = HttpRequest + .builder() + .method("DELETE") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), + TOKEN_RESPONSE, delete, deleteResponse).getHttpHealthCheckApi("myproject"); + + assertNull(api.delete("http-health-check")); + } + + public void testListHttpHealthChecksResponseIs2xx() { + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/httphealthcheck_list.json")).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject"); + + assertEquals(api.list().toString(), + new ParseHttpHealthCheckListTest().expected().toString()); + } + + public void testListHttpHealthChecksResponseIs4xx() { + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); + + HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); + + HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), + TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject"); + + assertTrue(api.list().concat().isEmpty()); + } + +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 new file mode 100644 index 0000000..9adcd4d --- /dev/null +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/HttpHealthCheckApiLiveTest.java @@ -0,0 +1,60 @@ +/* + * 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.features; + +import org.jclouds.collect.IterableWithMarker; +import org.jclouds.googlecomputeengine.domain.HttpHealthCheck; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; +import org.jclouds.googlecomputeengine.options.ListOptions; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { + + private static final String HTTP_HEALTH_CHECK_NAME = "http-health-check-api-live-test"; + private static final int TIME_WAIT = 60; + + private HttpHealthCheckApi api() { + return api.getHttpHealthCheckApi(userProject.get()); + } + + @Test(groups = "live") + public void testInsertHttpHealthCheck() { + assertGlobalOperationDoneSucessfully(api().insert(HTTP_HEALTH_CHECK_NAME), TIME_WAIT); + } + + @Test(groups = "live", dependsOnMethods = "testInsertHttpHealthCheck") + public void testGetHttpHealthCheck() { + HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME); + assertNotNull(httpHealthCheck); + assertEquals(httpHealthCheck.getName(), HTTP_HEALTH_CHECK_NAME); + } + + @Test(groups = "live", dependsOnMethods = "testGetHttpHealthCheck") + public void testListHttpHealthCheck() { + IterableWithMarker<HttpHealthCheck> httpHealthCheck = api().list(new ListOptions.Builder() + .filter("name eq " + HTTP_HEALTH_CHECK_NAME)); + assertEquals(httpHealthCheck.toList().size(), 1); + } + + @Test(groups = "live", dependsOnMethods = "testListHttpHealthCheck") + public void testDeleteHttpHealthCheck() { + assertGlobalOperationDoneSucessfully(api().delete(HTTP_HEALTH_CHECK_NAME), TIME_WAIT); + } +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 0665e1b..c1781f1 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 @@ -79,7 +79,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/image_get.json")).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud"); + TOKEN_RESPONSE, get, operationResponse).getImageApi("centos-cloud"); assertEquals(imageApi.get("centos-6-2-v20120326"), new ParseImageTest().expected()); @@ -97,7 +97,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud"); + TOKEN_RESPONSE, get, operationResponse).getImageApi("centos-cloud"); assertNull(imageApi.get("centos-6-2-v20120326")); } @@ -115,7 +115,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/operation.json")).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getImageApi("myproject"); assertEquals(imageApi.delete("centos-6-2-v20120326"), new ParseOperationTest().expected()); @@ -133,7 +133,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getImageApi("myproject"); assertNull(imageApi.delete("centos-6-2-v20120326")); } @@ -141,7 +141,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { public void testListImagesResponseIs2xx() { ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApiForProject + TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApi ("myproject"); assertEquals(imageApi.listFirstPage().toString(), @@ -153,7 +153,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApiForProject("myproject"); + TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApi("myproject"); assertTrue(imageApi.list().concat().isEmpty()); } @@ -173,7 +173,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/operation.json")).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, createImage, createImageResponse).getImageApiForProject("myproject"); + TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject"); assertEquals(imageApi.createImageFromPD("my-image", "https://www.googleapis.com/" + "compute/v1/projects/myproject/zones/us-central1-a/disks/mydisk"), @@ -195,7 +195,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse createImageResponse = HttpResponse.builder().statusCode(404).build(); ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, createImage, createImageResponse).getImageApiForProject("myproject"); + TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject"); imageApi.createImageFromPD("my-image", "https://www.googleapis.com/" + "compute/v1/projects/myproject/zones/us-central1-a/disks/mydisk"); http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/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 9c9ca55..c8a8cd7 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 @@ -47,15 +47,15 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private URI diskURI; private ImageApi api() { - return api.getImageApiForProject("centos-cloud"); + return api.getImageApi("centos-cloud"); } private ImageApi imageApi(){ - return api.getImageApiForProject(userProject.get()); + return api.getImageApi(userProject.get()); } private DiskApi diskApi() { - return api.getDiskApiForProject(userProject.get()); + return api.getDiskApi(userProject.get()); } @Test(groups = "live") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java index bb681c7..4e66f85 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiExpectTest.java @@ -92,7 +92,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest InstanceApi api = requestsSendResponses( requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, - GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApiForProject("myproject"); + GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApi("myproject"); assertEquals(api.getInZone("us-central1-a", "test-1"), new ParseInstanceTest().expected()); } @@ -102,7 +102,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApi("myproject"); assertNull(api.getInZone("us-central1-a", "test-1")); } @@ -121,7 +121,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getInstanceApi("myproject"); assertEquals(api.getSerialPortOutputInZone("us-central1-a", "test-1"), new ParseInstanceSerialOutputTest().expected()); } @@ -140,7 +140,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE, requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject"); + CREATE_INSTANCE_RESPONSE)).getInstanceApi("myproject"); InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1") .addNetworkInterface(URI.create("https://www.googleapis" + @@ -165,7 +165,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE, requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApi("myproject"); InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1") .addNetworkInterface(URI.create("https://www.googleapis" + @@ -194,7 +194,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getInstanceApi("myproject"); assertEquals(api.deleteInZone("us-central1-a", "test-1"), new ParseOperationTest().expected()); @@ -212,7 +212,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getInstanceApi("myproject"); assertNull(api.deleteInZone("us-central1-a", "test-1")); } @@ -221,7 +221,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest InstanceApi api = requestsSendResponses( requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE, - LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApiForProject("myproject"); + LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApi("myproject"); assertEquals(api.listFirstPageInZone("us-central1-a").toString(), new ParseInstanceListTest().expected().toString()); @@ -239,7 +239,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getInstanceApi("myproject"); assertTrue(api.listInZone("us-central1-a").concat().isEmpty()); } @@ -259,7 +259,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApi("myproject"); assertEquals(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"), new ParseOperationTest().expected()); @@ -280,7 +280,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApi("myproject"); api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"); } @@ -300,7 +300,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApi("myproject"); assertEquals(api.setTagsInZone("us-central1-a", "test-1", ImmutableSet.of("foo", "bar"), "efgh"), new ParseOperationTest().expected()); @@ -321,7 +321,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse setTagsResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApi("myproject"); api.setTagsInZone("us-central1-a", "test-1", ImmutableSet.of("foo", "bar"), "efgh"); } @@ -339,7 +339,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, reset, resetResponse).getInstanceApi("myproject"); assertEquals(api.resetInZone("us-central1-a", "test-1"), new ParseOperationTest().expected()); @@ -358,7 +358,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse resetResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, reset, resetResponse).getInstanceApi("myproject"); api.resetInZone("us-central1-a", "test-1"); } @@ -378,7 +378,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, attach, attachResponse).getInstanceApi("myproject"); assertEquals(api.attachDiskInZone("us-central1-a", "test-1", new AttachDiskOptions() @@ -403,7 +403,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse attachResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, attach, attachResponse).getInstanceApi("myproject"); api.attachDiskInZone("us-central1-a", "test-1", new AttachDiskOptions() @@ -428,7 +428,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest .payload(payloadFromResource("/zone_operation.json")).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, detach, detachResponse).getInstanceApi("myproject"); assertEquals(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"), new ParseOperationTest().expected()); @@ -449,7 +449,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest HttpResponse detachResponse = HttpResponse.builder().statusCode(404).build(); InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject"); + TOKEN_RESPONSE, detach, detachResponse).getInstanceApi("myproject"); api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java index dd3981e..13af8f2 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/InstanceApiLiveTest.java @@ -70,7 +70,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Override protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) { GoogleComputeEngineApi api = super.create(props, modules); - URI imageUri = api.getImageApiForProject("centos-cloud") + URI imageUri = api.getImageApi("centos-cloud") .list(new ListOptions.Builder().filter("name eq centos.*")) .concat() .filter(new Predicate<Image>() { @@ -98,22 +98,22 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { } private InstanceApi api() { - return api.getInstanceApiForProject(userProject.get()); + return api.getInstanceApi(userProject.get()); } private DiskApi diskApi() { - return api.getDiskApiForProject(userProject.get()); + return api.getDiskApi(userProject.get()); } @Test(groups = "live") public void testInsertInstance() { - // need to create the network first - assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range + // need to insert the network first + assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range (INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT); DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instance.getImage()); - assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()) + assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()) .createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions), TIME_WAIT); @@ -225,11 +225,11 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public void testDeleteInstance() { assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT); - assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), + assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT); - assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), + assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), TIME_WAIT); - assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete + assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete (INSTANCE_NETWORK_NAME), TIME_WAIT); } @@ -242,11 +242,11 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { protected void tearDownContext() { try { waitZoneOperationDone(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT); - waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), + waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME), TIME_WAIT); - waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), + waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME), TIME_WAIT); - waitGlobalOperationDone(api.getNetworkApiForProject(userProject.get()).delete + waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete (INSTANCE_NETWORK_NAME), TIME_WAIT); } catch (Exception e) { // we don't really care about any exception here, so just delete away. http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java index 35dec08..31bfdea 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiExpectTest.java @@ -68,7 +68,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe .payload(payloadFromResource("/machinetype.json")).build(); MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject"); assertEquals(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"), new ParseMachineTypeTest().expected()); @@ -86,7 +86,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject"); assertNull(machineTypeApi.getInZone("us-central1-a", "n1-standard-1")); } @@ -94,7 +94,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe public void testListMachineTypeNoOptionsResponseIs2xx() throws Exception { MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApiForProject + TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApi ("myproject"); assertEquals(machineTypeApi.listFirstPageInZone("us-central1-a").toString(), @@ -106,7 +106,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApiForProject("myproject"); + TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApi("myproject"); assertTrue(machineTypeApi.listInZone("us-central1-a").concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java index d9d00a1..2e43eab 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/MachineTypeApiLiveTest.java @@ -39,7 +39,7 @@ public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private MachineType machineType; private MachineTypeApi api() { - return api.getMachineTypeApiForProject(userProject.get()); + return api.getMachineTypeApi(userProject.get()); } @Test(groups = "live") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java index 1b2d73b..69852f1 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiExpectTest.java @@ -48,7 +48,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { public void testGetNetworkResponseIs2xx() throws Exception { NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApi("myproject"); assertEquals(api.get("jclouds-test"), new ParseNetworkTest().expected()); @@ -65,7 +65,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, get, operationResponse).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, get, operationResponse).getNetworkApi("myproject"); assertNull(api.get("jclouds-test")); } @@ -85,7 +85,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), TOKEN_RESPONSE, insert, - insertNetworkResponse).getNetworkApiForProject("myproject"); + insertNetworkResponse).getNetworkApi("myproject"); assertEquals(api.createInIPv4Range("test-network", "10.0.0.0/8"), new ParseOperationTest().expected()); } @@ -103,7 +103,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/operation.json")).build(); NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getNetworkApi("myproject"); assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected()); @@ -121,7 +121,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build(); NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, delete, deleteResponse).getNetworkApi("myproject"); assertNull(api.delete("jclouds-test")); } @@ -139,7 +139,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/network_list.json")).build(); NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject"); assertEquals(api.listFirstPage().toString(), new ParseNetworkListTest().expected().toString()); @@ -157,7 +157,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject"); + TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject"); assertTrue(api.list().concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java index 208ec1b..94d1fc5 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/NetworkApiLiveTest.java @@ -38,7 +38,7 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private static final int TIME_WAIT = 10; private NetworkApi api() { - return api.getNetworkApiForProject(userProject.get()); + return api.getNetworkApi(userProject.get()); } @Test(groups = "live") http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java index f4e32cb..548c704 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiExpectTest.java @@ -57,7 +57,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { .payload(payloadFromResource("/region_get.json")).build(); RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject"); + TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApi("myproject"); assertEquals(api.get("us-central1"), new ParseRegionTest().expected()); @@ -68,7 +68,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject"); + TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApi("myproject"); assertNull(api.get("us-central1")); } @@ -76,7 +76,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { public void testListRegionNoOptionsResponseIs2xx() throws Exception { RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApiForProject("myproject"); + TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApi("myproject"); assertEquals(api.listFirstPage().toString(), new ParseRegionListTest().expected().toString()); @@ -87,7 +87,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build(); RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApiForProject("myproject"); + TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApi("myproject"); assertTrue(api.list().concat().isEmpty()); } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/ed9fc5c5/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java index 6558f36..73d237c 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/RegionApiLiveTest.java @@ -39,7 +39,7 @@ public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { private Region region; private RegionApi api() { - return api.getRegionApiForProject(userProject.get()); + return api.getRegionApi(userProject.get()); } @Test(groups = "live")
