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 org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.annotations.*;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
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.BindSSHKeyToXmlPayload;
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
@ -87,11 +87,10 @@ public interface SSHKeyAsyncClient {
/**
* @see SSHKeyClient#createSSHKey
* TODO Should map the 204 header to a boolean to indicate that it was sucessful
*/
@DELETE
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
public ListenableFuture<Void> deleteSSHKey(@EndpointParam URI uri);
@ExceptionParser(ReturnFalseOnNotFoundOr404.class)
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
* 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 org.jclouds.http.HttpRequest;
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.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.tmrk.enterprisecloud.domain.keys.SSHKey;
import org.testng.annotations.Test;
@ -116,8 +116,8 @@ public class SSHKeyAsyncClientTest extends BaseTerremarkEnterpriseCloudAsyncClie
assertNonPayloadHeadersEqual(httpRequest,"x-tmrk-version: 2011-07-01\n");
assertPayloadEquals(httpRequest, null, null, false);
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
assertExceptionParserClassEquals(method, ReturnFalseOnNotFoundOr404.class);
checkFilters(httpRequest);
}

View File

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