mirror of https://github.com/apache/jclouds.git
Updates and fixes for existing clients, domain objects and tests, including:
- Changed MetadataEntry to MetadataValue where required - Added more standardised assertion/error check messages - Completed CatalogClientLiveTest
This commit is contained in:
parent
973ef7e167
commit
d8390da9b4
|
@ -46,8 +46,8 @@ public class Link extends ReferenceType<Link> {
|
|||
public static final String UP = "up";
|
||||
public static final String DOWN = "down";
|
||||
public static final String EDIT = "edit";
|
||||
public static final String DELETE = "delete";
|
||||
public static final String ADD = "add";
|
||||
public static final String DELETE = "delete";
|
||||
public static final String REMOVE = "remove";
|
||||
public static final String CATALOG_ITEM = "catalogItem";
|
||||
public static final String TASK_CANCEL = "task:cancel";
|
||||
|
@ -58,7 +58,7 @@ public class Link extends ReferenceType<Link> {
|
|||
public static final String FIRST_PAGE = "firstPage";
|
||||
|
||||
public static final List<String> ALL = Arrays.asList(
|
||||
UP, DOWN, EDIT, DELETE, ADD, REMOVE, CATALOG_ITEM, TASK_CANCEL,
|
||||
UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL,
|
||||
ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE
|
||||
);
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ public class QueryResultReferences<T extends ReferenceType<T>> extends Container
|
|||
@XmlElementRefs({
|
||||
@XmlElementRef(type = CatalogReference.class)
|
||||
})
|
||||
protected List<T> references;
|
||||
protected List<T> references = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Set of references representing query results.
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||
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.ReferenceType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
|
@ -93,7 +92,7 @@ public interface CatalogAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<MetadataEntry> getCatalogMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
|
||||
ListenableFuture<MetadataValue> getCatalogMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogRef,
|
||||
@PathParam("key") String key);
|
||||
|
||||
/**
|
||||
|
@ -155,7 +154,7 @@ public interface CatalogAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<MetadataEntry> getCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
ListenableFuture<MetadataValue> getCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
@PathParam("key") String key);
|
||||
|
||||
/**
|
||||
|
@ -167,7 +166,7 @@ public interface CatalogAsyncClient {
|
|||
@Produces(VCloudDirectorMediaType.METADATA_VALUE)
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Task> setCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
ListenableFuture<Task> setCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
@PathParam("key") String key, @BinderParam(BindToXMLPayload.class) MetadataValue metadataValue);
|
||||
|
||||
/**
|
||||
|
@ -178,6 +177,6 @@ public interface CatalogAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<Task> deleteCatalogItemMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
ListenableFuture<Task> deleteCatalogItemMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> catalogItemRef,
|
||||
@PathParam("key") String key);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.jclouds.concurrent.Timeout;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||
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.ReferenceType;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Task;
|
||||
|
@ -84,9 +83,9 @@ public interface CatalogClient {
|
|||
*
|
||||
* @param catalogRef the reference for the catalog
|
||||
* @param key the metadata entry key
|
||||
* @return the catalog metadata entry
|
||||
* @return the catalog metadata value
|
||||
*/
|
||||
MetadataEntry getCatalogMetadataEntry(ReferenceType<?> catalogRef, String key);
|
||||
MetadataValue getCatalogMetadataValue(ReferenceType<?> catalogRef, String key);
|
||||
|
||||
/**
|
||||
* Retrieves a catalog item.
|
||||
|
@ -158,9 +157,9 @@ public interface CatalogClient {
|
|||
*
|
||||
* @param catalogItemRef the reference for the catalog item
|
||||
* @param key the metadata entry key
|
||||
* @return the catalog item metadata entry
|
||||
* @return the catalog item metadata value
|
||||
*/
|
||||
MetadataEntry getCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key);
|
||||
MetadataValue getCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key);
|
||||
|
||||
/**
|
||||
* Sets the metadata for the particular key for the catalog item to the value provided.
|
||||
|
@ -174,7 +173,7 @@ public interface CatalogClient {
|
|||
* @param value the metadata value
|
||||
* @return a task for the set operation
|
||||
*/
|
||||
Task setCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key, MetadataValue value);
|
||||
Task setCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key, MetadataValue value);
|
||||
|
||||
/**
|
||||
* Deletes the metadata for the particular key for the catalog item.
|
||||
|
@ -187,5 +186,5 @@ public interface CatalogClient {
|
|||
* @param key the metadata entry key
|
||||
* @return a task for the delete operation
|
||||
*/
|
||||
Task deleteCatalogItemMetadataEntry(ReferenceType<?> catalogItemRef, String key);
|
||||
Task deleteCatalogItemMetadataValue(ReferenceType<?> catalogItemRef, String key);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.jclouds.rest.annotations.ExceptionParser;
|
|||
import org.jclouds.rest.annotations.JAXBResponseParser;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
@ -81,6 +81,6 @@ public interface OrgAsyncClient {
|
|||
@Consumes
|
||||
@JAXBResponseParser
|
||||
@ExceptionParser(ThrowVCloudErrorOn4xx.class)
|
||||
ListenableFuture<MetadataEntry> getOrgMetadataEntry(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef,
|
||||
ListenableFuture<MetadataValue> getOrgMetadataValue(@EndpointParam(parser = ReferenceToEndpoint.class) ReferenceType<?> orgRef,
|
||||
@PathParam("key") String key);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
|
||||
|
@ -58,7 +58,6 @@ public interface OrgClient {
|
|||
* @return the org or null if not found
|
||||
*/
|
||||
Org getOrg(ReferenceType<?> orgRef);
|
||||
// FIXME throws exception on not found currently
|
||||
|
||||
/**
|
||||
* Retrieves an list of the organization's metadata
|
||||
|
@ -80,6 +79,5 @@ public interface OrgClient {
|
|||
*
|
||||
* @return the metadata entry or null if not found
|
||||
*/
|
||||
MetadataEntry getOrgMetadataEntry(ReferenceType<?> orgRef, String key);
|
||||
// FIXME throws exception on not found currently
|
||||
MetadataValue getOrgMetadataValue(ReferenceType<?> orgRef, String key);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,22 @@ public class VCloudDirectorLiveTestConstants {
|
|||
public static final String TASK_COMPLETE_TIMELY = "Task %s should complete in a timely fashion";
|
||||
|
||||
@Deprecated
|
||||
public static final String FIELD_NOT_NULL_FMT = "The %s field of the %s must not be null";
|
||||
public static final String NOT_NULL_OBJECT_FMT = "The %s field of the %s must not be null";
|
||||
|
||||
public static final String NOT_EMPTY_OBJECT_FMT = "One or more %s fields of the %s must be present";
|
||||
|
||||
public static final String REQUIRED_VALUE_OBJECT_FMT = "The %s field of the %s must not be '%s'";
|
||||
|
||||
public static final String REQUIRED_VALUE_FMT = "The %s field must not be '%s'";
|
||||
|
||||
public static final String MUST_BE_WELL_FORMED_FMT = "The %s field must be well formed: '%s'";
|
||||
|
||||
public static final String MUST_EXIST_FMT = "The '%s' %s must exist";
|
||||
|
||||
public static final String MUST_CONTAIN_FMT = "The %s field must contain '%s': '%s'";
|
||||
|
||||
public static final String CONDITION_FMT = "The %s field must be %s: '%s'";
|
||||
|
||||
public static final String CORRECT_VALUE_OBJECT_FMT = "The %s field of the %s must be '%s': '%s'";
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.domain;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
@ -51,7 +53,7 @@ public class Checks {
|
|||
|
||||
public static void checkEntityType(EntityType<?> entity) {
|
||||
// Check required fields
|
||||
assertNotNull(entity.getName(), "The Name attribute of an EntityType must be set");
|
||||
assertNotNull(entity.getName(), String.format(NOT_NULL_OBJECT_FMT, "Name", "EntityType"));
|
||||
|
||||
// Check optional fields
|
||||
// NOTE description cannot be checked
|
||||
|
@ -66,7 +68,7 @@ public class Checks {
|
|||
|
||||
public static void checkReferenceType(ReferenceType<?> reference) {
|
||||
// Check required fields
|
||||
assertNotNull(reference.getHref(), "The Href attribute of a ReferenceType must be set");
|
||||
assertNotNull(reference.getHref(), String.format(NOT_NULL_OBJECT_FMT, "Href", "ReferenceType"));
|
||||
|
||||
// Check optional fields
|
||||
String id = reference.getId();
|
||||
|
@ -90,21 +92,18 @@ public class Checks {
|
|||
|
||||
public static void checkId(String id) {
|
||||
Iterable<String> parts = Splitter.on(':').split(id);
|
||||
assertEquals(Iterables.size(parts), 4, "The Id must be well formed");
|
||||
assertEquals(Iterables.get(parts, 0), "urn", "The Id must start with 'urn'");
|
||||
assertEquals(Iterables.get(parts, 1), "vcloud", "The Id must include 'vcloud'");
|
||||
assertEquals(Iterables.size(parts), 4, String.format(MUST_BE_WELL_FORMED_FMT, "Id", id));
|
||||
assertEquals(Iterables.get(parts, 0), "urn", String.format(MUST_CONTAIN_FMT, "Id", "urn", id));
|
||||
assertEquals(Iterables.get(parts, 1), "vcloud", String.format(MUST_CONTAIN_FMT, "Id", "vcloud", id));
|
||||
try {
|
||||
UUID uuid = UUID.fromString(Iterables.get(parts, 3));
|
||||
assertNotNull(uuid, "The UUID part of an Id must be well formed");
|
||||
UUID.fromString(Iterables.get(parts, 3));
|
||||
} catch (IllegalArgumentException iae) {
|
||||
fail("The UUID part of an Id must be well formed");
|
||||
fail(String.format(MUST_BE_WELL_FORMED_FMT, "Id", id));
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkType(String type) {
|
||||
assertTrue(VCloudDirectorMediaType.ALL.contains(type),
|
||||
String.format("The Type (%s) must be a valid media type - %s", type,
|
||||
Iterables.toString(VCloudDirectorMediaType.ALL)));
|
||||
assertTrue(VCloudDirectorMediaType.ALL.contains(type), String.format(REQUIRED_VALUE_FMT, "Type", type, Iterables.toString(VCloudDirectorMediaType.ALL)));
|
||||
}
|
||||
|
||||
// NOTE this does not currently check anything
|
||||
|
@ -120,10 +119,8 @@ public class Checks {
|
|||
|
||||
public static void checkLink(Link link) {
|
||||
// Check required fields
|
||||
assertNotNull(link.getRel(), "The Rel attribute of a Link must be set");
|
||||
// XXX choose one
|
||||
assertTrue(Link.Rel.ALL.contains(link.getRel()), String.format("The Rel attribute of a Link must be from the allowed list: %s", Iterables.toString(Link.Rel.ALL)));
|
||||
assertTrue(Link.Rel.ALL.contains(link.getRel()), String.format("The Rel attribute of a Link cannot be '%s'", link.getRel()));
|
||||
assertNotNull(link.getRel(), String.format(NOT_NULL_OBJECT_FMT, "Rel", "Link"));
|
||||
assertTrue(Link.Rel.ALL.contains(link.getRel()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Rel", "Link", link.getRel(), Iterables.toString(Link.Rel.ALL)));
|
||||
|
||||
// Check parent type
|
||||
checkReferenceType(link);
|
||||
|
@ -131,10 +128,8 @@ public class Checks {
|
|||
|
||||
public static void checkTask(Task task) {
|
||||
// Check required fields
|
||||
assertNotNull(task.getStatus(), "The Status attribute of a Task must be set");
|
||||
// XXX choose one
|
||||
assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format("The Status of a Task must be from the allowed list: %s", Iterables.toString(Task.Status.ALL)));
|
||||
assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format("The Status of a Task cannot be '%s'", task.getStatus()));
|
||||
assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJECT_FMT, "Status", "Task"));
|
||||
assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Status", "Task", task.getStatus(), Iterables.toString(Link.Rel.ALL)));
|
||||
|
||||
// Check optional fields
|
||||
// NOTE operation cannot be checked
|
||||
|
@ -177,7 +172,9 @@ public class Checks {
|
|||
public static void checkMetadata(Metadata metadata) {
|
||||
Set<MetadataEntry> metadataEntries = metadata.getMetadataEntries();
|
||||
if (metadataEntries != null && !metadataEntries.isEmpty()) {
|
||||
for (MetadataEntry metadataEntry : metadataEntries) checkMetadataEntry(metadataEntry);
|
||||
for (MetadataEntry metadataEntry : metadataEntries) {
|
||||
checkMetadataEntry(metadataEntry);
|
||||
}
|
||||
}
|
||||
|
||||
// Check parent type
|
||||
|
@ -185,27 +182,43 @@ public class Checks {
|
|||
}
|
||||
|
||||
public static void checkMetadataEntry(MetadataEntry metadataEntry) {+ // Check required fields
|
||||
assertNotNull(metadataEntry.getKey(), "The Key attribute of a MetadataEntry must be set");
|
||||
assertNotNull(metadataEntry.getValue(), "The Value attribute of a MetadataEntry must be set");
|
||||
assertNotNull(metadataEntry.getKey(), String.format(NOT_NULL_OBJECT_FMT, "Key", "MetadataEntry"));
|
||||
assertNotNull(metadataEntry.getValue(), String.format(NOT_NULL_OBJECT_FMT, "Value", "MetadataEntry"));
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(metadataEntry);
|
||||
}
|
||||
|
||||
public static void checkMetadataValue(MetadataValue metadataValue) {
|
||||
// Check required elements and attributes
|
||||
assertNotNull(metadataValue.getValue(), String.format(NOT_NULL_OBJECT_FMT, "Value", "MetadataValue"));
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(metadataValue);
|
||||
}
|
||||
|
||||
public static void checkProgress(Integer progress) {
|
||||
assertTrue(progress >= 0 && progress <= 100, "The Progress attribute must be between 0 and 100");
|
||||
assertTrue(progress >= 0 && progress <= 100, String.format(CONDITION_FMT, "Progress", "between 0 and 100", Integer.toString(progress)));
|
||||
}
|
||||
|
||||
public static void checkError(Error error) {
|
||||
// Check required fields
|
||||
assertNotNull(error.getMessage(), "The Message attribute of an Error must be set");
|
||||
assertNotNull(error.getMajorErrorCode(), "The MajorErrorCode attribute of an Error must be set");
|
||||
assertNotNull(error.getMinorErrorCode(), "The MinorErrorCode attribute of an Error must be set");
|
||||
assertNotNull(error.getMessage(), String.format(NOT_NULL_OBJECT_FMT, "Message", "Error"));
|
||||
assertNotNull(error.getMajorErrorCode(), String.format(NOT_NULL_OBJECT_FMT, "MajorErrorCode", "Error"));
|
||||
assertNotNull(error.getMinorErrorCode(), String.format(NOT_NULL_OBJECT_FMT, "MinorErrorCode", "Error"));
|
||||
|
||||
// NOTE vendorSpecificErrorCode cannot be checked
|
||||
// NOTE stackTrace cannot be checked
|
||||
}
|
||||
|
||||
public static void checkOrg(Org org) {
|
||||
// Check required elements and attributes
|
||||
assertNotNull(org.getFullName(), String.format(NOT_NULL_OBJECT_FMT, "FullName", "Org"));
|
||||
|
||||
// Check parent type
|
||||
checkEntityType(org);
|
||||
}
|
||||
|
||||
public static void checkCatalog(Catalog catalog) {
|
||||
// Check optional elements/attributes
|
||||
Entity owner = catalog.getOwner();
|
||||
|
|
|
@ -165,7 +165,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
|
||||
HttpResponse catalogResponse = HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY))
|
||||
.payload(payloadFromResourceWithContentType("/catalog/catalogMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE))
|
||||
.build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogRequest, catalogResponse);
|
||||
|
@ -176,9 +176,9 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.href(URI.create(endpoint + "/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4"))
|
||||
.build();
|
||||
|
||||
MetadataEntry expected = metadataEntry();
|
||||
MetadataValue expected = metadataValue();
|
||||
|
||||
assertEquals(client.getCatalogClient().getCatalogMetadataEntry(catalogRef, "KEY"), expected);
|
||||
assertEquals(client.getCatalogClient().getCatalogMetadataValue(catalogRef, "KEY"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -349,7 +349,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
|
||||
HttpResponse catalogItemResponse = HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.payload(payloadFromResourceWithContentType("/catalog/catalogItemMetadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY + ";version=1.5"))
|
||||
.payload(payloadFromResourceWithContentType("/catalog/catalogItemMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE + ";version=1.5"))
|
||||
.build();
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse, catalogItemRequest, catalogItemResponse);
|
||||
|
@ -360,9 +360,9 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df"))
|
||||
.build();
|
||||
|
||||
MetadataEntry expected = itemMetadataEntry();
|
||||
MetadataValue expected = itemMetadataValue();
|
||||
|
||||
assertEquals(client.getCatalogClient().getCatalogItemMetadataEntry(catalogItemReference, "KEY"), expected);
|
||||
assertEquals(client.getCatalogClient().getCatalogItemMetadataValue(catalogItemReference, "KEY"), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -394,7 +394,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
|
||||
Task expected = setMetadataValueTask();
|
||||
|
||||
assertEquals(client.getCatalogClient().setCatalogItemMetadataEntry(catalogItemReference, "KEY", value), expected);
|
||||
assertEquals(client.getCatalogClient().setCatalogItemMetadataValue(catalogItemReference, "KEY", value), expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -423,7 +423,7 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
|
||||
Task expected = deleteMetadataEntryTask();
|
||||
|
||||
assertEquals(client.getCatalogClient().deleteCatalogItemMetadataEntry(catalogItemReference, "KEY"), expected);
|
||||
assertEquals(client.getCatalogClient().deleteCatalogItemMetadataValue(catalogItemReference, "KEY"), expected);
|
||||
}
|
||||
|
||||
public static final Catalog catalog() {
|
||||
|
@ -525,6 +525,30 @@ public class CatalogClientExpectTest extends BaseVCloudDirectorRestClientExpectT
|
|||
.build();
|
||||
}
|
||||
|
||||
public static MetadataValue metadataValue() {
|
||||
return MetadataValue.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata/KEY"))
|
||||
.link(Link.builder()
|
||||
.rel("up")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"))
|
||||
.build())
|
||||
.value("VALUE")
|
||||
.build();
|
||||
}
|
||||
|
||||
public static MetadataValue itemMetadataValue() {
|
||||
return MetadataValue.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY"))
|
||||
.link(Link.builder()
|
||||
.rel("up")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"))
|
||||
.build())
|
||||
.value("VALUE")
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CatalogItem catalogItem() {
|
||||
return CatalogItem.builder()
|
||||
.name("ubuntu10")
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
import org.jclouds.predicates.RetryablePredicate;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Catalog;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.CatalogItem;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Error;
|
||||
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;
|
||||
|
@ -37,7 +38,6 @@ import org.testng.annotations.BeforeGroups;
|
|||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
|
@ -45,11 +45,9 @@ import com.google.common.collect.Iterables;
|
|||
*
|
||||
* @author grkvlt@apache.org
|
||||
*/
|
||||
@Test(groups = { "live", "apitests" }, testName = "CatalogClientLiveTest")
|
||||
@Test(groups = { "live", "apitests" }, testName = "CatalogClientLiveTest", singleThreaded = true)
|
||||
public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
||||
|
||||
private static final String CATALOG_NAME = "QunyingTestCatalog"; // TODO add as test configuration property
|
||||
|
||||
/*
|
||||
* Convenience references to API clients.
|
||||
*/
|
||||
|
@ -74,11 +72,12 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
catalogClient = context.getApi().getCatalogClient();
|
||||
queryClient = context.getApi().getQueryClient();
|
||||
}
|
||||
private Metadata catalogItemMetadata;
|
||||
|
||||
@Test(testName = "GET /catalog/{id}")
|
||||
public void testGetCatalog() {
|
||||
CatalogReferences catalogReferences = queryClient.catalogReferencesQuery(String.format("name==%s", CATALOG_NAME));
|
||||
assertEquals(Iterables.size(catalogReferences.getReferences()), 1, String.format("The %s Catalog must exist", CATALOG_NAME));
|
||||
CatalogReferences catalogReferences = queryClient.catalogReferencesQuery(String.format("name==%s", catalogName));
|
||||
assertEquals(Iterables.size(catalogReferences.getReferences()), 1, String.format(MUST_EXIST_FMT, catalogName, "Catalog"));
|
||||
catalogRef = Iterables.getOnlyElement(catalogReferences.getReferences());
|
||||
catalog = catalogClient.getCatalog(catalogRef);
|
||||
}
|
||||
|
@ -93,7 +92,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// NOTE for this test to work, we need to be able to upload a new vAppTemplate to a vDC first
|
||||
// NOTE we could do this with a test environment property -Dtest.vcloud-director.vappTemplateId=vapptemplate-abcd
|
||||
@Test(testName = "POST /catalog/{id}/catalogItems", dependsOnMethods = { "testGetCatalogItem" }, enabled = false)
|
||||
@Test(testName = "POST /catalog/{id}/catalogItems", dependsOnMethods = { "testGetCatalog" }, enabled = false)
|
||||
public void testAddCatalogItem() {
|
||||
CatalogItem editedCatalogItem = CatalogItem.builder()
|
||||
.name("newitem")
|
||||
|
@ -123,7 +122,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
assertEquals(newCatalogItem.getName(), "UPDATEDNAME");
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /catalogItem/{id}", dependsOnMethods = { "testUpdateCatalogItem" }, enabled = false)
|
||||
@Test(testName = "DELETE /catalogItem/{id}", dependsOnMethods = { "testAddCatalogItem" }, enabled = false)
|
||||
public void testDeleteCatalogItem() {
|
||||
catalogClient.deleteCatalogItem(newCatalogItemRef);
|
||||
try {
|
||||
|
@ -131,6 +130,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
fail("The CatalogItem should have been deleted");
|
||||
} catch (VCloudDirectorException vcde) {
|
||||
checkError(vcde.getError());
|
||||
// XXX
|
||||
assertEquals(vcde.getError().getMajorErrorCode(), Integer.valueOf(403), "The majorErrorCode should be 403 since the item has been deleted");
|
||||
}
|
||||
}
|
||||
|
@ -144,50 +144,123 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// NOTE for this test to work, we need to be able to create metadata on a Catalog, specifically { "KEY", "VALUE" }
|
||||
@Test(testName = "GET /catalog/{id}/metadata/{key}", dependsOnMethods = { "testGetCatalogMetadata" }, enabled = false)
|
||||
public void testGetCatalogMetadataEntry() {
|
||||
public void testGetCatalogMetadataValue() {
|
||||
MetadataEntry existingMetadataEntry = Iterables.find(catalogMetadata.getMetadataEntries(), new Predicate<MetadataEntry>() {
|
||||
@Override
|
||||
public boolean apply(MetadataEntry input) {
|
||||
return input.getKey().equals("KEY");
|
||||
}
|
||||
});
|
||||
MetadataEntry metadataEntry = catalogClient.getCatalogMetadataEntry(catalogRef, "KEY");
|
||||
assertEquals(existingMetadataEntry.getValue(), metadataEntry.getValue());
|
||||
checkMetadataEntry(metadataEntry);
|
||||
MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY");
|
||||
// XXX
|
||||
assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(),
|
||||
"The MetadataValue for KEY should have the same Value as the existing MetadataEntry");
|
||||
checkMetadataValue(metadataValue);
|
||||
}
|
||||
|
||||
@Test(testName = "POST /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" })
|
||||
@Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItem" })
|
||||
public void testGetCatalogItemMetadata() {
|
||||
resetCatalogItemMetadata(catalogItemRef);
|
||||
catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
|
||||
// XXX
|
||||
assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, "There should be a single MetadataEntry");
|
||||
checkMetadata(catalogItemMetadata);
|
||||
}
|
||||
|
||||
@Test(testName = "POST /catalogItem/{id}/metadata", dependsOnMethods = { "testGetCatalogItemMetadata" })
|
||||
public void testMergeCatalogItemMetadata() {
|
||||
Metadata newMetadata = Metadata.builder()
|
||||
.entry(MetadataEntry.builder().entry("KEY", "VALUE").build())
|
||||
.entry(MetadataEntry.builder().entry("KEY", "MARMALADE").build())
|
||||
.entry(MetadataEntry.builder().entry("VEGIMITE", "VALUE").build())
|
||||
.build();
|
||||
|
||||
Task task = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata);
|
||||
// TODO wait until task no longer running...
|
||||
}
|
||||
|
||||
@Test(testName = "GET /catalogItem/{id}/metadata", dependsOnMethods = { "testMergeCatalogItemMetadata" })
|
||||
public void testGetCatalogItemMetadata() {
|
||||
Metadata metadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
|
||||
Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata);
|
||||
checkTask(mergeCatalogItemMetadata);
|
||||
// TODO requires code from dan to be merged
|
||||
// assertTrue(taskTester.apply(mergeCatalogItemMetadata.getHref()),
|
||||
// String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
|
||||
|
||||
Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
|
||||
// XXX
|
||||
assertEquals(mergedCatalogItemMetadata.getMetadataEntries().size(), catalogItemMetadata.getMetadataEntries().size() + 1,
|
||||
"Should have added another MetadataEntry to the CatalogItem");
|
||||
|
||||
MetadataValue keyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
// XXX
|
||||
assertEquals(keyMetadataValue.getValue(), "MARMALADE", "The Value of the MetadataValue for KEY should have changed");
|
||||
checkMetadataValue(keyMetadataValue);
|
||||
|
||||
MetadataValue newKeyMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "VEGIMITE");
|
||||
// XXX
|
||||
assertEquals(newKeyMetadataValue.getValue(), "VALUE", "The Value of the MetadataValue for NEW_KEY should have been set");
|
||||
checkMetadataValue(newKeyMetadataValue);
|
||||
}
|
||||
|
||||
// TODO escalate
|
||||
// XXX org.jclouds.vcloud.director.v1_5.VCloudDirectorException: Error: The access to the resource metadata_item with id KEY is forbidden
|
||||
@Test(testName = "GET /catalog/{id}/metadata/{key}", dependsOnMethods = { "testMergeCatalogItemMetadata" }, enabled = false)
|
||||
public void testGetCatalogItemMetadataEntry() {
|
||||
MetadataEntry metadataEntry = catalogClient.getCatalogItemMetadataEntry(catalogItemRef, "KEY");
|
||||
@Test(testName = "GET /catalog/{id}/metadata/{key}", dependsOnMethods = { "testGetCatalogItemMetadata" })
|
||||
public void testGetCatalogItemMetadataValue() {
|
||||
MetadataEntry existingMetadataEntry = Iterables.find(catalogItemMetadata.getMetadataEntries(), new Predicate<MetadataEntry>() {
|
||||
@Override
|
||||
public boolean apply(MetadataEntry input) {
|
||||
return input.getKey().equals("KEY");
|
||||
}
|
||||
});
|
||||
MetadataValue metadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
assertEquals(existingMetadataEntry.getValue(), metadataValue.getValue());
|
||||
checkMetadataValue(metadataValue);
|
||||
}
|
||||
|
||||
@Test(testName = "PUT /catalog/{id}/metadata/{key}", dependsOnMethods = { "testMergeCatalogItemMetadata" })
|
||||
public void testSetCatalogItemMetadataEntry() {
|
||||
@Test(testName = "PUT /catalog/{id}/metadata/{key}", dependsOnMethods = { "testGetCatalogItemMetadataValue" })
|
||||
public void testSetCatalogItemMetadataValue() {
|
||||
MetadataValue newMetadataValue = MetadataValue.builder().value("NEW").build();
|
||||
|
||||
Task task = catalogClient.setCatalogItemMetadataEntry(catalogItemRef, "KEY", newMetadataValue);
|
||||
// TODO wait until task no longer running...
|
||||
Task setCatalogItemMetadataValue = catalogClient.setCatalogItemMetadataValue(catalogItemRef, "KEY", newMetadataValue);
|
||||
checkTask(setCatalogItemMetadataValue);
|
||||
// TODO requires code from dan to be merged
|
||||
// assertTrue(taskTester.apply(setCatalogItemMetadataValue.getHref()),
|
||||
// String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue"));
|
||||
|
||||
MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(),
|
||||
String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", newMetadataValue.getValue(), updatedMetadataValue.getValue()));
|
||||
checkMetadataValue(updatedMetadataValue);
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testMergeCatalogItemMetadata" })
|
||||
public void testDeleteCatalogItemMetadataEntry() {
|
||||
Task task = catalogClient.deleteCatalogItemMetadataEntry(catalogItemRef, "KEY");
|
||||
// TODO wait until task no longer running...
|
||||
@Test(testName = "DELETE /catalog/{id}/metadata/{key}", dependsOnMethods = { "testSetCatalogItemMetadataValue" })
|
||||
public void testDeleteCatalogItemMetadataValue() {
|
||||
Task deleteCatalogItemMetadataValue = catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
checkTask(deleteCatalogItemMetadataValue);
|
||||
// TODO requires code from dan to be merged
|
||||
// assertTrue(taskTester.apply(deleteCatalogItemMetadataValue.getHref()),
|
||||
// String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue"));
|
||||
try {
|
||||
catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
fail("The CatalogItem MetadataValue for KEY should have been deleted");
|
||||
} catch (VCloudDirectorException vcde) {
|
||||
Error error = vcde.getError();
|
||||
checkError(error);
|
||||
Integer majorErrorCode = error.getMajorErrorCode();
|
||||
assertEquals(majorErrorCode, Integer.valueOf(403),
|
||||
String.format(CORRECT_VALUE_OBJECT_FMT, "MajorErrorCode", "Error", "403",Integer.toString(majorErrorCode)));
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteAllCatalogItemMetadata(ReferenceType<?> catalogItemRef) {
|
||||
Metadata currentMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
|
||||
for (MetadataEntry currentMetadataEntry : currentMetadata.getMetadataEntries()) {
|
||||
catalogClient.deleteCatalogItemMetadataValue(catalogItemRef, currentMetadataEntry.getKey());
|
||||
}
|
||||
Metadata emptyMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
|
||||
assertTrue(emptyMetadata.getMetadataEntries().isEmpty(), "The catalogItem Metadata should be empty");
|
||||
}
|
||||
|
||||
private void resetCatalogItemMetadata(ReferenceType<?> catalogItemRef) {
|
||||
deleteAllCatalogItemMetadata(catalogItemRef);
|
||||
Metadata newMetadata = Metadata.builder().entry(MetadataEntry.builder().entry("KEY", "VALUE").build()).build();
|
||||
Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata);
|
||||
// TODO requires code from dan to be merged
|
||||
// assertTrue(taskTester.apply(mergeCatalogItemMetadata.getHref()),
|
||||
// String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Error;
|
|||
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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
|
@ -197,18 +198,18 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrgMetadataEntry() {
|
||||
public void testGetOrgMetadataValue() {
|
||||
URI orgUri = URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0");
|
||||
|
||||
VCloudDirectorClient client = requestsSendResponses(loginRequest, sessionResponse,
|
||||
getStandardRequest("GET", "/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"),
|
||||
getStandardPayloadResponse("/org/orgMetadataEntry.xml", VCloudDirectorMediaType.METADATA_ENTRY));
|
||||
getStandardPayloadResponse("/org/orgMetadataValue.xml", VCloudDirectorMediaType.METADATA_VALUE));
|
||||
|
||||
MetadataEntry expected = metadataEntry();
|
||||
MetadataValue expected = metadataValue();
|
||||
|
||||
Reference orgRef = Reference.builder().href(orgUri).build();
|
||||
|
||||
assertEquals(client.getOrgClient().getOrgMetadataEntry(orgRef, "KEY"), expected);
|
||||
assertEquals(client.getOrgClient().getOrgMetadataValue(orgRef, "KEY"), expected);
|
||||
}
|
||||
|
||||
public static Org org() {
|
||||
|
@ -272,4 +273,16 @@ public class OrgClientExpectTest extends BaseVCloudDirectorRestClientExpectTest
|
|||
.entry("KEY", "VALUE")
|
||||
.build();
|
||||
}
|
||||
|
||||
public static MetadataValue metadataValue() {
|
||||
return MetadataValue.builder()
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY"))
|
||||
.link(Link.builder()
|
||||
.rel("up")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"))
|
||||
.build())
|
||||
.value("VALUE")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.testng.Assert.*;
|
|||
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
|
||||
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.Org;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.Reference;
|
||||
|
@ -68,11 +68,11 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// NOTE The environment MUST have at least one organisation configured
|
||||
|
||||
// Check required elements and attributes
|
||||
assertFalse(Iterables.isEmpty(orgList.getOrgs()), "There must always be Org elements in the OrgList");
|
||||
// Check test requirements
|
||||
assertFalse(Iterables.isEmpty(orgList.getOrgs()), String.format(NOT_EMPTY_OBJECT_FMT, "Org", "OrgList"));
|
||||
|
||||
for (Reference orgRef : orgList.getOrgs()) {
|
||||
assertEquals(orgRef.getType(), VCloudDirectorMediaType.ORG, "The Refernce must be to an Org type");
|
||||
assertEquals(orgRef.getType(), VCloudDirectorMediaType.ORG, String.format(CONDITION_FMT, "Reference.Type", VCloudDirectorMediaType.ORG, orgRef.getType()));
|
||||
checkReferenceType(orgRef);
|
||||
}
|
||||
}
|
||||
|
@ -84,11 +84,7 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
// Call the method being tested
|
||||
org = orgClient.getOrg(orgRef);
|
||||
|
||||
// Check required elements and attributes
|
||||
assertNotNull(org.getFullName(), String.format(FIELD_NOT_NULL_FMT, "FullName", "Org"));
|
||||
|
||||
// Check parent type
|
||||
checkEntityType(org);
|
||||
checkOrg(org);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /org/{id}/metadata/", dependsOnMethods = { "testGetOrg" })
|
||||
|
@ -98,36 +94,22 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
// NOTE The environment MUST have at one metadata entry for the first organisation configured
|
||||
|
||||
// Check required elements and attributes
|
||||
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), "There must always be MetadataEntry elements in the Org");
|
||||
checkMetadata(metadata);
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(metadata);
|
||||
|
||||
for (MetadataEntry entry : metadata.getMetadataEntries()) {
|
||||
// Check required elements and attributes
|
||||
assertNotNull(entry.getKey(), String.format(FIELD_NOT_NULL_FMT, "Key", "MetadataEntry"));
|
||||
assertNotNull(entry.getValue(), String.format(FIELD_NOT_NULL_FMT, "Value", "MetadataEntry"));
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(entry);
|
||||
}
|
||||
// Check requirements for this test
|
||||
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()), String.format(NOT_EMPTY_OBJECT_FMT, "MetadataEntry", "Org"));
|
||||
}
|
||||
|
||||
@Test(testName = "GET /org/{id}/metadata/{key}", dependsOnMethods = { "testGetOrgMetadata" })
|
||||
public void testGetOrgMetadataEntry() {
|
||||
public void testGetOrgMetadataValue() {
|
||||
// Call the method being tested
|
||||
MetadataEntry entry = orgClient.getOrgMetadataEntry(orgRef, "KEY");
|
||||
MetadataValue value = orgClient.getOrgMetadataValue(orgRef, "KEY");
|
||||
|
||||
// NOTE The environment MUST have configured the metadata entry as '{ key="KEY", value="VALUE" )'
|
||||
|
||||
// Check required elements and attributes
|
||||
assertNotNull(entry.getKey(), String.format(FIELD_NOT_NULL_FMT, "Key", "MetadataEntry"));
|
||||
assertEquals(entry.getKey(), "KEY", "The Key field must have the value \"KEY\"");
|
||||
assertNotNull(entry.getValue(), String.format(FIELD_NOT_NULL_FMT, "Value", "MetadataEntry"));
|
||||
assertEquals(entry.getValue(), "VALUE", "The Value field must have the value \"VALUE\"");
|
||||
String expected = "VALUE";
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(entry);
|
||||
checkMetadataValue(value);
|
||||
assertEquals(value.getValue(), expected, String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", expected, value.getValue()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5.features;
|
||||
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.*;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
|
@ -75,7 +76,7 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
// NOTE The environment MUST have ...
|
||||
|
||||
// Check required elements and attributes
|
||||
assertFalse(Iterables.isEmpty(taskList.getTasks()), "There must always be Task elements in the TaskList");
|
||||
assertFalse(Iterables.isEmpty(taskList.getTasks()), String.format(NOT_EMPTY_OBJECT_FMT, "Task", "TaskList"));
|
||||
|
||||
for (Task task : taskList.getTasks()) {
|
||||
checkTask(task);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MetadataEntry xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY" 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">
|
||||
<MetadataValue xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata/KEY" 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.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalogItem/a36fdac9-b8c2-43e2-9a4c-2ffaf3ee13df/metadata"/>
|
||||
<Key>KEY</Key>
|
||||
<Value>VALUE</Value>
|
||||
</MetadataEntry>
|
||||
</MetadataValue>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MetadataEntry xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata/KEY" 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">
|
||||
<MetadataValue xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata/KEY" 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.metadata+xml" href="https://vcloudbeta.bluelock.com/api/catalog/7212e451-76e1-4631-b2de-ba1dfd8080e4/metadata"/>
|
||||
<Key>KEY</Key>
|
||||
<Value>VALUE</Value>
|
||||
</MetadataEntry>
|
||||
</MetadataValue>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<MetadataEntry xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY" 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">
|
||||
<MetadataValue xmlns="http://www.vmware.com/vcloud/v1.5" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata/KEY" 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.metadata+xml" href="https://vcloudbeta.bluelock.com/api/org/6f312e42-cd2b-488d-a2bb-97519cd57ed0/metadata"/>
|
||||
<Key>KEY</Key>
|
||||
<Value>VALUE</Value>
|
||||
</MetadataEntry>
|
||||
</MetadataValue>
|
Loading…
Reference in New Issue