pass clone media

This commit is contained in:
danikov 2012-03-02 12:43:32 +00:00
parent b9e0263aa1
commit 6a4ccc5178
1 changed files with 25 additions and 16 deletions

View File

@ -90,7 +90,7 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private MetadataValue metadataValue; private MetadataValue metadataValue;
private String metadataEntryValue = "value"; private String metadataEntryValue = "value";
@Test(testName = "POST /vdc/{id}/media") @Test(testName = "POST /vdc/{id}/media", enabled = false)
public void testCreateMedia() throws URISyntaxException { public void testCreateMedia() throws URISyntaxException {
assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC)); assertNotNull(vdcRef, String.format(REF_REQ_LIVE, VDC));
assertNotNull(vdcClient.getVdc(vdcRef), String.format(OBJ_REQ_LIVE, VDC)); assertNotNull(vdcClient.getVdc(vdcRef), String.format(OBJ_REQ_LIVE, VDC));
@ -118,10 +118,10 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
assertNotNull(links, ""); assertNotNull(links, "");
assertTrue(links.size() == 1, ""); assertTrue(links.size() == 1, "");
Link uploadLink = Iterables.getFirst(links, null); Link uploadLink = Iterables.getFirst(links, null);
assertTrue(equal(uploadLink.getRel(), Link.Rel.UPLOAD_DEFAULT), "");
//TODO upload file fail(); //TODO upload file and assert it succeeds
// context.getApi().getUploadClient().uploadFile(uploadFile, sourceFile); context.getApi().getUploadClient().uploadFile(uploadLink, sourceFile);
fail();
} }
@Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" }) @Test(testName = "GET /media/{id}", dependsOnMethods = { "testCreateMedia" })
@ -157,15 +157,19 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
oldMedia = media; oldMedia = media;
media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build()) .source(Reference.builder().fromEntity(media).build())
.name("copied test media")
.description("copied by testCloneMedia()")
.build()); .build());
Checks.checkMediaFor(VDC, media); Checks.checkMediaFor(VDC, media);
Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); if (media.getTasksInProgress() != null) {
if (copyTask != null) { Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null);
Checks.checkTask(copyTask); if (copyTask != null) {
assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); Checks.checkTask(copyTask);
media = mediaClient.getMedia(media); assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask"));
media = mediaClient.getMedia(media);
}
} }
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
@ -175,18 +179,20 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder() media = vdcClient.cloneMedia(vdcRef, CloneMediaParams.builder()
.source(Reference.builder().fromEntity(media).build()) .source(Reference.builder().fromEntity(media).build())
.name("copied test media") .name("moved test media")
.description("copied by testCloneMedia()") .description("moved by testCloneMedia()")
.isSourceDelete(true) .isSourceDelete(true)
.build()); .build());
Checks.checkMediaFor(VDC, media); Checks.checkMediaFor(VDC, media);
copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null); if (media.getTasksInProgress() != null) {
if (copyTask != null) { Task copyTask = Iterables.getFirst(media.getTasksInProgress().getTasks(), null);
Checks.checkTask(copyTask); if (copyTask != null) {
assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask")); Checks.checkTask(copyTask);
media = mediaClient.getMedia(media); assertTrue(retryTaskSuccess.apply(copyTask), String.format(TASK_COMPLETE_TIMELY, "copyTask"));
media = mediaClient.getMedia(media);
}
} }
Checks.checkMediaFor(MEDIA, media); Checks.checkMediaFor(MEDIA, media);
@ -374,5 +380,8 @@ public class MediaClientLiveTest extends BaseVCloudDirectorClientLiveTest {
if (media != null) { // guard against NPE on the .toStrings if (media != null) { // guard against NPE on the .toStrings
assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString())); assertNull(metadataValue, String.format(OBJ_DEL, MEDIA, media.toString()));
} }
deleteMedia = mediaClient.deleteMedia(oldMedia);
Checks.checkTask(deleteMedia);
} }
} }