http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java index b40d0fc..9984b20 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiExpectTest.java @@ -16,17 +16,16 @@ */ 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.Assert.assertFalse; import static org.testng.AssertJUnit.assertNull; import java.net.URI; import javax.ws.rs.core.MediaType; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest; import org.jclouds.googlecomputeengine.parse.ParseOperationTest; import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyListTest; import org.jclouds.googlecomputeengine.parse.ParseTargetHttpProxyTest; @@ -35,16 +34,16 @@ import org.jclouds.http.HttpResponse; import org.testng.annotations.Test; @Test(groups = "unit") -public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { - +public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> { + private static final String ENDPOINT_BASE = "https://www.googleapis.com/" - + "compute/v1/projects/myproject/global/targetHttpProxies"; - + + "compute/v1/projects/party/global/targetHttpProxies"; + private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() { return HttpRequest.builder().addHeader("Accept", "application/json") .addHeader("Authorization", "Bearer " + TOKEN); } - + private HttpResponse createResponse(String payloadFile) { return HttpResponse.builder().statusCode(200) .payload(payloadFromResource(payloadFile)) @@ -58,7 +57,7 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = createResponse("/target_http_proxy_get.json"); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); assertEquals(api.get("jclouds-test"), new ParseTargetHttpProxyTest().expected()); @@ -71,12 +70,12 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = HttpResponse.builder().statusCode(404).build(); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); assertNull(api.get("jclouds-test")); } - + public void testInsertTargetHttpProxyResponseIs2xx() { HttpRequest request = getBasicRequest().method("POST") @@ -88,7 +87,7 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = createResponse("/operation.json"); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); URI urlMap = URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"); assertEquals(api.create("jclouds-test", urlMap), new ParseOperationTest().expected()); @@ -102,7 +101,7 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = createResponse("/operation.json"); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected()); @@ -116,15 +115,15 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = HttpResponse.builder().statusCode(404).build(); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); assertNull(api.delete("jclouds-test")); } - + public void testSetUrlMapTargetHttpProxyResponseIs2xx() { HttpRequest request = getBasicRequest().method("POST") // setUrlMap uses a non-standard url pattern - .endpoint("https://www.googleapis.com/compute/v1/projects/myproject/targetHttpProxies" + .endpoint("https://www.googleapis.com/compute/v1/projects/party/targetHttpProxies" + "/jclouds-test/setUrlMap") .payload(payloadFromResourceWithContentType("/target_http_proxy_set_url_map.json", MediaType.APPLICATION_JSON)) @@ -133,7 +132,7 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = createResponse("/operation.json"); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); URI urlMap = URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test"); assertEquals(api.setUrlMap("jclouds-test", urlMap), new ParseOperationTest().expected()); @@ -147,22 +146,26 @@ public class TargetHttpProxyApiExpectTest extends BaseGoogleComputeEngineApiExpe HttpResponse response = createResponse("/target_http_proxy_list.json"); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, request, response).targetHttpProxies(); - assertEquals(api.listFirstPage().toString(), - new ParseTargetHttpProxyListTest().expected().toString()); + assertEquals(api.list().next(), + new ParseTargetHttpProxyListTest().expected()); } - public void testListTargetHttpProxiesResponseIs4xx() { - HttpRequest request = getBasicRequest().method("GET") - .endpoint(ENDPOINT_BASE) - .build(); + public void listEmpty() { + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint(BASE_URL + "/party/global/targetHttpProxies") + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); - HttpResponse response = HttpResponse.builder().statusCode(404).build(); + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/list_empty.json")).build(); TargetHttpProxyApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getTargetHttpProxyApiForProject("myproject"); + TOKEN_RESPONSE, list, response).targetHttpProxies(); - assertTrue(api.list().concat().isEmpty()); + assertFalse(api.list().hasNext()); } }
http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java index a82cbae..2a4e517 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/TargetHttpProxyApiLiveTest.java @@ -16,111 +16,102 @@ */ 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; import java.net.URI; -import java.util.HashSet; import java.util.List; -import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.domain.TargetHttpProxy; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.BackendServiceOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.googlecomputeengine.options.UrlMapOptions; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; public class TargetHttpProxyApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public static final String TARGET_HTTP_PROXY_NAME = "target-http-proxy-api-live-test-target-http-proxy"; public static final String TARGET_HTTP_PROXY_URL_MAP_NAME = "target-http-proxy-api-live-test-url-map"; public static final String URL_MAP_DEFAULT_SERVICE_NAME = "target-http-proxy-api-live-test-backend-service"; - public static final String HEALTH_CHECK_NAME = "backend-service-api-live-test-health-check"; - public static final int TIME_WAIT = 30; + public static final String HEALTH_CHECK_NAME = "target-http-proxy-api-live-test-health-check"; private TargetHttpProxyApi api() { - return api.getTargetHttpProxyApiForProject(userProject.get()); + return api.targetHttpProxies(); } @Test(groups = "live") public void testInsertTargetHttpProxy() { - String project = userProject.get(); + // Create resources that are required for target http proxies - // TODO: (ashmrtnz) create health check once it is merged into project - HashSet<URI> healthChecks = new HashSet<URI>(); - healthChecks.add(getHealthCheckUrl(userProject.get(), HEALTH_CHECK_NAME)); + + assertOperationDoneSuccessfully(api.httpHeathChecks().insert(HEALTH_CHECK_NAME)); + + List<URI> healthChecks = ImmutableList.of(getHealthCheckUrl(HEALTH_CHECK_NAME)); BackendServiceOptions b = new BackendServiceOptions().name(URL_MAP_DEFAULT_SERVICE_NAME) .healthChecks(healthChecks); - assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(userProject.get()) - .create(URL_MAP_DEFAULT_SERVICE_NAME, b), TIME_WAIT); - + + assertOperationDoneSuccessfully(api.backendServices().create(b)); + UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map") - .defaultService(getBackendServiceUrl(project, - URL_MAP_DEFAULT_SERVICE_NAME)); - assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(project).create(TARGET_HTTP_PROXY_URL_MAP_NAME, - map), TIME_WAIT); - - assertGlobalOperationDoneSucessfully(api().create(TARGET_HTTP_PROXY_NAME, - getUrlMapUrl(project, TARGET_HTTP_PROXY_URL_MAP_NAME)), - TIME_WAIT); + .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)); + assertOperationDoneSuccessfully(api.urlMaps().create(map)); + + UrlMapOptions map2 = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2").description("a second simple url map") + .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)); + assertOperationDoneSuccessfully(api.urlMaps().create(map2)); + + + assertOperationDoneSuccessfully(api().create(TARGET_HTTP_PROXY_NAME, getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME))); } @Test(groups = "live", dependsOnMethods = "testInsertTargetHttpProxy") public void testGetTargetHttpProxy() { TargetHttpProxy targetHttpProxy = api().get(TARGET_HTTP_PROXY_NAME); assertNotNull(targetHttpProxy); - assertTargetHttpProxyEquals(targetHttpProxy, getUrlMapUrl(userProject.get(), TARGET_HTTP_PROXY_URL_MAP_NAME)); + assertTargetHttpProxyEquals(targetHttpProxy, getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME)); } - + @Test(groups = "live", dependsOnMethods = "testGetTargetHttpProxy") public void testSetUrlMapTargetHttpProxy() { UrlMapOptions map = new UrlMapOptions().name(TARGET_HTTP_PROXY_URL_MAP_NAME).description("simple url map") - .defaultService(getBackendServiceUrl(userProject.get(), - URL_MAP_DEFAULT_SERVICE_NAME)); - assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(userProject.get()) - .create(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2", map), TIME_WAIT); - - assertGlobalOperationDoneSucessfully(api().setUrlMap(TARGET_HTTP_PROXY_NAME, - getUrlMapUrl(userProject.get(), - TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")), - TIME_WAIT); + .defaultService(getBackendServiceUrl(URL_MAP_DEFAULT_SERVICE_NAME)); + assertOperationDoneSuccessfully(api.urlMaps() + .create(map)); + + assertOperationDoneSuccessfully(api().setUrlMap(TARGET_HTTP_PROXY_NAME, + getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"))); } @Test(groups = "live", dependsOnMethods = "testSetUrlMapTargetHttpProxy") public void testListTargetHttpProxy() { - PagedIterable<TargetHttpProxy> disks = api().list(new ListOptions.Builder() - .filter("name eq " + TARGET_HTTP_PROXY_NAME)); - - List<TargetHttpProxy> targetHttpProxiesAsList = Lists.newArrayList(disks.concat()); + ListPage<TargetHttpProxy> targetHttpProxies = api().list(filter("name eq " + TARGET_HTTP_PROXY_NAME)).next(); - assertEquals(targetHttpProxiesAsList.size(), 1); - - assertTargetHttpProxyEquals(Iterables.getOnlyElement(targetHttpProxiesAsList), - getUrlMapUrl(userProject.get(), TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")); + assertEquals(targetHttpProxies.size(), 1); + assertTargetHttpProxyEquals(Iterables.getOnlyElement(targetHttpProxies), + getUrlMapUrl(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")); } @Test(groups = "live", dependsOnMethods = "testListTargetHttpProxy") public void testDeleteTargetHttpProxy() { - assertGlobalOperationDoneSucessfully(api().delete(TARGET_HTTP_PROXY_NAME), TIME_WAIT); - + assertOperationDoneSuccessfully(api().delete(TARGET_HTTP_PROXY_NAME)); + //remove extra resources created - assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(userProject.get()) - .delete(TARGET_HTTP_PROXY_URL_MAP_NAME), TIME_WAIT); - assertGlobalOperationDoneSucessfully(api.getUrlMapApiForProject(userProject.get()) - .delete(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2"), TIME_WAIT); - assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(userProject.get()) - .delete(URL_MAP_DEFAULT_SERVICE_NAME), TIME_WAIT); - // TODO: delete health check once it is merged + assertOperationDoneSuccessfully(api.urlMaps().delete(TARGET_HTTP_PROXY_URL_MAP_NAME)); + assertOperationDoneSuccessfully(api.urlMaps().delete(TARGET_HTTP_PROXY_URL_MAP_NAME + "-2")); + assertOperationDoneSuccessfully(api.backendServices().delete(URL_MAP_DEFAULT_SERVICE_NAME)); + assertOperationDoneSuccessfully(api.httpHeathChecks().delete(HEALTH_CHECK_NAME)); + } private void assertTargetHttpProxyEquals(TargetHttpProxy result, URI urlMap) { - assertEquals(result.getName(), TARGET_HTTP_PROXY_NAME); - assertEquals(result.getUrlMap(), urlMap); + assertEquals(result.name(), TARGET_HTTP_PROXY_NAME); + assertEquals(result.urlMap(), urlMap); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java index 15e9583..e13dbf3 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiExpectTest.java @@ -16,10 +16,8 @@ */ 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.Assert.assertFalse; import static org.testng.AssertJUnit.assertNull; import java.io.IOException; @@ -27,11 +25,12 @@ import java.net.URI; import javax.ws.rs.core.MediaType; +import org.jclouds.googlecomputeengine.GoogleComputeEngineApi; import org.jclouds.googlecomputeengine.domain.UrlMap; import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule; import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher; -import org.jclouds.googlecomputeengine.domain.UrlMap.PathRule; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest; +import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher.PathRule; +import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineExpectTest; import org.jclouds.googlecomputeengine.options.UrlMapOptions; import org.jclouds.googlecomputeengine.parse.ParseOperationTest; import org.jclouds.googlecomputeengine.parse.ParseUrlMapListTest; @@ -41,17 +40,19 @@ import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; import org.testng.annotations.Test; +import com.google.common.collect.ImmutableList; + @Test(groups = "unit") -public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { +public class UrlMapApiExpectTest extends BaseGoogleComputeEngineExpectTest<GoogleComputeEngineApi> { private static final String ENDPOINT_BASE = "https://www.googleapis.com/" - + "compute/v1/projects/myproject/global/urlMaps"; - + + "compute/v1/projects/party/global/urlMaps"; + private org.jclouds.http.HttpRequest.Builder<? extends HttpRequest.Builder<?>> getBasicRequest() { return HttpRequest.builder().addHeader("Accept", "application/json") .addHeader("Authorization", "Bearer " + TOKEN); } - + private HttpResponse createResponse(String payloadFile) { return HttpResponse.builder().statusCode(200) .payload(payloadFromResource(payloadFile)) @@ -62,11 +63,11 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpRequest request = getBasicRequest().method("GET") .endpoint(ENDPOINT_BASE + "/jclouds-test") .build(); - + HttpResponse response = createResponse("/url_map_get.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertEquals(api.get("jclouds-test"), new ParseUrlMapTest().expected()); } @@ -79,7 +80,7 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = HttpResponse.builder().statusCode(404).build(); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertNull(api.get("jclouds-test")); } @@ -93,9 +94,9 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = createResponse("/operation.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); - - assertEquals(api.create("jclouds-test", createBasicMap()), new ParseOperationTest().expected()); + TOKEN_RESPONSE, request, response).urlMaps(); + + assertEquals(api.create(createBasicMap()), new ParseOperationTest().expected()); } @@ -108,8 +109,8 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = createResponse("/operation.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); - + TOKEN_RESPONSE, request, response).urlMaps(); + assertEquals(api.update("jclouds-test", createBasicMap()), new ParseOperationTest().expected()); } @@ -122,7 +123,7 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = createResponse("/operation.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertEquals(api.patch("jclouds-test", createBasicMap()), new ParseOperationTest().expected()); } @@ -135,7 +136,7 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = createResponse("/operation.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertEquals(api.delete("jclouds-test"), new ParseOperationTest().expected()); } @@ -148,38 +149,38 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = HttpResponse.builder().statusCode(404).build(); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertNull(api.delete("jclouds-test")); } - public void testListUrlMapsResponseIs2xx() { - HttpRequest request = getBasicRequest().method("GET") - .endpoint(ENDPOINT_BASE) - .build(); + HttpRequest list = HttpRequest + .builder() + .method("GET") + .endpoint(ENDPOINT_BASE) + .addHeader("Accept", "application/json") + .addHeader("Authorization", "Bearer " + TOKEN).build(); - HttpResponse response = createResponse("/url_map_list.json"); + public void list() { + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/url_map_list.json")).build(); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, list, response).urlMaps(); - assertEquals(api.listFirstPage().toString(), - new ParseUrlMapListTest().expected().toString()); + assertEquals(api.list().next(), new ParseUrlMapListTest().expected()); } - public void testListUrlMapsResponseIs4xx() { - HttpRequest request = getBasicRequest().method("GET") - .endpoint(ENDPOINT_BASE) - .build(); - - HttpResponse response = HttpResponse.builder().statusCode(404).build(); + public void listEmpty() { + HttpResponse response = HttpResponse.builder().statusCode(200) + .payload(payloadFromResource("/list_empty.json")).build(); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, list, response).urlMaps(); - assertTrue(api.list().concat().isEmpty()); + assertFalse(api.list().hasNext()); } - + public void testValidateUrlMapsResponseIs2xx() { HttpRequest request = getBasicRequest().method("POST") .endpoint(ENDPOINT_BASE + "/jclouds-test/validate") @@ -190,31 +191,24 @@ public class UrlMapApiExpectTest extends BaseGoogleComputeEngineApiExpectTest { HttpResponse response = createResponse("/url_map_validate.json"); UrlMapApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE), - TOKEN_RESPONSE, request, response).getUrlMapApiForProject("myproject"); + TOKEN_RESPONSE, request, response).urlMaps(); assertEquals(api.validate("jclouds-test", createBasicMap()), new ParseUrlMapValidateTest().expected()); } - + private UrlMapOptions createBasicMap() { URI service = URI.create("https://www.googleapis.com/compute/v1/projects/" + "myproject/global/backendServices/jclouds-test"); return new UrlMapOptions().name("jclouds-test") .description("Sample url map") - .addHostRule(HostRule.builder().addHost("jclouds-test") - .pathMatcher("path") - .build()) - .addPathMatcher(PathMatcher.builder() - .name("path") - .defaultService(service) - .addPathRule(PathRule.builder() - .addPath("/") - .service(service) - .build()) - .build()) - .addTest(UrlMap.UrlMapTest.builder().host("jclouds-test") - .path("/test/path") - .service(service) - .build()) + .hostRule(HostRule.create(null, ImmutableList.of("jclouds-test"), "path")) + .pathMatcher(PathMatcher.create("path", + null, + service, + ImmutableList.of( + PathRule.create(ImmutableList.of("/"), + service)))) + .test(UrlMap.UrlMapTest.create(null, "jclouds-test", "/test/path", service)) .defaultService(service); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java index cf44677..f47d96e 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/features/UrlMapApiLiveTest.java @@ -16,55 +16,52 @@ */ 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; import java.net.URI; -import java.util.HashSet; import java.util.List; -import org.jclouds.collect.PagedIterable; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.domain.UrlMap; import org.jclouds.googlecomputeengine.domain.UrlMap.HostRule; import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher; -import org.jclouds.googlecomputeengine.domain.UrlMap.PathRule; +import org.jclouds.googlecomputeengine.domain.UrlMap.PathMatcher.PathRule; +import org.jclouds.googlecomputeengine.domain.UrlMap.UrlMapTest; import org.jclouds.googlecomputeengine.domain.UrlMapValidateResult; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest; import org.jclouds.googlecomputeengine.options.BackendServiceOptions; -import org.jclouds.googlecomputeengine.options.ListOptions; import org.jclouds.googlecomputeengine.options.UrlMapOptions; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { public static final String URL_MAP_NAME = "url-map-api-live-test-url-map"; public static final String URL_MAP_BACKEND_SERVICE_NAME = "url-map-api-live-test-backend-service"; - public static final String HEALTH_CHECK_NAME = "backend-service-api-live-test-health-check"; - public static final int TIME_WAIT = 30; + public static final String HEALTH_CHECK_NAME = "url-map-api-live-test-health-check"; private UrlMapApi api() { - return api.getUrlMapApiForProject(userProject.get()); + return api.urlMaps(); } @Test(groups = "live") public void testInsertUrlMap() { // Create extra resources needed for url maps - // TODO: (ashmrtnz) create health check once it is merged into project - HashSet<URI> healthChecks = new HashSet<URI>(); - healthChecks.add(getHealthCheckUrl(userProject.get(), HEALTH_CHECK_NAME)); + assertOperationDoneSuccessfully(api.httpHeathChecks().insert(HEALTH_CHECK_NAME)); + + List<URI> healthChecks = ImmutableList.of(getHealthCheckUrl(HEALTH_CHECK_NAME)); BackendServiceOptions b = new BackendServiceOptions().name(URL_MAP_BACKEND_SERVICE_NAME) .healthChecks(healthChecks); - assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(userProject.get()) - .create(URL_MAP_BACKEND_SERVICE_NAME, b), TIME_WAIT); - + assertOperationDoneSuccessfully(api.backendServices().create(b)); + UrlMapOptions map = new UrlMapOptions().name(URL_MAP_NAME).description("simple url map") - .defaultService(getBackendServiceUrl(userProject.get(), - URL_MAP_BACKEND_SERVICE_NAME)); - assertGlobalOperationDoneSucessfully(api().create(URL_MAP_NAME, map), TIME_WAIT); + .defaultService(getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME)); + + assertOperationDoneSuccessfully(api().create(map)); } @@ -79,137 +76,129 @@ public class UrlMapApiLiveTest extends BaseGoogleComputeEngineApiLiveTest { @Test(groups = "live", dependsOnMethods = "testGetUrlMap") public void testListUrlMap() { - PagedIterable<UrlMap> urlMaps = api().list(new ListOptions.Builder() - .filter("name eq " + URL_MAP_NAME)); - - List<UrlMap> urlMapsAsList = Lists.newArrayList(urlMaps.concat()); + ListPage<UrlMap> urlMaps = api().list(filter("name eq " + URL_MAP_NAME)).next(); - assertEquals(urlMapsAsList.size(), 1); + assertEquals(urlMaps.size(), 1); - assertUrlMapEquals(Iterables.getOnlyElement(urlMapsAsList)); + assertUrlMapEquals(Iterables.getOnlyElement(urlMaps)); } - + @Test(groups = "live", dependsOnMethods = "testGetUrlMap") public void testUpdateUrlMap() { - String fingerprint = api().get(URL_MAP_NAME).getFingerprint().get(); - URI service = getBackendServiceUrl(userProject.get(), URL_MAP_BACKEND_SERVICE_NAME); - ImmutableSet<String> path = ImmutableSet.<String>of("/"); - PathRule rule = PathRule.builder().service(service).paths(path).build(); - ImmutableSet<PathRule> rules = ImmutableSet.<PathRule>of(rule); - ImmutableSet<PathMatcher> matchers = ImmutableSet.<PathMatcher>of(PathMatcher.builder().defaultService(service) - .name("path") - .pathRules(rules) - .build()); - ImmutableSet<String> hosts = ImmutableSet.<String>of("jclouds-test"); - ImmutableSet<HostRule> hostRules = ImmutableSet.<HostRule>of(HostRule.builder().hosts(hosts) - .pathMatcher("path") - .build()); + String fingerprint = api().get(URL_MAP_NAME).fingerprint(); + + URI service = getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME); + + ImmutableList<String> paths = ImmutableList.<String>of("/"); + + PathRule rule = PathRule.create(paths, service); + + ImmutableList<PathRule> rules = ImmutableList.<PathRule>of(rule); + + ImmutableList<PathMatcher> matchers = ImmutableList.<PathMatcher>of(PathMatcher.create("test-path-matcher", "", service, rules)); + + ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test"); + ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher")); UrlMapOptions options = new UrlMapOptions().name(URL_MAP_NAME) .pathMatchers(matchers) .hostRules(hostRules) .defaultService(service) .fingerprint(fingerprint); - assertGlobalOperationDoneSucessfully(api().update(URL_MAP_NAME, options), TIME_WAIT); - + + assertOperationDoneSuccessfully(api().update(URL_MAP_NAME, options)); + assertUrlMapEquals(api().get(URL_MAP_NAME), options); } - + @Test(groups = "live", dependsOnMethods = "testUpdateUrlMap") public void testPatchUrlMap() { - String fingerprint = api().get(URL_MAP_NAME).getFingerprint().get(); - URI service = getBackendServiceUrl(userProject.get(), URL_MAP_BACKEND_SERVICE_NAME); - ImmutableSet<UrlMap.UrlMapTest> urlMapTests = ImmutableSet.<UrlMap.UrlMapTest>of(UrlMap.UrlMapTest.builder() - .host("jclouds-test") - .path("/test/path") - .service(service) - .build()); + String fingerprint = api().get(URL_MAP_NAME).fingerprint(); + URI service = getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME); + + UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service); + ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest); + UrlMapOptions options = new UrlMapOptions().urlMapTests(urlMapTests) .fingerprint(fingerprint); - assertGlobalOperationDoneSucessfully(api().patch(URL_MAP_NAME, options), TIME_WAIT); - + assertOperationDoneSuccessfully(api().patch(URL_MAP_NAME, options)); + // Update options with settings it should have for later assertions. - ImmutableSet<String> path = ImmutableSet.<String>of("/"); - PathRule rule = PathRule.builder().service(service).paths(path).build(); - ImmutableSet<PathRule> rules = ImmutableSet.<PathRule>of(rule); - ImmutableSet<PathMatcher> matchers = ImmutableSet.<PathMatcher>of(PathMatcher.builder().defaultService(service) - .name("path") - .pathRules(rules) - .build()); - ImmutableSet<String> hosts = ImmutableSet.<String>of("jclouds-test"); - ImmutableSet<HostRule> hostRules = ImmutableSet.<HostRule>of(HostRule.builder().hosts(hosts) - .pathMatcher("path") - .build()); + ImmutableList<String> paths = ImmutableList.<String>of("/"); + PathRule rule = PathRule.create(paths, service); + + ImmutableList<PathRule> rules = ImmutableList.<PathRule>of(rule); + ImmutableList<PathMatcher> matchers = ImmutableList.<PathMatcher>of(PathMatcher.create("test-path-matcher", "", service, rules)); + + ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test"); + ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher")); options.name(URL_MAP_NAME) .description("simple url map") .pathMatchers(matchers) .hostRules(hostRules) .defaultService(service); + assertUrlMapEquals(api().get(URL_MAP_NAME), options); } - + @Test(groups = "live", dependsOnMethods = "testPatchUrlMap") public void testValidateUrlMap() { UrlMapValidateResult results = api().validate(URL_MAP_NAME, api().get(URL_MAP_NAME)); - UrlMapValidateResult expected = UrlMapValidateResult.builder().testPassed(true).loadSucceeded(true).build(); + UrlMapValidateResult expected = UrlMapValidateResult.allPass(); assertEquals(results, expected); } - + @Test(groups = "live", dependsOnMethods = "testPatchUrlMap") public void testValidateUrlMapWithOptions() { + URI service = getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME); + ImmutableList<String> paths = ImmutableList.<String>of("/"); + PathRule rule = PathRule.create(paths, service); + ImmutableList<PathRule> rules = ImmutableList.<PathRule>of(rule); + + ImmutableList<PathMatcher> matchers = ImmutableList.<PathMatcher>of(PathMatcher.create("test-path-matcher", "", service, rules)); + + ImmutableList<String> hosts = ImmutableList.<String>of("jclouds-test"); + + ImmutableList<HostRule> hostRules = ImmutableList.<HostRule>of(HostRule.create("", hosts, "test-path-matcher")); + UrlMapTest urlMapTest = UrlMapTest.create(null, "jclouds-test", "/test/path", service); + ImmutableList<UrlMap.UrlMapTest> urlMapTests = ImmutableList.<UrlMap.UrlMapTest>of(urlMapTest); + UrlMapOptions options = new UrlMapOptions(); - - URI service = getBackendServiceUrl(userProject.get(), URL_MAP_BACKEND_SERVICE_NAME); - ImmutableSet<UrlMap.UrlMapTest> urlMapTests = ImmutableSet.<UrlMap.UrlMapTest>of(UrlMap.UrlMapTest.builder() - .host("jclouds-test") - .path("/test/path") - .service(service) - .build()); - ImmutableSet<String> path = ImmutableSet.<String>of("/"); - PathRule rule = PathRule.builder().service(service).paths(path).build(); - ImmutableSet<PathRule> rules = ImmutableSet.<PathRule>of(rule); - ImmutableSet<PathMatcher> matchers = ImmutableSet.<PathMatcher>of(PathMatcher.builder().defaultService(service) - .name("path") - .pathRules(rules) - .build()); - ImmutableSet<String> hosts = ImmutableSet.<String>of("jclouds-test"); - ImmutableSet<HostRule> hostRules = ImmutableSet.<HostRule>of(HostRule.builder().hosts(hosts) - .pathMatcher("path") - .build()); + options.pathMatchers(matchers) .name(URL_MAP_NAME) .hostRules(hostRules) .urlMapTests(urlMapTests) .defaultService(service) .description("simple url map"); - + UrlMapValidateResult results = api().validate(URL_MAP_NAME, options); - UrlMapValidateResult expected = UrlMapValidateResult.builder().testPassed(true).loadSucceeded(true).build(); + UrlMapValidateResult expected = UrlMapValidateResult.allPass(); assertEquals(results, expected); } - @Test(groups = "live", dependsOnMethods = "testValidateUrlMapWithOptions") + @Test(groups = "live", dependsOnMethods = "testValidateUrlMapWithOptions", alwaysRun = true) public void testDeleteUrlMap() { - assertGlobalOperationDoneSucessfully(api().delete(URL_MAP_NAME), TIME_WAIT); - + assertOperationDoneSuccessfully(api().delete(URL_MAP_NAME)); + // remove extra resources created - assertGlobalOperationDoneSucessfully(api.getBackendServiceApiForProject(userProject.get()) - .delete(URL_MAP_BACKEND_SERVICE_NAME), TIME_WAIT); - // TODO: delete health check once it is merged + assertOperationDoneSuccessfully(api.backendServices().delete(URL_MAP_BACKEND_SERVICE_NAME)); + + assertOperationDoneSuccessfully(api.httpHeathChecks().delete(HEALTH_CHECK_NAME)); + } private void assertUrlMapEquals(UrlMap result) { - assertEquals(result.getName(), URL_MAP_NAME); - assertEquals(result.getDefaultService(), getBackendServiceUrl(userProject.get(), - URL_MAP_BACKEND_SERVICE_NAME)); - assertEquals(result.getDescription().get(), "simple url map"); + assertEquals(result.name(), URL_MAP_NAME); + assertEquals(result.defaultService(), getBackendServiceUrl(URL_MAP_BACKEND_SERVICE_NAME)); + assertEquals(result.description(), "simple url map"); } private void assertUrlMapEquals(UrlMap result, UrlMapOptions expected) { - assertEquals(result.getName(), expected.getName()); - assertEquals(result.getDefaultService(), expected.getDefaultService()); - assertEquals(result.getPathMatchers(), expected.getPathMatchers()); - assertEquals(result.getHostRules(), expected.getHostRules()); + assertEquals(result.name(), expected.getName()); + assertEquals(result.defaultService(), expected.getDefaultService()); + assertEquals(result.pathMatchers(), expected.getPathMatchers()); + assertEquals(result.hostRules(), expected.getHostRules()); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java index 5af9607..1a62257 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/internal/BaseGoogleComputeEngineApiLiveTest.java @@ -57,9 +57,6 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo protected static final String BACKEND_SERVICE_API_URL_SUFFIX = "/global/backendServices/"; protected static final String URL_MAP_API_URL_SUFFIX = "/global/urlMaps/"; protected static final String HEALTH_CHECK_API_URL_SUFFIX = "/global/httpHealthChecks/"; - protected static final String RESOURCE_VIEW_API_URL_PREFIX = "https://www.googleapis.com/resourceviews/" - + "v1beta1/projects/"; - protected static final String RESOURCE_VIEW_API_URL_SUFFIX = "/resourceViews/"; protected static final String TARGET_HTTP_PROXY_API_URL_SUFFIX = "/global/targetHttpProxies/"; protected static final String GOOGLE_PROJECT = "google"; @@ -128,29 +125,18 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo return URI.create(projectUrl + IMAGE_API_URL_SUFFIX + image); } - //TODO (broudy): refactor all these functions to not take project once compiling correctly! - protected URI getHealthCheckUrl(String project, String healthCheck) { + protected URI getHealthCheckUrl(String healthCheck) { return URI.create(projectUrl + HEALTH_CHECK_API_URL_SUFFIX + healthCheck); } - protected URI getInstanceUrl(String project, String instanceName) { + protected URI getInstanceUrl(String instanceName) { return URI.create(projectUrl + ZONE_API_URL_SUFFIX + DEFAULT_ZONE_NAME + "/instances/" + instanceName); } - // TODO (broudy): duplicate! remove! - protected URI getGatewayUrl(String project, String gateway) { - return URI.create(projectUrl + GATEWAY_API_URL_SUFFIX + gateway); - } - - protected URI getTargetHttpProxyUrl(String project, String targetHttpProxy) { + protected URI getTargetHttpProxyUrl(String targetHttpProxy) { return URI.create(projectUrl + TARGET_HTTP_PROXY_API_URL_SUFFIX + targetHttpProxy); } - // TODO (broudy): duplicate! remove! - protected URI getImageUrl(String project, String image){ - return URI.create(projectUrl + IMAGE_API_URL_SUFFIX + image); - } - protected URI getDefaultMachineTypeUrl() { return getMachineTypeUrl(DEFAULT_MACHINE_TYPE_NAME); } @@ -164,22 +150,13 @@ public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleCo return URI.create(projectUrl + ZONE_API_URL_SUFFIX + DEFAULT_ZONE_NAME + "/disks/" + diskName); } - protected URI getDiskUrl(String project, String diskName) { - return URI.create(projectUrl + ZONE_API_URL_SUFFIX + DEFAULT_ZONE_NAME + "/disks/" + diskName); - } - - protected URI getBackendServiceUrl(String project, String backendService) { + protected URI getBackendServiceUrl(String backendService) { return URI.create(projectUrl + BACKEND_SERVICE_API_URL_SUFFIX + backendService); } - protected URI getUrlMapUrl(String project, String urlMap) { + protected URI getUrlMapUrl(String urlMap) { return URI.create(projectUrl + URL_MAP_API_URL_SUFFIX + urlMap); } - - protected URI getResourceViewInZoneUrl(String project, String resourceView) { - return URI.create(RESOURCE_VIEW_API_URL_PREFIX + project + ZONE_API_URL_SUFFIX - + DEFAULT_ZONE_NAME + RESOURCE_VIEW_API_URL_SUFFIX + resourceView); - } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java index 2bf9041..b131b43 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceGetHealthTest.java @@ -16,16 +16,17 @@ */ package org.jclouds.googlecomputeengine.parse; -import java.net.URI; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth; +import org.jclouds.googlecomputeengine.domain.BackendServiceGroupHealth.HealthStatus; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; @Test(groups = "unit") public class ParseBackendServiceGetHealthTest extends BaseGoogleComputeEngineParseTest<BackendServiceGroupHealth> { @@ -36,16 +37,18 @@ public class ParseBackendServiceGetHealthTest extends BaseGoogleComputeEnginePar } @Override - @Consumes(MediaType.APPLICATION_JSON) + @Consumes(APPLICATION_JSON) public BackendServiceGroupHealth expected() { URI uri = URI.create("https://www.googleapis.com/compute/v1/projects/" + "myproject/zones/us-central1-a/instances/" + "jclouds-test"); - return BackendServiceGroupHealth.builder() - .healthStatuses(ImmutableSet.of(BackendServiceGroupHealth.HealthStatus.builder() - .healthState("HEALTHY") - .instance(uri) - .build()) - ).build(); + return BackendServiceGroupHealth.create( + ImmutableList.of(HealthStatus.create( + null, // ipAddress + 80, // port + uri, // instance + "HEALTHY" //healthState + )) //healthStatuses + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceListTest.java index b662923..9397557 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceListTest.java @@ -16,19 +16,20 @@ */ package org.jclouds.googlecomputeengine.parse; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; + import java.net.URI; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.BackendService; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; +import org.jclouds.googlecloud.domain.ForwardingListPage; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; @Test(groups = "unit") public class ParseBackendServiceListTest extends BaseGoogleComputeEngineParseTest<ListPage<BackendService>> { @@ -39,27 +40,24 @@ public class ParseBackendServiceListTest extends BaseGoogleComputeEngineParseTes } @Override - @Consumes(MediaType.APPLICATION_JSON) + @Consumes(APPLICATION_JSON) public ListPage<BackendService> expected() { - return ListPage.<BackendService>builder() - .kind(Resource.Kind.BACKEND_SERVICE_LIST) - .id("projects/myproject/backendServices") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices")) - .items(ImmutableSet.of( - new ParseBackendServiceTest().expected(), - BackendService.builder() - .id("12862241067393040785") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/backendServices/jclouds-test-2")) - .name("jclouds-test-2") - .description("Backend Service 2") - .port(80) - .protocol("HTTP") - .timeoutSec(45) - .healthChecks(ImmutableSet.of(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/jclouds-test"))) - .build() - )) - .build(); + return ForwardingListPage.create( + ImmutableList.of( + new ParseBackendServiceTest().expected(), + BackendService.create("12862241067393040785", //id + new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365"), //creationTimestamp, + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/backendServices/jclouds-test-2"), //selfLink, + "jclouds-test-2", //name, + "Backend Service 2", //description + null, // backends, + ImmutableList.of(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/jclouds-test")), //healthChecks, + 45, //timeoutSec, + 80, //port, + "HTTP", //protocol, + null) //fingerprint + ), + null + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceTest.java index 3c1ddbe..004a9ec 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseBackendServiceTest.java @@ -24,10 +24,11 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.BackendService; import org.jclouds.googlecomputeengine.domain.BackendService.Backend; +import org.jclouds.googlecomputeengine.domain.BackendService.Backend.BalancingModes; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; @Test(groups = "unit") public class ParseBackendServiceTest extends BaseGoogleComputeEngineParseTest<BackendService> { @@ -49,24 +50,24 @@ public class ParseBackendServiceTest extends BaseGoogleComputeEngineParseTest<Ba URI group = URI.create("https://www.googleapis.com/resourceviews/v1beta1" + "/projects/myproject/zones/us-central1-a/" + "resourceViews/jclouds-test"); - Backend backend = Backend.builder() - .balancingMode("UTILIZATION") - .capacityScaler((float) 1.0) - .description("A resource view") - .group(group) - .maxUtilization((float) 0.8).build(); - return BackendService.builder() - .id("15448612110458377529") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-07-18T13:37:48.574-07:00")) - .selfLink(selfLink) - .name("jclouds-test") - .addHealthCheck(healthCheck) - .port(80) - .protocol("HTTP") - .timeoutSec(30) - .fingerprint("I6n5NPSXn8g=") - .description("Backend service") - .backends(ImmutableSet.of(backend)) - .build(); + Backend backend = Backend.create("A resource view", //description + group, //group + BalancingModes.UTILIZATION, //balancingMode + (float) 0.8, //maxUtilization + null, //maxRate + null, //maxRatePerInstance + (float) 1.0); // capacityScaler + return BackendService.create("15448612110458377529", //id + new SimpleDateFormatDateService().iso8601DateParse("2014-07-18T13:37:48.574-07:00"), //creationTimestamp + selfLink, //selfLink + "jclouds-test", //name + "Backend service", // description + ImmutableList.of(backend), //backends + ImmutableList.of(healthCheck), //healthChecks + 30, //timeoutSec + 80, //port + "HTTP", //protocol + "I6n5NPSXn8g=" //fingerprint + ); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java index ae755d8..7b09dc6 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseForwardingRuleTest.java @@ -22,6 +22,7 @@ import java.net.URI; import javax.ws.rs.Consumes; +import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.ForwardingRule; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; @@ -41,6 +42,7 @@ public class ParseForwardingRuleTest extends BaseGoogleComputeEngineParseTest<Fo URI.create(BASE_URL + "/party/regions/europe-west1/forwardingRules/test-forwarding-rule"), // selfLink "test-forwarding-rule", // name null, // description + new SimpleDateFormatDateService().iso8601DateParse("2014-01-08T06:51:10.809-08:00"), // creationTimestamp URI.create(BASE_URL + "/party/regions/europe-west1"), // region "23.251.129.77", // ipAddress ForwardingRule.IPProtocol.TCP, // ipProtocol http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleListTest.java index 3fcf60a..45b6159 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleListTest.java @@ -16,18 +16,19 @@ */ package org.jclouds.googlecomputeengine.parse; -import java.net.URI; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; -import org.jclouds.googlecomputeengine.domain.ListPage; +import org.jclouds.googlecloud.domain.ForwardingListPage; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.domain.ForwardingRule; -import org.jclouds.googlecomputeengine.domain.Resource; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; +import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; +@Test(groups = "unit", testName = "ParseGlobalForwardingRuleListTest") public class ParseGlobalForwardingRuleListTest extends BaseGoogleComputeEngineParseTest<ListPage<ForwardingRule>> { @Override @@ -35,15 +36,11 @@ public class ParseGlobalForwardingRuleListTest extends BaseGoogleComputeEnginePa return "/global_forwarding_rule_list.json"; } - @Override - @Consumes(MediaType.APPLICATION_JSON) + @Override @Consumes(APPLICATION_JSON) public ListPage<ForwardingRule> expected() { - return ListPage.<ForwardingRule>builder() - .kind(Resource.Kind.FORWARDING_RULE_LIST) - .id("projects/myproject/global/forwardingRules") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/forwardingRules")) - .items(ImmutableSet.of(new ParseGlobalForwardingRuleTest().expected())) - .build(); - + return ForwardingListPage.create( + ImmutableList.of(new ParseGlobalForwardingRuleTest().expected()), // items + null // nextPageToken + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleTest.java index 41dcd03..d797378 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseGlobalForwardingRuleTest.java @@ -23,6 +23,7 @@ import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.googlecomputeengine.domain.ForwardingRule; +import org.jclouds.googlecomputeengine.domain.ForwardingRule.IPProtocol; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; public class ParseGlobalForwardingRuleTest extends BaseGoogleComputeEngineParseTest<ForwardingRule> { @@ -35,16 +36,16 @@ public class ParseGlobalForwardingRuleTest extends BaseGoogleComputeEngineParseT @Override @Consumes(MediaType.APPLICATION_JSON) public ForwardingRule expected() { - return ForwardingRule.builder() - .id("8192211304399313984") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2014-07-18T09:47:30.826-07:00")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/forwardingRules/jclouds-test")) - .name("jclouds-test") - .description("tcp forwarding rule") - .ipAddress("107.178.255.156") - .ipProtocol("TCP") - .portRanges("80-80") - .target(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test")) - .build(); + return ForwardingRule.create("8192211304399313984", // id + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/forwardingRules/jclouds-test"), // selfLink + "jclouds-test", // name + "tcp forwarding rule", // description + new SimpleDateFormatDateService().iso8601DateParse("2014-07-18T09:47:30.826-07:00"), // creationTimestamp + null, // region + "107.178.255.156", //IPAddress + IPProtocol.TCP, //IPProtocol + "80-80", // portRange + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test") // Target + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListRegionTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListRegionTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListRegionTest.java deleted file mode 100644 index cc6cae4..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListRegionTest.java +++ /dev/null @@ -1,64 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; -import org.jclouds.googlecomputeengine.domain.ResourceView; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit") -public class ParseResourceViewListRegionTest extends BaseGoogleComputeEngineParseTest<ListPage<ResourceView>> { - - @Override - public String resource() { - return "/resource_view_list_region.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage<ResourceView> expected() { - return ListPage.<ResourceView>builder() - .kind(Resource.Kind.RESOURCE_VIEW_LIST) - .id("") - .selfLink(URI.create("")) - .items(ImmutableSet.of( - new ParseResourceViewRegionTest().expected() - , ResourceView.builder() - .id("13050421646334304116") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/resourceviews/v1beta1/projects/myproject/regions/" - + "us-central1/resourceViews/jclouds-test-2")) - .name("jclouds-test-2") - .description("Simple resource view") - .addMember(URI.create("https://www.googleapis.com/compute/projects/myproject/zones/" - + "us-central1-a/instances/jclouds-test")) - .numMembers(1) - .build() - )) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListZoneTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListZoneTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListZoneTest.java deleted file mode 100644 index 07ab864..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewListZoneTest.java +++ /dev/null @@ -1,64 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; -import org.jclouds.googlecomputeengine.domain.ResourceView; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit") -public class ParseResourceViewListZoneTest extends BaseGoogleComputeEngineParseTest<ListPage<ResourceView>> { - - @Override - public String resource() { - return "/resource_view_list_zone.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage<ResourceView> expected() { - return ListPage.<ResourceView>builder() - .kind(Resource.Kind.RESOURCE_VIEW_LIST) - .id("") - .selfLink(URI.create("")) - .items(ImmutableSet.of( - new ParseResourceViewZoneTest().expected() - , ResourceView.builder() - .id("13050421646334304116") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/resourceviews/v1beta1/projects/myproject/zones/" - + "us-central1-a/resourceViews/jclouds-test-2")) - .name("jclouds-test-2") - .description("Simple resource view") - .addMember(URI.create("https://www.googleapis.com/compute/projects/myproject/zones/" - + "us-central1-a/instances/jclouds-test")) - .numMembers(1) - .build() - )) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewRegionTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewRegionTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewRegionTest.java deleted file mode 100644 index 02e32d0..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewRegionTest.java +++ /dev/null @@ -1,50 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ResourceView; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -@Test(groups = "unit") -public class ParseResourceViewRegionTest extends BaseGoogleComputeEngineParseTest<ResourceView> { - - @Override - public String resource() { - return "/resource_view_get_region.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ResourceView expected() { - return ResourceView.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/resourceviews/v1beta1/projects/myproject/regions/" - + "us-central1/resourceViews/jclouds-test")) - .name("jclouds-test") - .description("Simple resource view") - .numMembers(0) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewResourceListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewResourceListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewResourceListTest.java deleted file mode 100644 index f4d8056..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewResourceListTest.java +++ /dev/null @@ -1,51 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSet; - -@Test(groups = "unit") -public class ParseResourceViewResourceListTest extends BaseGoogleComputeEngineParseTest<ListPage<URI>> { - - @Override - public String resource() { - return "/resource_view_resources_list.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ListPage<URI> expected() { - String base = "https://googleapis.com/compute/projects/myproject/zones/us-central1-a/instances/"; - return ListPage.<URI>builder() - .kind(Resource.Kind.RESOURCE_VIEW_MEMBER_LIST) - .id("") - .selfLink(URI.create("")) - .items(ImmutableSet.<URI>of(URI.create(base + "jclouds-test-1"), - URI.create(base + "jclouds-test-2")) - ).build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewZoneTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewZoneTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewZoneTest.java deleted file mode 100644 index 9324a4d..0000000 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseResourceViewZoneTest.java +++ /dev/null @@ -1,50 +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.parse; - -import java.net.URI; - -import javax.ws.rs.Consumes; -import javax.ws.rs.core.MediaType; - -import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ResourceView; -import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; -import org.testng.annotations.Test; - -@Test(groups = "unit") -public class ParseResourceViewZoneTest extends BaseGoogleComputeEngineParseTest<ResourceView> { - - @Override - public String resource() { - return "/resource_view_get_zone.json"; - } - - @Override - @Consumes(MediaType.APPLICATION_JSON) - public ResourceView expected() { - return ResourceView.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/resourceviews/v1beta1/projects/myproject/zones/" - + "us-central1-a/resourceViews/jclouds-test")) - .name("jclouds-test") - .description("Simple resource view") - .numMembers(0) - .build(); - } -} http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java index dbd1ea6..d4abfca 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyListTest.java @@ -22,13 +22,13 @@ import javax.ws.rs.Consumes; import javax.ws.rs.core.MediaType; import org.jclouds.date.internal.SimpleDateFormatDateService; -import org.jclouds.googlecomputeengine.domain.ListPage; -import org.jclouds.googlecomputeengine.domain.Resource; +import org.jclouds.googlecloud.domain.ForwardingListPage; +import org.jclouds.googlecloud.domain.ListPage; import org.jclouds.googlecomputeengine.domain.TargetHttpProxy; import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest; import org.testng.annotations.Test; -import com.google.common.collect.ImmutableSet; +import com.google.common.collect.ImmutableList; @Test(groups = "unit") public class ParseTargetHttpProxyListTest extends BaseGoogleComputeEngineParseTest<ListPage<TargetHttpProxy>> { @@ -41,22 +41,17 @@ public class ParseTargetHttpProxyListTest extends BaseGoogleComputeEngineParseTe @Override @Consumes(MediaType.APPLICATION_JSON) public ListPage<TargetHttpProxy> expected() { - return ListPage.<TargetHttpProxy>builder() - .kind(Resource.Kind.TARGET_HTTP_PROXY_LIST) - .id("projects/myproject/targetHttpProxies") - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies")) - .items(ImmutableSet.of( - new ParseTargetHttpProxyTest().expected() - , TargetHttpProxy.builder() - .id("13050421646334304116") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis" + - ".com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test-2")) - .name("jclouds-test-2") - .description("Simple proxy") - .urlMap(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test-2")) - .build() - )) - .build(); + return ForwardingListPage.create( + ImmutableList.of( + new ParseTargetHttpProxyTest().expected(), + TargetHttpProxy.create("13050421646334304116", // id + new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"), // creationTimestamp + URI.create("https://www.googleapis" + + ".com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test-2"), // selfLink + "jclouds-test-2", // name + "Simple proxy", // description + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test-2"))), // urlMap + null // nextPageToken d + ); } } http://git-wip-us.apache.org/repos/asf/jclouds-labs-google/blob/d147afdc/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java ---------------------------------------------------------------------- diff --git a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java index 66ff65e..802ad46 100644 --- a/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java +++ b/google-compute-engine/src/test/java/org/jclouds/googlecomputeengine/parse/ParseTargetHttpProxyTest.java @@ -37,12 +37,11 @@ public class ParseTargetHttpProxyTest extends BaseGoogleComputeEngineParseTest<T @Override @Consumes(MediaType.APPLICATION_JSON) public TargetHttpProxy expected() { - return TargetHttpProxy.builder() - .id("13050421646334304115") - .creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306")) - .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test")) - .name("jclouds-test") - .urlMap(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test")) - .build(); + return TargetHttpProxy.create("13050421646334304115", // id + new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"), // creationTimestamp + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/targetHttpProxies/jclouds-test"), // selfLink + "jclouds-test", // name + null, + URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/urlMaps/jclouds-test")); // urlMap } }
