diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApiExpectTest.java index 5c87813b61..26293d30f8 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/AccessRuleApiExpectTest.java @@ -17,20 +17,21 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.POST; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.List; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRule; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AccessRuleWithId; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.AccessRuleApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -47,7 +48,7 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/accesslist-list.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/accesslist-list.json")).build() ).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000); Iterable accessList = api.list(); @@ -59,8 +60,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< AccessRuleApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("POST").endpoint(endpoint).payload(payloadFromResource("/accesslist-create.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(POST).endpoint(endpoint).payload(payloadFromResource("/accesslist-create.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000); AccessRule accessRule1 = AccessRule.deny("206.160.163.21"); @@ -76,8 +77,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< AccessRuleApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.delete(23)); @@ -88,8 +89,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< AccessRuleApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000); List accessRuleIds = ImmutableList. of(23, 24); @@ -101,8 +102,8 @@ public class AccessRuleApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< AccessRuleApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getAccessRuleApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.deleteAll()); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApiExpectTest.java index 4abbb4c305..dc15f39f61 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ConnectionApiExpectTest.java @@ -17,19 +17,20 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import java.net.URI; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.ConnectionThrottle; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.ConnectionApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -44,7 +45,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionthrottle-get.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionthrottle-get.json")).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); ConnectionThrottle connectionThrottle = api.getConnectionThrottle(); @@ -57,7 +58,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionthrottle-get-deleted.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionthrottle-get-deleted.json")).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); ConnectionThrottle connectionThrottle = api.getConnectionThrottle(); @@ -69,8 +70,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< ConnectionApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionthrottle-create.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionthrottle-create.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); api.createOrUpdateConnectionThrottle(getConnectionThrottle()); @@ -90,8 +91,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< ConnectionApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.deleteConnectionThrottle()); @@ -103,7 +104,7 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/connectionlogging-enable.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/connectionlogging-enable.json")).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.isConnectionLogging()); @@ -114,8 +115,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< ConnectionApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionlogging-enable.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionlogging-enable.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); api.enableConnectionLogging(); @@ -126,8 +127,8 @@ public class ConnectionApiExpectTest extends BaseCloudLoadBalancerApiExpectTest< ConnectionApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/connectionlogging-disable.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/connectionlogging-disable.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getConnectionApiForZoneAndLoadBalancer("DFW", 2000); api.disableConnectionLogging(); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApiExpectTest.java index b95f5867b9..f1a92a6311 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ContentCachingApiExpectTest.java @@ -17,14 +17,14 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertTrue; import java.net.URI; import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.ContentCachingApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -39,7 +39,7 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/contentcaching-enable.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/contentcaching-enable.json")).build() ).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.isContentCaching()); @@ -50,8 +50,8 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT ContentCachingApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/contentcaching-enable.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/contentcaching-enable.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000); api.enable(); @@ -62,8 +62,8 @@ public class ContentCachingApiExpectTest extends BaseCloudLoadBalancerApiExpectT ContentCachingApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/contentcaching-disable.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/contentcaching-disable.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getContentCachingApiForZoneAndLoadBalancer("DFW", 2000); api.disable(); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApiExpectTest.java index 72b9d9c1c1..b879e4cdf5 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/ErrorPageApiExpectTest.java @@ -17,18 +17,20 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.io.IOException; import java.net.URI; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.ErrorPageApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -55,8 +57,8 @@ public class ErrorPageApiExpectTest extends BaseCloudLoadBalancerApiExpectTest loadBalancers = api.list().concat().toSet(); @@ -69,7 +73,7 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build() ).getLoadBalancerApiForZone("DFW"); LoadBalancer loadBalancer = api.get(2000); @@ -82,11 +86,11 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET() - .method("POST") + .method(POST) .payload(payloadFromResource("/loadbalancer-create.json")) .endpoint(endpoint) .build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/loadbalancer-get.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/loadbalancer-get.json")).build() ).getLoadBalancerApiForZone("DFW"); AddNode addNode1 = AddNode.builder() @@ -122,8 +126,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes LoadBalancerApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").payload(payloadFromResource("/loadbalancer-update.json")).endpoint(endpoint).build(), - HttpResponse.builder().statusCode(202).payload("").build() + authenticatedGET().method(PUT).payload(payloadFromResource("/loadbalancer-update.json")).endpoint(endpoint).build(), + HttpResponse.builder().statusCode(ACCEPTED.getStatusCode()).payload("").build() ).getLoadBalancerApiForZone("DFW"); UpdateLoadBalancer updateLB = UpdateLoadBalancer.builder() @@ -142,11 +146,11 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET() - .method("DELETE") - .replaceHeader("Accept", MediaType.WILDCARD) + .method(DELETE) + .replaceHeader(ACCEPT, WILDCARD) .endpoint(endpoint) .build(), - HttpResponse.builder().statusCode(202).payload("").build() + HttpResponse.builder().statusCode(ACCEPTED.getStatusCode()).payload("").build() ).getLoadBalancerApiForZone("DFW"); api.delete(2000); @@ -158,7 +162,7 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build() ).getLoadBalancerApiForZone("DFW"); Metadata metadata = api.getMetadata(2000); @@ -171,10 +175,10 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET() - .method("POST") + .method(POST) .endpoint(endpoint) - .payload(payloadFromResourceWithContentType("/metadata-create.json", MediaType.APPLICATION_JSON)).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/metadata-list.json")).build() + .payload(payloadFromResourceWithContentType("/metadata-create.json", APPLICATION_JSON)).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/metadata-list.json")).build() ).getLoadBalancerApiForZone("DFW"); Metadata metadata = api.createMetadata(2000, getExpectedMetadata()); @@ -186,8 +190,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes LoadBalancerApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getLoadBalancerApiForZone("DFW"); assertTrue(api.deleteMetadatum(2000, 23)); @@ -198,8 +202,8 @@ public class LoadBalancerApiExpectTest extends BaseCloudLoadBalancerApiExpectTes LoadBalancerApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getLoadBalancerApiForZone("DFW"); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiExpectTest.java index 520a4baa86..e8764161ef 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/NodeApiExpectTest.java @@ -17,22 +17,25 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.POST; +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.Set; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; +import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Metadata; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.Node; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.UpdateNode; -import org.jclouds.rackspace.cloudloadbalancers.v1.domain.AddNode; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.NodeApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -51,7 +54,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest nodes = api.list().concat().toSet(); @@ -64,7 +67,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest nodeIds = ImmutableSortedSet. of(410, 411); @@ -162,7 +165,7 @@ public class NodeApiExpectTest extends BaseCloudLoadBalancerApiExpectTest loadBalancers = api.listBillableLoadBalancers(aWeekAgo, today).concat(); @@ -88,7 +87,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest loadBalancerUsages = api.listLoadBalancerUsage(2000, aWeekAgo, today).concat(); @@ -130,7 +129,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest loadBalancerUsages = api.listCurrentLoadBalancerUsage(2000).concat(); @@ -144,7 +143,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest protocols = api.listProtocols(); @@ -177,7 +176,7 @@ public class ReportApiExpectTest extends BaseCloudLoadBalancerApiExpectTest algorithms = api.listAlgorithms(); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApiExpectTest.java index 681c66a346..b30903a2a4 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SSLTerminationApiExpectTest.java @@ -17,20 +17,23 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertNull; +import static org.testng.Assert.assertTrue; import java.io.IOException; import java.net.URI; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SSLTermination; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.SSLTerminationApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.jclouds.util.Strings2; import org.testng.annotations.Test; @@ -47,7 +50,7 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/ssltermination-get.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/ssltermination-get.json")).build() ).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000); SSLTermination sslTermination = api.get(); @@ -60,7 +63,7 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(404).build() + HttpResponse.builder().statusCode(NOT_FOUND.getStatusCode()).build() ).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000); SSLTermination sslTermination = api.get(); @@ -73,11 +76,11 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET() - .method("PUT") + .method(PUT) .endpoint(endpoint) - .payload(payloadFromResourceWithContentType("/ssltermination-create.json", MediaType.APPLICATION_JSON)) + .payload(payloadFromResourceWithContentType("/ssltermination-create.json", APPLICATION_JSON)) .build(), - HttpResponse.builder().statusCode(200).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000); api.createOrUpdate(getSSLTermination()); @@ -88,8 +91,8 @@ public class SSLTerminationApiExpectTest extends BaseCloudLoadBalancerApiExpectT SSLTerminationApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).replaceHeader("Accept", MediaType.WILDCARD).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).replaceHeader(ACCEPT, WILDCARD).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getSSLTerminationApiForZoneAndLoadBalancer("DFW", 2000); assertTrue(api.delete()); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApiExpectTest.java index e872e00a72..202109948b 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/SessionPersistenceApiExpectTest.java @@ -17,7 +17,9 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.PUT; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNull; @@ -26,7 +28,6 @@ import java.net.URI; import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.SessionPersistence; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.SessionPersistenceApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -41,7 +42,7 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/sessionpersistence-get.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/sessionpersistence-get.json")).build() ).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000); SessionPersistence sessionPersistence = api.get(); @@ -54,7 +55,7 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp rackspaceAuthWithUsernameAndApiKey, responseWithAccess, authenticatedGET().endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).payload(payloadFromResource("/sessionpersistence-get-deleted.json")).build() + HttpResponse.builder().statusCode(OK.getStatusCode()).payload(payloadFromResource("/sessionpersistence-get-deleted.json")).build() ).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000); SessionPersistence sessionPersistence = api.get(); @@ -66,8 +67,8 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp SessionPersistenceApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("PUT").endpoint(endpoint).payload(payloadFromResource("/sessionpersistence-create.json")).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(PUT).endpoint(endpoint).payload(payloadFromResource("/sessionpersistence-create.json")).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000); api.create(SessionPersistence.HTTP_COOKIE); @@ -78,8 +79,8 @@ public class SessionPersistenceApiExpectTest extends BaseCloudLoadBalancerApiExp SessionPersistenceApi api = requestsSendResponses( rackspaceAuthWithUsernameAndApiKey, responseWithAccess, - authenticatedGET().method("DELETE").endpoint(endpoint).build(), - HttpResponse.builder().statusCode(200).build() + authenticatedGET().method(DELETE).endpoint(endpoint).build(), + HttpResponse.builder().statusCode(OK.getStatusCode()).build() ).getSessionPersistenceApiForZoneAndLoadBalancer("DFW", 2000); api.delete(); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApiExpectTest.java index 8b8a116dc2..d6f41bba72 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/features/VirtualIPApiExpectTest.java @@ -17,19 +17,20 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.features; - +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.DELETE; +import static javax.ws.rs.HttpMethod.POST; +import static javax.ws.rs.core.MediaType.WILDCARD; +import static javax.ws.rs.core.Response.Status.OK; import static org.testng.Assert.assertEquals; import java.net.URI; import java.util.List; -import javax.ws.rs.core.MediaType; - import org.jclouds.http.HttpResponse; import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIP; import org.jclouds.rackspace.cloudloadbalancers.v1.domain.VirtualIPWithId; -import org.jclouds.rackspace.cloudloadbalancers.v1.features.VirtualIPApi; import org.jclouds.rackspace.cloudloadbalancers.v1.internal.BaseCloudLoadBalancerApiExpectTest; import org.testng.annotations.Test; @@ -46,7 +47,7 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest virtualIPs = api.list(); @@ -58,8 +59,8 @@ public class VirtualIPApiExpectTest extends BaseCloudLoadBalancerApiExpectTest virtualIPIds = ImmutableList. of(23, 24); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/handlers/ParseCloudLoadBalancersErrorFromHttpResponseTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/handlers/ParseCloudLoadBalancersErrorFromHttpResponseTest.java index 4d0fbd1281..8c286b4f84 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/handlers/ParseCloudLoadBalancersErrorFromHttpResponseTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/handlers/ParseCloudLoadBalancersErrorFromHttpResponseTest.java @@ -17,11 +17,12 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.handlers; +import static javax.ws.rs.HttpMethod.GET; +import static javax.ws.rs.core.Response.Status.NOT_FOUND; import java.net.URI; import org.jclouds.http.handlers.BaseHttpErrorHandlerTest; -import org.jclouds.rackspace.cloudloadbalancers.v1.handlers.ParseCloudLoadBalancersErrorFromHttpResponse; import org.jclouds.rest.ResourceNotFoundException; import org.testng.annotations.Test; @@ -33,11 +34,11 @@ import org.testng.annotations.Test; public class ParseCloudLoadBalancersErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest { @Test - public void test404NotFound() { + public void testNotFound() { assertCodeMakes( - "GET", + GET, URI.create("https://ord.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/2000"), - 404, + NOT_FOUND.getStatusCode(), "Not Found", "\n Object not Found\n", ResourceNotFoundException.class, "loadbalancers 2000 not found"); diff --git a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancerApiExpectTest.java b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancerApiExpectTest.java index fee0b1af40..1793e1056b 100644 --- a/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancerApiExpectTest.java +++ b/apis/rackspace-cloudloadbalancers/src/test/java/org/jclouds/rackspace/cloudloadbalancers/v1/internal/BaseCloudLoadBalancerApiExpectTest.java @@ -17,8 +17,9 @@ * under the License. */ package org.jclouds.rackspace.cloudloadbalancers.v1.internal; - -import javax.ws.rs.core.MediaType; +import static com.google.common.net.HttpHeaders.ACCEPT; +import static javax.ws.rs.HttpMethod.GET; +import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; @@ -53,8 +54,8 @@ public class BaseCloudLoadBalancerApiExpectTest extends BaseRestApiExpectTest protected HttpRequest.Builder authenticatedGET() { return HttpRequest.builder() - .method("GET") - .addHeader("Accept", MediaType.APPLICATION_JSON) + .method(GET) + .addHeader(ACCEPT, APPLICATION_JSON) .addHeader("X-Auth-Token", authToken); } }