mirror of https://github.com/apache/jclouds.git
deleteGroup with tests
This commit is contained in:
parent
3f8f28f0f9
commit
7b635ddf77
|
@ -21,6 +21,7 @@ package org.jclouds.vcloud.director.v1_5.features;
|
|||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
|
||||
import org.jclouds.rest.annotations.EndpointParam;
|
||||
|
@ -33,12 +34,12 @@ import org.jclouds.vcloud.director.v1_5.functions.ThrowVCloudErrorOn4xx;
|
|||
|
||||
import com.google.common.util.concurrent.ListenableFuture;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @see GroupClient
|
||||
* @author danikov
|
||||
*/
|
||||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
public interface GroupAsyncClient {
|
||||
@RequestFilters(AddVCloudAuthorizationToRequest.class)
|
||||
public interface GroupAsyncClient {
|
||||
|
||||
/**
|
||||
* @see GroupClient#getGroup(URI)
|
||||
|
@ -49,4 +50,12 @@ public interface GroupAsyncClient {
|
|||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Group> getGroup(@EndpointParam URI groupUri);
|
||||
|
||||
/**
|
||||
* @see GroupClient#deleteGroup(URI)
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Void> deleteGroup(@EndpointParam URI groupRef);
|
||||
}
|
||||
|
|
|
@ -45,4 +45,12 @@ public interface GroupClient {
|
|||
*/
|
||||
Group getGroup(URI groupUri);
|
||||
|
||||
/**
|
||||
* Deletes a group.
|
||||
*
|
||||
* <pre>
|
||||
* DELETE /admin/group/{id}
|
||||
* </pre>
|
||||
*/
|
||||
void deleteGroup(URI groupRef);
|
||||
}
|
||||
|
|
|
@ -64,4 +64,17 @@ public class GroupClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
|
||||
.build();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteGroup() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("DELETE", "/admin/group/???")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.httpResponseBuilder().statusCode(204).build());
|
||||
|
||||
client.getAdminCatalogClient().deleteCatalog(groupRef.getURI());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,9 +21,16 @@ package org.jclouds.vcloud.director.v1_5.features;
|
|||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Group;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
@ -57,7 +64,7 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void setupRequiredClients() {
|
||||
groupClient = context.getApi().getGroupClient();
|
||||
groupRef = Reference.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/catalog/???"))
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/group/???"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -68,4 +75,29 @@ public class GroupClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
Checks.checkGroup(group);
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /admin/group/{id}", enabled = false )
|
||||
public void testDeleteCatalog() {
|
||||
groupClient.deleteGroup(groupRef.getURI());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("???")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
|
||||
try {
|
||||
group = groupClient.getGroup(groupRef.getURI());
|
||||
fail("Should give HTTP 403 error");
|
||||
} catch (VCloudDirectorException vde) {
|
||||
assertEquals(vde.getError(), expected);
|
||||
group = null;
|
||||
} catch (Exception e) {
|
||||
fail("Should have thrown a VCloudDirectorException");
|
||||
}
|
||||
|
||||
if (group != null) { // guard against NPE on the .toStrings
|
||||
assertNull(group, String.format(OBJ_DEL, GROUP, group.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue