Issue 695: Converted deleteSSHKey to return boolean instead of void when 2xx return code

This commit is contained in:
Jason King 2011-12-14 20:45:32 +00:00
parent e71728d82c
commit 831e35ecbc
4 changed files with 14 additions and 11 deletions

View File

@ -21,8 +21,8 @@ package org.jclouds.tmrk.enterprisecloud.features;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.*; import org.jclouds.rest.annotations.*;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.tmrk.enterprisecloud.binders.BindCreateSSHKeyToXmlPayload; import org.jclouds.tmrk.enterprisecloud.binders.BindCreateSSHKeyToXmlPayload;
import org.jclouds.tmrk.enterprisecloud.binders.BindSSHKeyToXmlPayload; import org.jclouds.tmrk.enterprisecloud.binders.BindSSHKeyToXmlPayload;
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey; import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
@ -87,11 +87,10 @@ public interface SSHKeyAsyncClient {
/** /**
* @see SSHKeyClient#createSSHKey * @see SSHKeyClient#createSSHKey
* TODO Should map the 204 header to a boolean to indicate that it was sucessful
*/ */
@DELETE @DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class) @ExceptionParser(ReturnFalseOnNotFoundOr404.class)
public ListenableFuture<Void> deleteSSHKey(@EndpointParam URI uri); public ListenableFuture<Boolean> deleteSSHKey(@EndpointParam URI uri);
} }

View File

@ -94,6 +94,6 @@ public interface SSHKeyClient {
* @param uri the uri of the ssk key to delete * @param uri the uri of the ssk key to delete
* e.g. /cloudapi/ecloud/admin/sshkeys/77 * e.g. /cloudapi/ecloud/admin/sshkeys/77
*/ */
public void deleteSSHKey(URI uri); public boolean deleteSSHKey(URI uri);
} }

View File

@ -21,9 +21,9 @@ package org.jclouds.tmrk.enterprisecloud.features;
import com.google.inject.TypeLiteral; import com.google.inject.TypeLiteral;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseXMLWithJAXB; import org.jclouds.http.functions.ParseXMLWithJAXB;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey; import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -116,8 +116,8 @@ public class SSHKeyAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClie
assertNonPayloadHeadersEqual(httpRequest,"x-tmrk-version: 2011-07-01\n"); assertNonPayloadHeadersEqual(httpRequest,"x-tmrk-version: 2011-07-01\n");
assertPayloadEquals(httpRequest, null, null, false); assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class); assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class); assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
checkFilters(httpRequest); checkFilters(httpRequest);
} }

View File

@ -63,7 +63,7 @@ public class SSHKeyClientLiveTest extends BaseTerremarkEnterpriseCloudClientLive
assertFalse(sshKey.isDefaultKey()); assertFalse(sshKey.isDefaultKey());
assertFalse(sshKey.getFingerPrint().isEmpty()); assertFalse(sshKey.getFingerPrint().isEmpty());
assertFalse(sshKey.getPrivateKey().isEmpty()); assertFalse(sshKey.getPrivateKey().isEmpty());
client.deleteSSHKey(sshKey.getHref()); assertTrue(client.deleteSSHKey(sshKey.getHref()));
assertNull(client.getSSHKey(sshKey.getHref())); assertNull(client.getSSHKey(sshKey.getHref()));
} }
@ -76,7 +76,11 @@ public class SSHKeyClientLiveTest extends BaseTerremarkEnterpriseCloudClientLive
SSHKey result = client.getSSHKey(sshKey.getHref()); SSHKey result = client.getSSHKey(sshKey.getHref());
assertEquals(result.getName(),"editedname"); assertEquals(result.getName(),"editedname");
client.deleteSSHKey(sshKey.getHref()); assertTrue(client.deleteSSHKey(sshKey.getHref()));
assertNull(client.getSSHKey(sshKey.getHref())); assertNull(client.getSSHKey(sshKey.getHref()));
} }
public void testDeleteWhenNoKey() {
assertFalse(client.deleteSSHKey(URI.create("/cloudapi/ecloud/admin/sshkeys/-1")));
}
} }