expect/live tests for publishCatalog

This commit is contained in:
danikov 2012-03-06 16:37:18 +00:00
parent 7704b6b8f0
commit bef1baa109
2 changed files with 41 additions and 5 deletions

View File

@ -28,6 +28,7 @@ import org.jclouds.vcloud.director.v1_5.domain.AdminCatalog;
import org.jclouds.vcloud.director.v1_5.domain.CatalogItems; import org.jclouds.vcloud.director.v1_5.domain.CatalogItems;
import org.jclouds.vcloud.director.v1_5.domain.Link; import org.jclouds.vcloud.director.v1_5.domain.Link;
import org.jclouds.vcloud.director.v1_5.domain.Owner; import org.jclouds.vcloud.director.v1_5.domain.Owner;
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorRestClientExpectTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -118,6 +119,24 @@ public class AdminCatalogClientExpectTest extends BaseVCloudDirectorRestClientEx
client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner); client.getAdminCatalogClient().setOwner(catalogRef.getURI(), newOwner);
} }
@Test
public void testPublishCatalog() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
new VcloudHttpRequestPrimer()
.apiCommand("POST", "/admin/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/action/publish")
.xmlFilePayload("/catalog/admin/publishCatalogParams.xml", VCloudDirectorMediaType.PUBLISH_CATALOG_PARAMS)
.acceptAnyMedia()
.httpRequestBuilder().build(),
new VcloudHttpResponsePrimer()
.httpResponseBuilder().statusCode(204).build());
PublishCatalogParams params = PublishCatalogParams.builder()
.isPublished(true)
.build();
client.getAdminCatalogClient().publishCatalog(catalogRef.getURI(), params);
}
@Test @Test
public void testDeleteCatalog() { public void testDeleteCatalog() {
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,

View File

@ -19,9 +19,7 @@
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.equal;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_DEL; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
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.assertEquals;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull; import static org.testng.Assert.assertNull;
@ -35,6 +33,7 @@ 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.Checks;
import org.jclouds.vcloud.director.v1_5.domain.Error; 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.Owner;
import org.jclouds.vcloud.director.v1_5.domain.PublishCatalogParams;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType; import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
@ -98,7 +97,7 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
.name("adk@cloudsoftcorp.com") .name("adk@cloudsoftcorp.com")
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9")) .href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/e9eb1b29-0404-4c5e-8ef7-e584acc51da9"))
.build()) .build())
.build(); .build();
try { try {
catalogClient.setOwner(catalog.getURI(), newOwner); catalogClient.setOwner(catalog.getURI(), newOwner);
@ -149,8 +148,26 @@ public class AdminCatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest
} }
} }
@Test(testName = "DELETE /admin/catalog/{id}", @Test(testName = "POST /admin/catalog/{id}/action/publish",
dependsOnMethods = { "testUpdateCatalog" }, enabled = false ) dependsOnMethods = { "testUpdateCatalog" }, enabled = false )
public void testPublishCatalog() {
assertTrue(!catalog.isPublished(), String.format(OBJ_FIELD_EQ,
CATALOG, "isPublished", false, catalog.isPublished()));
PublishCatalogParams params = PublishCatalogParams.builder()
.isPublished(true)
.build();
catalogClient.publishCatalog(catalogRef.getURI(), params);
catalog = catalogClient.getCatalog(catalogRef.getURI());
assertTrue(catalog.isPublished(), String.format(OBJ_FIELD_EQ,
CATALOG, "isPublished", true, catalog.isPublished()));
}
@Test(testName = "DELETE /admin/catalog/{id}",
dependsOnMethods = { "testPublishCatalog" }, enabled = false )
public void testDeleteCatalog() { public void testDeleteCatalog() {
catalogClient.deleteCatalog(catalogRef.getURI()); catalogClient.deleteCatalog(catalogRef.getURI());