mirror of https://github.com/apache/jclouds.git
Updated Catalog expect tests
This commit is contained in:
parent
751d99c143
commit
4fdaa3b6a6
|
@ -25,16 +25,20 @@ import java.net.URI;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogsList;
|
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||||
|
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.Metadata;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
|
||||||
|
import org.jclouds.vcloud.director.v1_5.domain.MetadataValue;
|
||||||
|
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;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the {@link CatalogClient} by observing its side effects.
|
* Test the {@link CatalogClient} by observing its side effects.
|
||||||
|
@ -45,10 +49,10 @@ import com.google.common.collect.ImmutableMultimap;
|
||||||
public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCatalogListForValidOrg() {
|
public void testGetCatalog() {
|
||||||
HttpRequest catalogRequest = HttpRequest.builder()
|
HttpRequest catalogRequest = HttpRequest.builder()
|
||||||
.method("GET")
|
.method("GET")
|
||||||
.endpoint(URI.create(endpoint + "/catalogsList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
.put("Accept", "*/*")
|
.put("Accept", "*/*")
|
||||||
.put("x-vcloud-authorization", token)
|
.put("x-vcloud-authorization", token)
|
||||||
|
@ -57,221 +61,158 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
||||||
|
|
||||||
HttpResponse catalogResponse = HttpResponse.builder()
|
HttpResponse catalogResponse = HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
.payload(payloadFromResourceWithContentType("/catalog/catalogslist.xml", VCloudDirectorMediaType.CATALOGS_LIST + ";version=1.5"))
|
.payload(payloadFromResourceWithContentType("/catalog/catalog.xml", VCloudDirectorMediaType.CATALOG + ";version=1.5"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||||
|
|
||||||
CatalogsList expected = CatalogsList.builder()
|
Catalog expected = Catalog.builder()
|
||||||
.name("Catalogs Lists")
|
|
||||||
.type("application/vnd.vmware.vcloud.catalogsList+xml")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogsList/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.catalog(Catalog.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
|
||||||
.name("catalog")
|
|
||||||
.id("urn:vcloud:catalog:5fcd2af3-d0ec-45ce-9451-8c585a2c766b")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
|
||||||
.status("success")
|
|
||||||
.operation("Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)")
|
|
||||||
.operationName("catalogCreateCatalog")
|
|
||||||
.startTime(dateService.iso8601DateParse("2012-02-07T00:16:28.450-05:00"))
|
|
||||||
.endTime(dateService.iso8601DateParse("2012-02-07T00:16:28.867-05:00"))
|
|
||||||
.expiryTime(dateService.iso8601DateParse("2012-05-07T00:16:28.450-04:00"))
|
|
||||||
.owner(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
|
||||||
.name("QunyingTestCatalog")
|
.name("QunyingTestCatalog")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
|
||||||
.build())
|
|
||||||
.user(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.admin.user+xml")
|
|
||||||
.name("JClouds")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.build())
|
|
||||||
.org(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.org+xml")
|
|
||||||
.name("JClouds")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.build())
|
|
||||||
.build())
|
|
||||||
.catalog(Catalog.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
.name("catalog")
|
.id("urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4")
|
||||||
.id("urn:vcloud:catalog:bd22e745-9c2a-4f82-a954-0e35b6f76ba5")
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/bd22e745-9c2a-4f82-a954-0e35b6f76ba5"))
|
.link(Link.builder()
|
||||||
.status("success")
|
.rel("up")
|
||||||
.operation("Enabled User (967d317c-4273-4a95-b8a4-bf63b78e9c69)")
|
|
||||||
.operationName("jobEnable")
|
|
||||||
.startTime(dateService.iso8601DateParse("2012-02-06T17:30:38.507-05:00"))
|
|
||||||
.endTime(dateService.iso8601DateParse("2012-02-06T17:30:38.507-05:00"))
|
|
||||||
.expiryTime(dateService.iso8601DateParse("2012-05-06T17:30:38.507-04:00"))
|
|
||||||
.user(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.admin.user+xml")
|
|
||||||
.name("adrian@jclouds.org")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/admin/user/8c360b93-ed25-4c9a-8e24-d48cd9966d93"))
|
|
||||||
.build())
|
|
||||||
.org(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.org+xml")
|
.type("application/vnd.vmware.vcloud.org+xml")
|
||||||
.name("JClouds")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
||||||
.build())
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("add")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"))
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.link(Link.builder()
|
||||||
|
.rel("down")
|
||||||
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0")).build();
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
assertEquals(client.getCatalogClient().getCatalogList(orgRef), expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCatalogListForInvalidOrgId() {
|
|
||||||
HttpRequest catalogRequest = HttpRequest.builder()
|
|
||||||
.method("GET")
|
|
||||||
.endpoint(URI.create(endpoint + "/catalogsList/NOTAUUID"))
|
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization", token)
|
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.catalogItems(CatalogItems.builder()
|
||||||
|
.item(Reference.builder()
|
||||||
HttpResponse catalogResponse = HttpResponse.builder()
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
.statusCode(400)
|
.name("ubuntu10")
|
||||||
.payload(payloadFromResourceWithContentType("/catalog/error400.xml", VCloudDirectorMediaType.ERROR + ";version=1.5"))
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
.build();
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
|
||||||
|
|
||||||
Error expected = Error.builder()
|
|
||||||
.message("validation error on field 'id': String value has invalid format or length")
|
|
||||||
.majorErrorCode(400)
|
|
||||||
.minorErrorCode("BAD_REQUEST")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/NOTAUUID")).build();
|
|
||||||
|
|
||||||
try {
|
|
||||||
client.getCatalogClient().getCatalogList(orgRef);
|
|
||||||
fail("Should give HTTP 400 error");
|
|
||||||
} catch (VCloudDirectorException vde) {
|
|
||||||
assertEquals(vde.getError(), expected);
|
|
||||||
} catch (Exception e) {
|
|
||||||
fail("Should have thrown a VCloudDirectorException");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testCatalogListForNotFoundOrgId() {
|
|
||||||
HttpRequest catalogRequest = HttpRequest.builder()
|
|
||||||
.method("GET")
|
|
||||||
.endpoint(URI.create(endpoint + "/catalogsList/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"))
|
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization", token)
|
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.item(Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
HttpResponse catalogResponse = HttpResponse.builder()
|
.name("imageTesting")
|
||||||
.statusCode(403)
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"))
|
||||||
.payload(payloadFromResourceWithContentType("/catalog/error403.xml", VCloudDirectorMediaType.ERROR + ";version=1.5"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
|
||||||
|
|
||||||
Error expected = Error.builder()
|
|
||||||
.message("No access to entity \"com.vmware.vcloud.entity.org:aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee\".")
|
|
||||||
.majorErrorCode(403)
|
|
||||||
.minorErrorCode("ACCESS_TO_RESOURCE_IS_FORBIDDEN")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Reference orgRef = Reference.builder().href(URI.create("https://vcloudbeta.bluelock.com/api/org/aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")).build();
|
|
||||||
|
|
||||||
try {
|
|
||||||
client.getCatalogClient().getCatalogList(orgRef);
|
|
||||||
fail("Should give HTTP 400 error");
|
|
||||||
} catch (VCloudDirectorException vde) {
|
|
||||||
assertEquals(vde.getError(), expected);
|
|
||||||
} catch (Exception e) {
|
|
||||||
fail("Should have thrown a VCloudDirectorException");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGetCatalogForCatalogRef() {
|
|
||||||
HttpRequest catalogRequest = HttpRequest.builder()
|
|
||||||
.method("GET")
|
|
||||||
.endpoint(URI.create(endpoint + "/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
|
||||||
.put("Accept", "*/*")
|
|
||||||
.put("x-vcloud-authorization", token)
|
|
||||||
.build())
|
.build())
|
||||||
|
.build())
|
||||||
|
.description("Testing")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse catalogResponse = HttpResponse.builder()
|
|
||||||
.statusCode(200)
|
|
||||||
.payload(payloadFromResourceWithContentType("/catalog/catalog.xml", VCloudDirectorMediaType.catalog + ";version=1.5"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
|
||||||
|
|
||||||
Reference catalogRef = Reference.builder()
|
Reference catalogRef = Reference.builder()
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
|
||||||
.name("catalog")
|
|
||||||
.href(URI.create(endpoint + "/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Catalog expected = Catalog.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
|
||||||
.name("catalog")
|
|
||||||
.id("urn:vcloud:catalog:5fcd2af3-d0ec-45ce-9451-8c585a2c766b")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
|
||||||
.status("success")
|
|
||||||
.operation("Created Catalog QunyingTestCatalog(7212e451-76e1-4631-b2de-ba1dfd8080e4)")
|
|
||||||
.operationName("catalogCreateCatalog")
|
|
||||||
.startTime(dateService.iso8601DateParse("2012-02-07T00:16:28.450-05:00"))
|
|
||||||
.endTime(dateService.iso8601DateParse("2012-02-07T00:16:28.867-05:00"))
|
|
||||||
.expiryTime(dateService.iso8601DateParse("2012-05-07T00:16:28.450-04:00"))
|
|
||||||
.owner(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
.name("QunyingTestCatalog")
|
.name("QunyingTestCatalog")
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
.build())
|
|
||||||
.user(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.admin.user+xml")
|
|
||||||
.name("JClouds")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.build())
|
|
||||||
.org(Reference.builder()
|
|
||||||
.type("application/vnd.vmware.vcloud.org+xml")
|
|
||||||
.name("JClouds")
|
|
||||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"))
|
|
||||||
.build())
|
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
assertEquals(client.getCatalogClient().getCatalog(catalogRef), expected);
|
assertEquals(client.getCatalogClient().getCatalog(catalogRef), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCancelCatalogByCatalogRef() {
|
public void testAddCatalogItem() {
|
||||||
HttpRequest catalogRequest = HttpRequest.builder()
|
HttpRequest catalogItemRequest = HttpRequest.builder()
|
||||||
.method("POST")
|
.method("POST")
|
||||||
.endpoint(URI.create(endpoint + "/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b/action/cancel"))
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"))
|
||||||
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
|
.put("Accept", "application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.put("x-vcloud-authorization", token)
|
||||||
|
.build())
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/newCatalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
HttpResponse catalogItemResponse = HttpResponse.builder()
|
||||||
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/catalogItem.xml", VCloudDirectorMediaType.CATALOG_ITEM + ";version=1.5"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||||
|
|
||||||
|
Reference catalogRef = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.name("QunyingTestCatalog")
|
||||||
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Reference ubuntu = Reference.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.vAppTemplate+xml")
|
||||||
|
.name("ubuntu10")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
CatalogItem newItem = CatalogItem.builder()
|
||||||
|
.name("newCatalogItem")
|
||||||
|
.description("New Catalog Item")
|
||||||
|
.entity(ubuntu)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
CatalogItem expected = CatalogItem.builder()
|
||||||
|
.name("newCatalogItem")
|
||||||
|
.id("urn:vcloud:catalogitem:a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("down")
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("edit")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalogItem+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("remove")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||||
|
.build())
|
||||||
|
.description("New Catalog Item")
|
||||||
|
.entity(ubuntu)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().addCatalogItem(catalogRef, newItem), expected);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetCatalogMetadata() {
|
||||||
|
HttpRequest catalogItemRequest = HttpRequest.builder()
|
||||||
|
.method("GET")
|
||||||
|
.endpoint(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
.headers(ImmutableMultimap.<String, String> builder()
|
.headers(ImmutableMultimap.<String, String> builder()
|
||||||
.put("Accept", "*/*")
|
.put("Accept", "*/*")
|
||||||
.put("x-vcloud-authorization", token)
|
.put("x-vcloud-authorization", token)
|
||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
HttpResponse catalogResponse = HttpResponse.builder()
|
HttpResponse catalogItemResponse = HttpResponse.builder()
|
||||||
.statusCode(200)
|
.statusCode(200)
|
||||||
|
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadata.xml", VCloudDirectorMediaType.METADATA + ";version=1.5"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||||
|
|
||||||
Reference catalogRef = Reference.builder()
|
Reference catalogRef = Reference.builder()
|
||||||
.type("application/vnd.vmware.vcloud.catalog+xml")
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
.name("catalog")
|
.name("QunyingTestCatalog")
|
||||||
.href(URI.create(endpoint + "/catalog/5fcd2af3-d0ec-45ce-9451-8c585a2c766b"))
|
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
client.getCatalogClient().cancelCatalog(catalogRef);
|
Metadata expected = Metadata.builder()
|
||||||
|
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api//catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||||
|
.link(Link.builder()
|
||||||
|
.rel("up")
|
||||||
|
.type("application/vnd.vmware.vcloud.catalog+xml")
|
||||||
|
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||||
|
.build())
|
||||||
|
.metadata(ImmutableSet.of(MetadataEntry.builder().entry("key", "value").build()))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertEquals(client.getCatalogClient().getCatalogMetadata(catalogRef), expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Catalog xmlns="http://www.vmware.com/vcloud/v1.5" name="QunyingTestCatalog" id="urn:vcloud:catalog:7212e451-76e1-4631-b2de-ba1dfd8080e4" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0"/>
|
||||||
|
<Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/catalogItems"/>
|
||||||
|
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"/>
|
||||||
|
<Description>Testing</Description>
|
||||||
|
<CatalogItems>
|
||||||
|
<CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<CatalogItem type="application/vnd.vmware.vcloud.catalogItem+xml" name="imageTesting" href="https://vcloudbeta.bluelock.com/api/catalogItem/a9e0afdb-a42b-4688-8409-2ac68cf22939"/>
|
||||||
|
</CatalogItems>
|
||||||
|
<IsPublished>false</IsPublished>
|
||||||
|
</Catalog>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<CatalogItem xmlns="http://www.vmware.com/vcloud/v1.5" name="newCatalogItem" id="urn:vcloud:catalogitem:a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
|
||||||
|
<Link rel="down" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"/>
|
||||||
|
<Link rel="edit" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<Link rel="remove" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"/>
|
||||||
|
<Description>New Catalog Item</Description>
|
||||||
|
<Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"/>
|
||||||
|
</CatalogItem>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Metadata xmlns="http://www.vmware.com/vcloud/v1.5" type="application/vnd.vmware.vcloud.metadata+xml" href="https://vcloudbeta.bluelock.com/api//catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd">
|
||||||
|
<Link rel="up" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"/>
|
||||||
|
<MetadataEntry>
|
||||||
|
<Key>key</Key>
|
||||||
|
<Value>value</Value>
|
||||||
|
</MetadataEntry>
|
||||||
|
</Metadata>
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<CatalogItem name="newCatalogItem" xmlns="http://www.vmware.com/vcloud/v1.5">
|
||||||
|
<Description>New Catalog Item</Description>
|
||||||
|
<Entity type="application/vnd.vmware.vcloud.vAppTemplate+xml" name="ubuntu10" href="https://vcloudbeta.bluelock.com/api/vAppTemplate/vappTemplate-ef4415e6-d413-4cbb-9262-f9bbec5f2ea9"/>
|
||||||
|
</CatalogItem>
|
Loading…
Reference in New Issue