Link addMedia = find(vdc.getLinks(), and(relEquals("add"), typeEquals(VCloudDirectorMediaType.MEDIA)));
// TODO: generate an iso
byte[] iso = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
Media sourceMedia = Media.builder().type(VCloudDirectorMediaType.MEDIA).name("Test media " + random.nextInt())
.size(iso.length).imageType(Media.ImageType.ISO).description("Test media generated by testAddMedia()")
.build();
media = mediaApi.add(addMedia.getHref(), sourceMedia);
Checks.checkMediaFor(MEDIA, media);
assertNotNull(media.getFiles(), String.format(OBJ_FIELD_REQ, MEDIA, "files"));
assertEquals(1, media.getFiles().size(),
String.format(OBJ_FIELD_LIST_SIZE_EQ, MEDIA, "files", 1, media.getFiles().size()));
File uploadFile = getFirst(media.getFiles(), null);
assertNotNull(uploadFile, String.format(OBJ_FIELD_REQ, MEDIA, "files.first"));
assertEquals(uploadFile.getSize(), Long.valueOf(iso.length));
assertEquals(uploadFile.getSize().longValue(), sourceMedia.getSize(),
String.format(OBJ_FIELD_EQ, MEDIA, "uploadFile.size()", sourceMedia.getSize(), uploadFile.getSize()));
Set<Link> links = uploadFile.getLinks();
assertNotNull(links, String.format(OBJ_FIELD_REQ, MEDIA, "uploadFile.links"));
assertTrue(links.size() >= 1, String.format(OBJ_FIELD_LIST_SIZE_GE, MEDIA, "uploadfile.links", 1, links.size()));
assertTrue(