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