mirror of https://github.com/apache/jclouds.git
Merge pull request #383 from danikov/vclouds-director-bugfixes
Issue 830: vCloud director common changes
This commit is contained in:
commit
aca5beaa21
|
@ -92,10 +92,17 @@ public class Media extends ResourceEntityType<Media> {
|
|||
|
||||
@Override
|
||||
public Media build() {
|
||||
Media media = new Media();
|
||||
Media media = new Media(href, name);
|
||||
media.setOwner(owner);
|
||||
media.setImageType(imageType);
|
||||
media.setSize(size);
|
||||
media.setFiles(files);
|
||||
media.setStatus(status);
|
||||
media.setDescription(description);
|
||||
media.setTasksInProgress(tasksInProgress);
|
||||
media.setId(id);
|
||||
media.setType(type);
|
||||
media.setLinks(links);
|
||||
return media;
|
||||
}
|
||||
|
||||
|
@ -200,7 +207,11 @@ public class Media extends ResourceEntityType<Media> {
|
|||
}
|
||||
|
||||
public Media() {
|
||||
super();
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
protected Media(URI href, String name) {
|
||||
super(href, name);
|
||||
}
|
||||
|
||||
@XmlElement(namespace = VCLOUD_1_5_NS, name = "Owner")
|
||||
|
|
|
@ -89,8 +89,10 @@ public class Owner
|
|||
|
||||
|
||||
public Owner build() {
|
||||
Owner owner = new Owner();
|
||||
Owner owner = new Owner(href);
|
||||
owner.setUser(user);
|
||||
owner.setType(type);
|
||||
owner.setLinks(links);
|
||||
return owner;
|
||||
}
|
||||
|
||||
|
@ -146,6 +148,10 @@ public class Owner
|
|||
// For JAXB and builder use
|
||||
}
|
||||
|
||||
private Owner(URI href) {
|
||||
super(href);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@XmlElement(name = "User", required = true)
|
||||
|
|
|
@ -54,8 +54,8 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
|
|||
|
||||
public static class Builder<T extends ResourceEntityType<T>> extends EntityType.Builder<T> {
|
||||
|
||||
private FilesList files;
|
||||
private Integer status;
|
||||
protected FilesList files;
|
||||
protected Integer status;
|
||||
|
||||
/**
|
||||
* @see ResourceEntityType#getFiles()
|
||||
|
@ -75,9 +75,14 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
|
|||
|
||||
@Override
|
||||
public ResourceEntityType<T> build() {
|
||||
ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>();
|
||||
ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>(href, name);
|
||||
resourceEntity.setFiles(files);
|
||||
resourceEntity.setStatus(status);
|
||||
resourceEntity.setDescription(description);
|
||||
resourceEntity.setTasksInProgress(tasksInProgress);
|
||||
resourceEntity.setId(id);
|
||||
resourceEntity.setType(type);
|
||||
resourceEntity.setLinks(links);
|
||||
return resourceEntity;
|
||||
}
|
||||
|
||||
|
@ -135,6 +140,7 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
|
|||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Builder<T> fromResourceType(ResourceType<T> in) {
|
||||
return Builder.class.cast(super.fromResourceType(in));
|
||||
|
@ -145,10 +151,14 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
|
|||
}
|
||||
}
|
||||
|
||||
public ResourceEntityType() {
|
||||
protected ResourceEntityType() {
|
||||
// for JAXB
|
||||
}
|
||||
|
||||
protected ResourceEntityType(URI href, String name) {
|
||||
super(href, name);
|
||||
}
|
||||
|
||||
@XmlElement(name = "Files")
|
||||
protected FilesList files;
|
||||
@XmlAttribute
|
||||
|
|
|
@ -22,6 +22,8 @@ import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.C
|
|||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_BE_WELL_FORMED_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.MUST_CONTAIN_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.NOT_NULL_OBJECT_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_FMT;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REQUIRED_VALUE_OBJECT_FMT;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
@ -368,4 +370,25 @@ public class Checks {
|
|||
public static void checkIpAddress(String ip) {
|
||||
InetAddresses.isInetAddress(ip);
|
||||
}
|
||||
|
||||
public static void checkVApp(VApp vApp) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public static void checkVAppTemplate(VAppTemplate template) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public static void checkMediaFor(String client, Media media) {
|
||||
// required
|
||||
assertNotNull(media.getImageType(), String.format(OBJ_FIELD_REQ, client, "imageType"));
|
||||
Checks.checkImageType(media.getImageType());
|
||||
assertNotNull(media.getSize(), String.format(OBJ_FIELD_REQ, client, "size"));
|
||||
assertTrue(media.getSize() >= 0, String.format(OBJ_FIELD_GTE_0, client, "size", media.getSize()));
|
||||
|
||||
// parent type
|
||||
Checks.checkResourceEntityType(media);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ import static org.testng.Assert.fail;
|
|||
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.Checks;
|
||||
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;
|
||||
|
@ -63,7 +64,6 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
private CatalogClient catalogClient;
|
||||
private QueryClient queryClient;
|
||||
private MediaClient mediaClient;
|
||||
|
||||
/*
|
||||
* Shared state between dependant tests.
|
||||
|
@ -81,7 +81,6 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
public void setupRequiredClients() {
|
||||
catalogClient = context.getApi().getCatalogClient();
|
||||
queryClient = context.getApi().getQueryClient();
|
||||
mediaClient = context.getApi().getMediaClient();
|
||||
}
|
||||
|
||||
private Metadata catalogItemMetadata;
|
||||
|
@ -227,9 +226,9 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
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"));
|
||||
Checks.checkTask(setCatalogItemMetadataValue);
|
||||
assertTrue(retryTaskSuccess.apply(setCatalogItemMetadataValue.getHref()),
|
||||
String.format(TASK_COMPLETE_TIMELY, "setCatalogItemMetadataValue"));
|
||||
|
||||
MetadataValue updatedMetadataValue = catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
assertEquals(updatedMetadataValue.getValue(), newMetadataValue.getValue(),
|
||||
|
@ -241,9 +240,9 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
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"));
|
||||
Checks.checkTask(deleteCatalogItemMetadataValue);
|
||||
assertTrue(retryTaskSuccess.apply(deleteCatalogItemMetadataValue.getHref()),
|
||||
String.format(TASK_COMPLETE_TIMELY, "deleteCatalogItemMetadataValue"));
|
||||
try {
|
||||
catalogClient.getCatalogItemMetadataValue(catalogItemRef, "KEY");
|
||||
fail("The CatalogItem MetadataValue for KEY should have been deleted");
|
||||
|
@ -269,8 +268,8 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
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"));
|
||||
Checks.checkTask(mergeCatalogItemMetadata);
|
||||
assertTrue(retryTaskSuccess.apply(mergeCatalogItemMetadata.getHref()),
|
||||
String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,8 +158,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: fix this
|
||||
@Test( enabled=false )
|
||||
@Test
|
||||
public void testUpdateMedia() {
|
||||
URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");
|
||||
|
||||
|
@ -383,7 +382,6 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
.build())
|
||||
.link(Link.builder()
|
||||
.rel("remove")
|
||||
.type("application/vnd.vmware.vcloud.metadata+xml")
|
||||
.href(URI.create("https://mycloud.greenhousedata.com/api/media/c93e5cdc-f29a-4749-8ed2-093df04cc75e"))
|
||||
.build())
|
||||
.link(Link.builder()
|
||||
|
@ -403,6 +401,7 @@ public class MediaClientExpectTest extends BaseVCloudDirectorRestClientExpectTes
|
|||
.build())
|
||||
.description("new test description")
|
||||
.owner(Owner.builder()
|
||||
.type("application/vnd.vmware.vcloud.owner+xml")
|
||||
.user(Reference.builder()
|
||||
.type("application/vnd.vmware.admin.user+xml")
|
||||
.name("dan")
|
||||
|
|
|
@ -22,17 +22,13 @@ 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_DEL;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_DEL;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_ATTRB_REQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_CONTAINS;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_GTE_0;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_UPDATABLE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.REF_REQ_LIVE;
|
||||
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
|
||||
import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkResourceType;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
@ -75,18 +71,24 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
* Convenience references to API clients.
|
||||
*/
|
||||
|
||||
private Reference mediaRef;
|
||||
protected MediaClient mediaClient;
|
||||
|
||||
@BeforeClass(inheritGroups = true)
|
||||
@Override
|
||||
public void setupRequiredClients() {
|
||||
mediaRef = Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.media+xml")
|
||||
.name("")
|
||||
.href(URI.create(endpoint+"/media/" + mediaId))
|
||||
.id(mediaId)
|
||||
.build();
|
||||
mediaClient = context.getApi().getMediaClient();
|
||||
}
|
||||
|
||||
/*
|
||||
* Shared state between dependent tests.
|
||||
*/
|
||||
private Reference mediaRef;
|
||||
private Media media;
|
||||
private Owner owner;
|
||||
private Metadata metadata;
|
||||
|
@ -95,17 +97,12 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void createReferenceData() {
|
||||
mediaRef = Reference.builder()
|
||||
.type("application/vnd.vmware.vcloud.media+xml")
|
||||
.name("")
|
||||
.href(URI.create(endpoint+"/media/" + mediaId))
|
||||
.id(mediaId)
|
||||
.build();
|
||||
// FIXME: don't want to be modifying anything here!
|
||||
mediaClient.setMetadata(mediaRef, "key", MetadataValue.builder().value("value").build());
|
||||
}
|
||||
|
||||
@Test(testName = "GET /media/{id}")
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMedia() {
|
||||
public void testGetMedia() {
|
||||
// required for testing
|
||||
assertNotNull(mediaRef, String.format(REF_REQ_LIVE, MEDIA));
|
||||
|
||||
|
@ -117,20 +114,12 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
assertNotNull(owner, String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "owner"));
|
||||
Checks.checkResourceType(media.getOwner());
|
||||
|
||||
// parent type
|
||||
Checks.checkResourceEntityType(media);
|
||||
|
||||
// required
|
||||
String imageType = media.getImageType();
|
||||
Checks.checkImageType(imageType);
|
||||
Long size = media.getSize();
|
||||
assertNotNull(size, String.format(OBJ_FIELD_REQ, MEDIA, "size"));
|
||||
assertTrue(size >= 0, String.format(OBJ_FIELD_GTE_0, MEDIA, "size", size));
|
||||
Checks.checkMediaFor(MEDIA, media);
|
||||
}
|
||||
|
||||
@Test(testName = "GET /media/{id}/owner",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginReturnsValidMedia" })
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMediaOwner() {
|
||||
dependsOnMethods = { "testGetMedia" })
|
||||
public void testGetMediaOwner() {
|
||||
Owner directOwner = mediaClient.getOwner(mediaRef);
|
||||
assertEquals(owner, directOwner, String.format(GETTER_RETURNS_SAME_OBJ,
|
||||
"getOwner()", "owner", "media.getOwner()", owner.toString(), directOwner.toString()));
|
||||
|
@ -144,8 +133,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(testName = "PUT /media/{id}",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginReturnsValidMedia" })
|
||||
public void testWhenResponseIs2xxLoginReturnsValidNetwork() {
|
||||
dependsOnMethods = { "testGetMedia" })
|
||||
public void testSetMedia() {
|
||||
String oldName = media.getName();
|
||||
String newName = "new "+oldName;
|
||||
String oldDescription = media.getDescription();
|
||||
|
@ -164,11 +153,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
|
||||
//TODO negative tests?
|
||||
|
||||
// ensure media remains valid
|
||||
testWhenResponseIs2xxLoginReturnsValidMedia();
|
||||
Checks.checkMediaFor(MEDIA, media);
|
||||
|
||||
media.setName(newName);
|
||||
media.setDescription(newDescription);
|
||||
media.setName(oldName);
|
||||
media.setDescription(oldDescription);
|
||||
|
||||
updateMedia = mediaClient.updateMedia(mediaRef, media);
|
||||
Checks.checkTask(updateMedia);
|
||||
|
@ -177,31 +165,19 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(testName = "GET /media/{id}/metadata",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginReturnsValidMedia" })
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMetadata() {
|
||||
dependsOnMethods = { "testGetMedia" })
|
||||
public void testGetMetadata() {
|
||||
metadata = mediaClient.getMetadata(mediaRef);
|
||||
// required for testing
|
||||
assertFalse(Iterables.isEmpty(metadata.getMetadataEntries()),
|
||||
String.format(OBJ_FIELD_REQ_LIVE, MEDIA, "metadata.entries"));
|
||||
|
||||
// parent type
|
||||
checkResourceType(metadata);
|
||||
|
||||
for (MetadataEntry entry : metadata.getMetadataEntries()) {
|
||||
// required elements and attributes
|
||||
assertNotNull(entry.getKey(),
|
||||
String.format(OBJ_FIELD_ATTRB_REQ, MEDIA, "MetadataEntry", metadataValue, "key"));
|
||||
assertNotNull(entry.getValue(),
|
||||
String.format(OBJ_FIELD_ATTRB_REQ, MEDIA, "MetadataEntry", metadataValue, "value"));
|
||||
|
||||
// parent type
|
||||
checkResourceType(entry);
|
||||
}
|
||||
Checks.checkMetadataFor(MEDIA, metadata);
|
||||
}
|
||||
|
||||
@Test(testName = "POST /media/{id}/metadata",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginReturnsValidMetadata" })
|
||||
public void testWhenResponseIs2xxLoginMergedMetadata() {
|
||||
dependsOnMethods = { "testGetMetadata" })
|
||||
public void testMergeMetadata() {
|
||||
// test new
|
||||
Set<MetadataEntry> inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "testValue").build());
|
||||
Metadata inputMetadata = Metadata.builder()
|
||||
|
@ -212,9 +188,11 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Checks.checkTask(mergeMetadata);
|
||||
assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(new)"));
|
||||
metadata = mediaClient.getMetadata(mediaRef);
|
||||
Checks.checkMetadataFor(MEDIA, metadata);
|
||||
checkMetadataContainsEntries(metadata, inputEntries);
|
||||
|
||||
testWhenResponseIs2xxLoginReturnsValidMetadata();
|
||||
media = mediaClient.getMedia(mediaRef);
|
||||
Checks.checkMediaFor(MEDIA, media);
|
||||
|
||||
// test modify
|
||||
inputEntries = ImmutableSet.of(MetadataEntry.builder().entry("testKey", "new testValue").build());
|
||||
|
@ -226,9 +204,11 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
Checks.checkTask(mergeMetadata);
|
||||
assertTrue(retryTaskSuccess.apply(mergeMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeMetadata(modify)"));
|
||||
metadata = mediaClient.getMetadata(mediaRef);
|
||||
Checks.checkMetadataFor(MEDIA, metadata);
|
||||
checkMetadataContainsEntries(metadata, inputEntries);
|
||||
|
||||
testWhenResponseIs2xxLoginReturnsValidMetadata();
|
||||
media = mediaClient.getMedia(mediaRef);
|
||||
Checks.checkMediaFor(MEDIA, media);
|
||||
}
|
||||
|
||||
private void checkMetadataContainsEntries(Metadata metadata, Set<MetadataEntry> entries) {
|
||||
|
@ -249,25 +229,15 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
}
|
||||
|
||||
@Test(testName = "GET /media/{id}/metadata/{key}",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginMergedMetadata" })
|
||||
public void testWhenResponseIs2xxLoginReturnsValidMetadataValue() {
|
||||
dependsOnMethods = { "testMergeMetadata" })
|
||||
public void testGetMetadataValue() {
|
||||
metadataValue = mediaClient.getMetadataValue(mediaRef, "key");
|
||||
|
||||
// Check parent type
|
||||
checkResourceType(metadataValue);
|
||||
|
||||
// Check required elements and attributes
|
||||
String value = metadataValue.getValue();
|
||||
assertNotNull(value,
|
||||
String.format(OBJ_FIELD_ATTRB_REQ, MEDIA, "MetadataEntry",
|
||||
metadataValue.toString(), metadataEntryValue.toString()));
|
||||
assertEquals(value, metadataEntryValue,
|
||||
String.format(OBJ_FIELD_EQ, MEDIA, "metadataEntry.value", metadataEntryValue, value));
|
||||
Checks.checkMetadataValueFor(MEDIA, metadataValue);
|
||||
}
|
||||
|
||||
@Test(testName = "PUT /media/{id}/metadata/{key}",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginReturnsValidMetadataValue" })
|
||||
public void testWhenResponseIs2xxLoginUpdatesMetadataEntry() {
|
||||
dependsOnMethods = { "testGetMetadataValue" })
|
||||
public void testSetMetadataValue() {
|
||||
metadataEntryValue = "newValue";
|
||||
MetadataValue newValue = MetadataValue.builder().value(metadataEntryValue).build();
|
||||
|
||||
|
@ -276,14 +246,12 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
assertTrue(retryTaskSuccess.apply(setMetadataEntry.getHref()),
|
||||
String.format(TASK_COMPLETE_TIMELY, "setMetadataEntry"));
|
||||
metadataValue = mediaClient.getMetadataValue(mediaRef, "key");
|
||||
|
||||
// ensure metadataEntry remains valid
|
||||
testWhenResponseIs2xxLoginReturnsValidMetadataValue();
|
||||
Checks.checkMetadataValueFor(MEDIA, metadataValue);
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /media/{id}/metadata/{key}",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginUpdatesMetadataEntry" } )
|
||||
public void testWhenResponseIs2xxLoginDeletesMetadataEntry() {
|
||||
dependsOnMethods = { "testSetMetadataValue" } )
|
||||
public void testDeleteMetadata() {
|
||||
Task deleteMetadataEntry = mediaClient.deleteMetadataEntry(mediaRef, "testKey");
|
||||
Checks.checkTask(deleteMetadataEntry);
|
||||
assertTrue(retryTaskSuccess.apply(deleteMetadataEntry.getHref()),
|
||||
|
@ -311,14 +279,16 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
|
|||
"metadataEntry", metadataValue.toString()));
|
||||
}
|
||||
|
||||
// ensure metadata and media remains valid
|
||||
testWhenResponseIs2xxLoginReturnsValidMetadata();
|
||||
testWhenResponseIs2xxLoginReturnsValidMedia();
|
||||
}
|
||||
@Test(testName = "DELETE /media/{id}",
|
||||
dependsOnMethods = { "testWhenResponseIs2xxLoginDeletesMetadataEntry" } )
|
||||
public void testWhenResponseIs2xxLoginDeletesMedia() {
|
||||
metadataValue = mediaClient.getMetadataValue(mediaRef, "key");
|
||||
Checks.checkMetadataValueFor(MEDIA, metadataValue);
|
||||
|
||||
media = mediaClient.getMedia(mediaRef);
|
||||
Checks.checkMediaFor(MEDIA, media);
|
||||
}
|
||||
|
||||
@Test(testName = "DELETE /media/{id}",
|
||||
dependsOnMethods = { "testDeleteMetadata" } )
|
||||
public void testDeleteMedia() {
|
||||
Task deleteMedia = mediaClient.deleteMedia(mediaRef);
|
||||
Checks.checkTask(deleteMedia);
|
||||
assertTrue(retryTaskSuccess.apply(deleteMedia.getHref()),
|
||||
|
|
|
@ -81,28 +81,34 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
|||
credential = password;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path) {
|
||||
return getStandardRequest(method, path, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri) {
|
||||
return getStandardRequest(method, uri, VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, String path, String mediaType) {
|
||||
return getStandardRequest(method, URI.create(endpoint + path), VCloudDirectorMediaType.ANY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, String command, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardPayloadRequest(method, URI.create(endpoint + command), relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardPayloadRequest(String method, URI uri, String relativeFilePath,
|
||||
String postMediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, postMediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequest(String method, URI uri, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
|
@ -114,19 +120,23 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
|||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, path, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String relativeFilePath, String mediaType) {
|
||||
return getStandardRequestWithPayload(method, uri, VCloudDirectorMediaType.ANY, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, String path, String acceptType, String relativeFilePath, String mediaType) {
|
||||
URI uri = URI.create(endpoint + path);
|
||||
return getStandardRequestWithPayload(method, uri, acceptType, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpRequest getStandardRequestWithPayload(String method, URI uri, String acceptType, String relativeFilePath, String mediaType) {
|
||||
return HttpRequest.builder()
|
||||
.method(method)
|
||||
|
@ -139,10 +149,12 @@ public class BaseVCloudDirectorRestClientExpectTest extends BaseRestClientExpect
|
|||
.build();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(String relativeFilePath, String mediaType) {
|
||||
return getStandardPayloadResponse(200, relativeFilePath, mediaType);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected HttpResponse getStandardPayloadResponse(int statusCode, String relativeFilePath, String mediaType) {
|
||||
return HttpResponse.builder()
|
||||
.statusCode(statusCode)
|
||||
|
|
Loading…
Reference in New Issue