Permalink
Browse files

Cleanup TODO for AssetInfo

For #593
  • Loading branch information...
1 parent a190c0b commit 9958ed2b21d7206cfd6686503c12bd0496aa70be @jcookems jcookems committed Jan 8, 2013
@@ -135,7 +135,6 @@ public LinkInfo getLocatorsLink() {
* @return the link
*/
public LinkInfo getParentAssetsLink() {
- // TODO: NEEDS TESTS once we figure out how to create assets with parents
return getRelationLink("ParentAssets");
}
}
@@ -17,23 +17,38 @@
import static org.junit.Assert.*;
+import java.io.InputStream;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
+import java.util.EnumSet;
import java.util.List;
import java.util.UUID;
import org.junit.Test;
import com.microsoft.windowsazure.services.core.ServiceException;
+import com.microsoft.windowsazure.services.media.models.AccessPolicy;
+import com.microsoft.windowsazure.services.media.models.AccessPolicyInfo;
+import com.microsoft.windowsazure.services.media.models.AccessPolicyPermission;
import com.microsoft.windowsazure.services.media.models.Asset;
+import com.microsoft.windowsazure.services.media.models.AssetFile;
import com.microsoft.windowsazure.services.media.models.AssetInfo;
import com.microsoft.windowsazure.services.media.models.AssetOption;
import com.microsoft.windowsazure.services.media.models.AssetState;
import com.microsoft.windowsazure.services.media.models.ContentKey;
import com.microsoft.windowsazure.services.media.models.ContentKeyInfo;
import com.microsoft.windowsazure.services.media.models.ContentKeyType;
+import com.microsoft.windowsazure.services.media.models.Job;
+import com.microsoft.windowsazure.services.media.models.JobInfo;
+import com.microsoft.windowsazure.services.media.models.LinkInfo;
+import com.microsoft.windowsazure.services.media.models.ListResult;
+import com.microsoft.windowsazure.services.media.models.Locator;
+import com.microsoft.windowsazure.services.media.models.LocatorInfo;
+import com.microsoft.windowsazure.services.media.models.LocatorType;
+import com.microsoft.windowsazure.services.media.models.Task;
+import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;
public class AssetIntegrationTest extends IntegrationTestBase {
@@ -301,4 +316,43 @@ public void linkAssetContentKeyInvalidIdFailed() throws ServiceException, URISyn
// Assert
}
+
+ @Test
+ public void canGetParentBackFromAsset() throws ServiceException, InterruptedException {
+ // Arrange
+ String originalAssetName = testAssetPrefix + "canGetParentBackFromAsset";
+ AssetInfo originalAsset = service.create(Asset.create().setName(originalAssetName));
+
+ int durationInMinutes = 10;
+ AccessPolicyInfo accessPolicyInfo = service.create(AccessPolicy.create(testPolicyPrefix
+ + "uploadAesPortectedAssetSuccess", durationInMinutes, EnumSet.of(AccessPolicyPermission.WRITE)));
+
+ LocatorInfo locatorInfo = service.create(Locator.create(accessPolicyInfo.getId(), originalAsset.getId(),
+ LocatorType.SAS));
+ WritableBlobContainerContract blobWriter = service.createBlobWriter(locatorInfo);
+
+ InputStream mpeg4H264InputStream = getClass().getResourceAsStream("/media/MPEG4-H264.mp4");
+ blobWriter.createBlockBlob("MPEG4-H264.mp4", mpeg4H264InputStream);
+ service.action(AssetFile.createFileInfos(originalAsset.getId()));
+
+ String jobName = testJobPrefix + "createJobSuccess";
+ CreateBatchOperation taskCreator = Task
+ .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5",
+ "<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>"
+ + "<outputAsset>JobOutputAsset(0)</outputAsset>" + "</taskBody>")
+ .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task");
+ JobInfo jobInfo = service.create(Job.create().setName(jobName).addInputMediaAsset(originalAsset.getId())
+ .addTaskCreator(taskCreator));
+
+ // Act
+ ListResult<AssetInfo> outputAssets = service.list(Asset.list(jobInfo.getOutputAssetsLink()));
+ assertEquals(1, outputAssets.size());
+ AssetInfo childAsset = outputAssets.get(0);
+
+ LinkInfo parentAssetLink = childAsset.getParentAssetsLink();
+ AssetInfo parentAsset = service.get(Asset.get(parentAssetLink));
+
+ // Assert
+ assertEquals(originalAsset.getId(), parentAsset.getId());
+ }
}

0 comments on commit 9958ed2

Please sign in to comment.