Issue 77: removed inconsistent NOT_FOUND objects

git-svn-id: http://jclouds.googlecode.com/svn/trunk@2554 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-12-31 02:08:43 +00:00
parent 1e0e63ddd2
commit cc0dbf6e1c
12 changed files with 117 additions and 290 deletions

View File

@ -65,10 +65,6 @@ import org.jclouds.rackspace.cloudservers.functions.ParseServerFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseServerListFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseSharedIpGroupFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseSharedIpGroupListFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ReturnFlavorNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnImageNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnServerNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnSharedIpGroupNotFoundOn404;
import org.jclouds.rackspace.cloudservers.options.CreateServerOptions;
import org.jclouds.rackspace.cloudservers.options.CreateSharedIpGroupOptions;
import org.jclouds.rackspace.cloudservers.options.ListOptions;
@ -116,7 +112,6 @@ public interface CloudServersAsyncClient {
@GET
@ResponseParser(ParseServerFromJsonResponse.class)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnServerNotFoundOn404.class)
@Path("/servers/{id}")
Future<Server> getServer(@PathParam("id") int id);
@ -246,7 +241,6 @@ public interface CloudServersAsyncClient {
@GET
@ResponseParser(ParseFlavorFromJsonResponse.class)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnFlavorNotFoundOn404.class)
@Path("/flavors/{id}")
Future<Flavor> getFlavor(@PathParam("id") int id);
@ -265,7 +259,6 @@ public interface CloudServersAsyncClient {
@GET
@ResponseParser(ParseImageFromJsonResponse.class)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnImageNotFoundOn404.class)
@Path("/images/{id}")
Future<Image> getImage(@PathParam("id") int id);
@ -283,7 +276,6 @@ public interface CloudServersAsyncClient {
@POST
@ResponseParser(ParseImageFromJsonResponse.class)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnImageNotFoundOn404.class)
@MapBinder(BindCreateImageToJsonPayload.class)
@Path("/images")
Future<Image> createImageFromServer(@MapPayloadParam("imageName") String imageName,
@ -304,7 +296,6 @@ public interface CloudServersAsyncClient {
@GET
@ResponseParser(ParseSharedIpGroupFromJsonResponse.class)
@QueryParams(keys = "format", values = "json")
@ExceptionParser(ReturnSharedIpGroupNotFoundOn404.class)
@Path("/shared_ip_groups/{id}")
Future<SharedIpGroup> getSharedIpGroup(@PathParam("id") int id);

View File

@ -73,7 +73,7 @@ public interface CloudServersClient {
*
* This operation returns details of the specified server.
*
* @return {@link Server#NOT_FOUND} if the server is not found
* @throws ResourceNotFoundException if the server is not found
* @see Server
*/
Server getServer(@PathParam("id") int id);
@ -243,7 +243,7 @@ public interface CloudServersClient {
*
* This operation returns details of the specified flavor.
*
* @return {@link Flavor#NOT_FOUND} if the flavor is not found
* @throws ResourceNotFoundException if the flavor is not found
* @see Flavor
*/
Flavor getFlavor(int id);
@ -261,7 +261,7 @@ public interface CloudServersClient {
*
* This operation returns details of the specified image.
*
* @return {@link Image#NOT_FOUND} if the image is not found
* @throws ResourceNotFoundException if the image is not found
* @see Image
*/
Image getImage(int id);
@ -294,7 +294,7 @@ public interface CloudServersClient {
* Note: At present, image creation is an asynchronous operation, so coordinating the creation
* with data quiescence, etc. is currently not possible.
*
* @return {@link Image#NOT_FOUND} if the server is not found
* @throws ResourceNotFoundException if the server is not found
* @see Image
*/
Image createImageFromServer(String imageName, int serverId);
@ -312,7 +312,7 @@ public interface CloudServersClient {
*
* This operation returns details of the specified shared IP group.
*
* @return {@link SharedIpGroup#NOT_FOUND} if the shared IP group is not found
* @throws ResourceNotFoundException if the shared IP group is not found
* @see SharedIpGroup
*/
SharedIpGroup getSharedIpGroup(int id);

View File

@ -32,8 +32,6 @@ package org.jclouds.rackspace.cloudservers.domain;
*/
public class Flavor {
public static final Flavor NOT_FOUND = new Flavor(-1, "NOT_FOUND");
public Flavor() {
}

View File

@ -35,8 +35,6 @@ import java.util.Date;
*/
public class Image {
public static final Image NOT_FOUND = new Image(-1, "NOT_FOUND");
private Date created;
private int id;
private String name;

View File

@ -35,7 +35,6 @@ import com.google.inject.internal.Maps;
* @since 4.0
*/
public class Server {
public static final Server NOT_FOUND = new Server(-1, "NOT_FOUND");
private int id;
private String name;

View File

@ -37,8 +37,6 @@ import com.google.inject.internal.Lists;
*/
public class SharedIpGroup {
public static final SharedIpGroup NOT_FOUND = new SharedIpGroup(-1, "NOT_FOUND");
private int id;
private String name;

View File

@ -1,51 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Flavor;
import com.google.common.base.Function;
/**
*
*
* @author Adrian Cole
*/
@Singleton
public class ReturnFlavorNotFoundOn404 implements Function<Exception, Flavor> {
public Flavor apply(Exception from) {
if (from instanceof HttpResponseException) {
HttpResponseException responseException = (HttpResponseException) from;
if (responseException.getResponse().getStatusCode() == 404) {
return Flavor.NOT_FOUND;
}
}
return null;
}
}

View File

@ -1,51 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Image;
import com.google.common.base.Function;
/**
*
*
* @author Adrian Cole
*/
@Singleton
public class ReturnImageNotFoundOn404 implements Function<Exception, Image> {
public Image apply(Exception from) {
if (from instanceof HttpResponseException) {
HttpResponseException responseException = (HttpResponseException) from;
if (responseException.getResponse().getStatusCode() == 404) {
return Image.NOT_FOUND;
}
}
return null;
}
}

View File

@ -1,51 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.Server;
import com.google.common.base.Function;
/**
*
*
* @author Adrian Cole
*/
@Singleton
public class ReturnServerNotFoundOn404 implements Function<Exception, Server> {
public Server apply(Exception from) {
if (from instanceof HttpResponseException) {
HttpResponseException responseException = (HttpResponseException) from;
if (responseException.getResponse().getStatusCode() == 404) {
return Server.NOT_FOUND;
}
}
return null;
}
}

View File

@ -1,51 +0,0 @@
/**
*
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.rackspace.cloudservers.functions;
import javax.inject.Singleton;
import org.jclouds.http.HttpResponseException;
import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
import com.google.common.base.Function;
/**
*
*
* @author Adrian Cole
*/
@Singleton
public class ReturnSharedIpGroupNotFoundOn404 implements Function<Exception, SharedIpGroup> {
public SharedIpGroup apply(Exception from) {
if (from instanceof HttpResponseException) {
HttpResponseException responseException = (HttpResponseException) from;
if (responseException.getResponse().getStatusCode() == 404) {
return SharedIpGroup.NOT_FOUND;
}
}
return null;
}
}

View File

@ -57,6 +57,7 @@ import org.jclouds.rackspace.cloudservers.domain.ServerStatus;
import org.jclouds.rackspace.cloudservers.domain.SharedIpGroup;
import org.jclouds.rackspace.cloudservers.domain.WeeklyBackup;
import org.jclouds.rackspace.cloudservers.options.RebuildServerOptions;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.ssh.ExecResponse;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
@ -152,19 +153,19 @@ public class CloudServersClientLiveTest {
}
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testGetImageDetailsNotFound() throws Exception {
try {
Image newDetails = client.getImage(12312987);
assertEquals(Image.NOT_FOUND, newDetails);
client.getImage(12312987);
} catch (HttpResponseException e) {// Ticket #9867
if (e.getResponse().getStatusCode() != 400)
throw e;
}
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testGetServerDetailsNotFound() throws Exception {
Server newDetails = client.getServer(12312987);
assertEquals(Server.NOT_FOUND, newDetails);
client.getServer(12312987);
}
public void testGetServersDetail() throws Exception {
@ -214,9 +215,9 @@ public class CloudServersClientLiveTest {
}
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testGetFlavorDetailsNotFound() throws Exception {
Flavor newDetails = client.getFlavor(12312987);
assertEquals(Flavor.NOT_FOUND, newDetails);
client.getFlavor(12312987);
}
public void testListSharedIpGroups() throws Exception {
@ -254,9 +255,9 @@ public class CloudServersClientLiveTest {
}
}
@Test(expectedExceptions = ResourceNotFoundException.class)
public void testGetSharedIpGroupDetailsNotFound() throws Exception {
SharedIpGroup newDetails = client.getSharedIpGroup(12312987);
assertEquals(SharedIpGroup.NOT_FOUND, newDetails);
client.getSharedIpGroup(12312987);
}
@Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
@ -571,39 +572,35 @@ public class CloudServersClientLiveTest {
}
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "testRebootSoft", "testRevertResize",
"testConfirmResize" })
"testConfirmResize" }, expectedExceptions = ResourceNotFoundException.class)
void deleteServer2() {
if (serverId2 > 0) {
client.deleteServer(serverId2);
Server server = client.getServer(serverId2);
assertEquals(server, Server.NOT_FOUND);
client.getServer(serverId2);
}
}
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "deleteServer2")
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "deleteServer2", expectedExceptions = ResourceNotFoundException.class)
void testDeleteImage() {
if (imageId > 0) {
client.deleteImage(imageId);
Image image = client.getImage(imageId);
assertEquals(image, Image.NOT_FOUND);
client.getImage(imageId);
}
}
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteImage")
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteImage", expectedExceptions = ResourceNotFoundException.class)
void deleteServer1() {
if (serverId > 0) {
client.deleteServer(serverId);
Server server = client.getServer(serverId);
assertEquals(server, Server.NOT_FOUND);
client.getServer(serverId);
}
}
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "deleteServer1" })
@Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "deleteServer1" }, expectedExceptions = ResourceNotFoundException.class)
void testDeleteSharedIpGroup() {
if (sharedIpGroupId > 0) {
client.deleteSharedIpGroup(sharedIpGroupId);
SharedIpGroup server = client.getSharedIpGroup(sharedIpGroupId);
assertEquals(server, SharedIpGroup.NOT_FOUND);
client.getSharedIpGroup(sharedIpGroupId);
}
}

View File

@ -68,10 +68,6 @@ import org.jclouds.rackspace.cloudservers.functions.ParseServerFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseServerListFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseSharedIpGroupFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ParseSharedIpGroupListFromJsonResponse;
import org.jclouds.rackspace.cloudservers.functions.ReturnFlavorNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnImageNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnServerNotFoundOn404;
import org.jclouds.rackspace.cloudservers.functions.ReturnSharedIpGroupNotFoundOn404;
import org.jclouds.rackspace.cloudservers.options.CreateServerOptions;
import org.jclouds.rackspace.cloudservers.options.CreateSharedIpGroupOptions;
import org.jclouds.rackspace.cloudservers.options.ListOptions;
@ -183,7 +179,9 @@ public class CloudServersClientTest {
.singletonList(MediaType.APPLICATION_JSON));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseServerFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
assertNotNull(processor.getMapPayloadBinderOrNull(method, new Object[] { "", 1, 2,
new CreateServerOptions[] { CreateServerOptions.Builder.withSharedIpGroup(1) } }));
}
@ -197,7 +195,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getPath(), "/images/2");
assertEquals(httpMethod.getMethod(), HttpMethod.DELETE);
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -216,7 +215,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseServerListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
Date now = new Date();
@ -235,7 +236,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseServerListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListServersDetail() throws SecurityException, NoSuchMethodException {
@ -251,7 +254,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseServerListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testGetServer() throws SecurityException, NoSuchMethodException {
@ -266,8 +271,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseServerFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnServerNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListFlavors() throws SecurityException, NoSuchMethodException {
@ -283,7 +289,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseFlavorListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListFlavorsOptions() throws SecurityException, NoSuchMethodException {
@ -300,7 +308,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseFlavorListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListFlavorsDetail() throws SecurityException, NoSuchMethodException {
@ -316,7 +326,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseFlavorListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListFlavorsDetailOptions() throws SecurityException, NoSuchMethodException {
@ -333,7 +345,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseFlavorListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testGetFlavor() throws SecurityException, NoSuchMethodException {
@ -348,8 +362,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseFlavorFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFlavorNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListImages() throws SecurityException, NoSuchMethodException {
@ -365,7 +380,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListImagesDetail() throws SecurityException, NoSuchMethodException {
@ -381,7 +398,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListImagesOptions() throws SecurityException, NoSuchMethodException {
@ -398,7 +417,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListImagesDetailOptions() throws SecurityException, NoSuchMethodException {
@ -415,7 +436,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testGetImage() throws SecurityException, NoSuchMethodException {
@ -430,8 +453,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnImageNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testDeleteServer() throws SecurityException, NoSuchMethodException {
@ -443,7 +467,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getPath(), "/servers/2");
assertEquals(httpMethod.getMethod(), HttpMethod.DELETE);
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -466,7 +491,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"shareIp\":{\"sharedIpGroupId\":3}}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -490,7 +516,8 @@ public class CloudServersClientTest {
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"shareIp\":{\"sharedIpGroupId\":3,\"configureServer\":true}}", httpMethod
.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -507,7 +534,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getPath(), "/servers/2/ips/public/127.0.0.1");
assertEquals(httpMethod.getMethod(), HttpMethod.DELETE);
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -531,7 +559,8 @@ public class CloudServersClientTest {
.singletonList(MediaType.APPLICATION_JSON));
assertEquals(httpMethod.getPayload().getRawContent(),
"{\"backupSchedule\":{\"daily\":\"H_0800_1000\",\"enabled\":true,\"weekly\":\"MONDAY\"}}");
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -546,7 +575,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getPath(), "/servers/2/backup_schedule");
assertEquals(httpMethod.getMethod(), HttpMethod.DELETE);
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -568,7 +598,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"server\":{\"adminPass\":\"foo\"}}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -590,7 +621,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"server\":{\"name\":\"foo\"}}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -609,7 +641,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListSharedIpGroupsOptions() throws SecurityException, NoSuchMethodException {
@ -626,7 +660,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListSharedIpGroupsDetail() throws SecurityException, NoSuchMethodException {
@ -642,7 +678,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testListSharedIpGroupsDetailOptions() throws SecurityException,
@ -660,7 +698,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupListFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
public void testGetSharedIpGroup() throws SecurityException, NoSuchMethodException {
@ -675,8 +715,9 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnSharedIpGroupNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
}
private static final Class<? extends CreateSharedIpGroupOptions[]> createSharedIpGroupOptionsVarargsClass = new CreateSharedIpGroupOptions[] {}
@ -718,7 +759,9 @@ public class CloudServersClientTest {
.singletonList(MediaType.APPLICATION_JSON));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseSharedIpGroupFromJsonResponse.class);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(), ThrowResourceNotFoundOn404.class);
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ThrowResourceNotFoundOn404.class);
assertNotNull(processor.getMapPayloadBinderOrNull(method, new Object[] { "",
new CreateSharedIpGroupOptions[] { withServer(2) } }));
}
@ -732,7 +775,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getEndpoint().getPath(), "/shared_ip_groups/2");
assertEquals(httpMethod.getMethod(), HttpMethod.DELETE);
assertEquals(httpMethod.getHeaders().size(), 0);
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -814,7 +858,8 @@ public class CloudServersClientTest {
.singletonList(MediaType.APPLICATION_JSON));
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ParseImageFromJsonResponse.class);
assertNotNull(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method));
assertNotNull(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method));
assertNotNull(processor.getMapPayloadBinderOrNull(method, new Object[] { "", 2 }));
}
@ -853,7 +898,8 @@ public class CloudServersClientTest {
+ ""));
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -877,7 +923,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"reboot\":{\"type\":\"HARD\"}}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -898,7 +945,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"resize\":{\"flavorId\":3}}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -919,7 +967,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"confirmResize\":null}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);
@ -939,7 +988,8 @@ public class CloudServersClientTest {
assertEquals(httpMethod.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList(MediaType.APPLICATION_JSON));
assertEquals("{\"revertResize\":null}", httpMethod.getPayload().getRawContent());
assertEquals(processor.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
assertEquals(processor
.createExceptionParserOrThrowResourceNotFoundOn404IfNoAnnotation(method).getClass(),
ReturnFalseOn404.class);
assertEquals(processor.createResponseParser(method, httpMethod).getClass(),
ReturnTrueIf2xx.class);