mirror of https://github.com/apache/jclouds.git
Merge pull request #401 from danikov/vclouds-director-admin-catalog-4
Issue 830: vCloud director Admin Catalog (deleteCatalog)
This commit is contained in:
commit
969c5132eb
|
@ -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 javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -67,6 +68,15 @@ public interface AdminCatalogAsyncClient {
|
|||
ListenableFuture<AdminCatalog> updateCatalog(@EndpointParam URI catalogRef,
|
||||
@BinderParam(BindToXMLPayload.class) AdminCatalog catalog);
|
||||
|
||||
/**
|
||||
* @see AdminClient#deleteCatalog(URI)
|
||||
*/
|
||||
@DELETE
|
||||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Void> deleteCatalog(@EndpointParam URI catalogRef);
|
||||
|
||||
/**
|
||||
* @see AdminClient#getOwner(URI)
|
||||
*/
|
||||
|
|
|
@ -58,6 +58,15 @@ public interface AdminCatalogClient {
|
|||
*/
|
||||
AdminCatalog updateCatalog(URI catalogRef, AdminCatalog catalog);
|
||||
|
||||
/**
|
||||
* Deletes a catalog. The catalog could be deleted if it is either published or unpublished.
|
||||
*
|
||||
* <pre>
|
||||
* DELETE /admin/catalog/{id}
|
||||
* </pre>
|
||||
*/
|
||||
void deleteCatalog(URI catalogRef);
|
||||
|
||||
/**
|
||||
* Retrieves the owner of a catalog.
|
||||
*
|
||||
|
|
|
@ -118,6 +118,19 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
|
|||
client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDeleteCatalog() {
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
new VcloudHttpRequestPrimer()
|
||||
.apiCommand("DELETE", "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4")
|
||||
.acceptAnyMedia()
|
||||
.httpRequestBuilder().build(),
|
||||
new VcloudHttpResponsePrimer()
|
||||
.httpResponseBuilder().statusCode(204).build());
|
||||
|
||||
client.getAdminCatalogClient().deleteCatalog(catalogRef.getURI());
|
||||
}
|
||||
|
||||
public static final AdminCatalog catalog() {
|
||||
return AdminCatalog.builder()
|
||||
.name("QunyingTestCatalog")
|
||||
|
|
|
@ -19,18 +19,21 @@
|
|||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.GETTER_RETURNS_SAME_OBJ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Checks;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Owner;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
@ -145,4 +148,30 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
|
|||
catalog = catalogClient.updateCatalog(catalog.getURI(), catalog);
|
||||
}
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /admin/catalog/{id}",
|
||||
dependsOnMethods = { "testUpdateCatalog" }, enabled = false )
|
||||
public void testDeleteCatalog() {
|
||||
catalogClient.deleteCatalog(catalogRef.getURI());
|
||||
|
||||
Error expected = Error.builder()
|
||||
.message("???")
|
||||
.majorErrorCode(403)
|
||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
||||
.build();
|
||||
|
||||
try {
|
||||
catalog = catalogClient.getCatalog(catalogRef.getURI());
|
||||
fail("Should give HTTP 403 error");
|
||||
} catch (VCloudDirectorException vde) {
|
||||
assertEquals(vde.getError(), expected);
|
||||
catalog = null;
|
||||
} catch (Exception e) {
|
||||
fail("Should have thrown a VCloudDirectorException");
|
||||
}
|
||||
|
||||
if (catalog != null) { // guard against NPE on the .toStrings
|
||||
assertNull(catalog, String.format(OBJ_DEL, CATALOG, catalog.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue