Browse files

Merge pull request #595 from jcookems/dev

Dev
  • Loading branch information...
2 parents a190c0b + 6460f54 commit 240804883db16168df7ef572dc10bed73d010bdc @jcookems jcookems committed Jan 8, 2013
View
1 ...t-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/AssetInfo.java
@@ -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");
}
}
View
1 ...oft-azure-api/src/main/java/com/microsoft/windowsazure/services/media/models/JobInfo.java
@@ -21,7 +21,6 @@
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.content.JobType;
-// TODO: Auto-generated Javadoc
/**
* The Class JobInfo.
*/
View
1 ...pi/src/main/java/com/microsoft/windowsazure/services/media/models/MediaProcessorInfo.java
@@ -19,7 +19,6 @@
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.content.MediaProcessorType;
-// TODO: Auto-generated Javadoc
/**
* Data about a Media Processor entity.
*
View
2 .../src/test/java/com/microsoft/windowsazure/services/media/AccessPolicyIntegrationTest.java
@@ -82,8 +82,6 @@ public void canCreateAccessPolicyWithReadPermissions() throws Exception {
verifyPolicyProperties("policy", testName, duration, AccessPolicyPermission.READ, policy);
}
- // TODO: Null name or duration?
-
@Test
public void canGetSinglePolicyById() throws Exception {
String expectedName = testPolicyPrefix + "GetOne";
View
54 ...ure-api/src/test/java/com/microsoft/windowsazure/services/media/AssetIntegrationTest.java
@@ -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());
+ }
}
View
3 ...zure-api/src/test/java/com/microsoft/windowsazure/services/media/IntegrationTestBase.java
@@ -81,9 +81,6 @@ public static void cleanup() throws Exception {
}
private static void cleanupEnvironment() {
- // TODO: This should be removed once cascade delete is implemented for Assets.
- // But for now, trying to delete an asset with fail if there are any
- // existing Locators associated with it.
removeAllTestLocators();
removeAllTestAssets();
removeAllTestAccessPolicies();
View
27 ...azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java
@@ -31,6 +31,7 @@
import com.microsoft.windowsazure.services.media.models.Job;
import com.microsoft.windowsazure.services.media.models.JobInfo;
import com.microsoft.windowsazure.services.media.models.JobState;
+import com.microsoft.windowsazure.services.media.models.LinkInfo;
import com.microsoft.windowsazure.services.media.models.ListResult;
import com.microsoft.windowsazure.services.media.models.Task;
import com.microsoft.windowsazure.services.media.models.Task.CreateBatchOperation;
@@ -40,16 +41,16 @@
private static AssetInfo assetInfo;
- private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) {
+ private void verifyJobInfoEqual(String message, JobInfo expected, JobInfo actual) throws ServiceException {
verifyJobProperties(message, expected.getName(), expected.getPriority(), expected.getRunningDuration(),
expected.getState(), expected.getTemplateId(), expected.getCreated(), expected.getLastModified(),
- expected.getStartTime(), expected.getEndTime(), actual);
+ expected.getStartTime(), expected.getEndTime(), null, actual);
}
@SuppressWarnings("deprecation")
private void verifyJobProperties(String message, String testName, Integer priority, double runningDuration,
JobState state, String templateId, Date created, Date lastModified, Date startTime, Date endTime,
- JobInfo actualJob) {
+ Integer expectedTaskCount, JobInfo actualJob) throws ServiceException {
assertNotNull(message, actualJob);
assertNotNull(message + "Id", actualJob.getId());
@@ -66,8 +67,11 @@ private void verifyJobProperties(String message, String testName, Integer priori
assertDateApproxEquals(message + " StartTime", startTime, actualJob.getStartTime());
assertDateApproxEquals(message + " EndTime", endTime, actualJob.getEndTime());
- // TODO: Add test for accessing the tasks when fixed:
- // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/531
+ if (expectedTaskCount != null) {
+ LinkInfo tasksLink = actualJob.getTasksLink();
+ ListResult<TaskInfo> actualTasks = service.list(Task.list(tasksLink));
+ assertEquals(message + " tasks size", expectedTaskCount.intValue(), actualTasks.size());
+ }
}
private JobInfo createJob(String name) throws ServiceException {
@@ -108,7 +112,7 @@ public void createJobSuccess() throws ServiceException {
// Assert
verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime,
- endTime, actualJob);
+ endTime, 1, actualJob);
}
@Test
@@ -133,7 +137,7 @@ public void createJobTwoTasksSuccess() throws ServiceException {
// Assert
verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime,
- endTime, actualJob);
+ endTime, 2, actualJob);
}
@Test
@@ -155,7 +159,7 @@ public void getJobSuccess() throws ServiceException {
// Assert
verifyJobProperties("actualJob", name, priority, duration, state, templateId, created, lastModified, stateTime,
- endTime, actualJob);
+ endTime, 1, actualJob);
}
@Test
@@ -180,7 +184,12 @@ public void listJobSuccess() throws ServiceException {
verifyListResultContains("listJobs", expectedListJobsResult, actualListJobResult, new ComponentDelegate() {
@Override
public void verifyEquals(String message, Object expected, Object actual) {
- verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual);
+ try {
+ verifyJobInfoEqual(message, (JobInfo) expected, (JobInfo) actual);
+ }
+ catch (ServiceException e) {
+ fail(e.getMessage());
+ }
}
});
}
View
5 ...zure-api/src/test/java/com/microsoft/windowsazure/services/media/TaskIntegrationTest.java
@@ -189,8 +189,6 @@ public void cancelTaskSuccess() throws ServiceException, InterruptedException {
//Assert
List<TaskInfo> taskInfos = service.list(Task.list(cancellingJobInfo.getTasksLink()));
for (TaskInfo taskInfo : taskInfos) {
- // Replace with enums
- // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/522
verifyTaskPropertiesNoEncryption("canceled task", mediaProcessorId, TaskOption.None, taskBody,
configuration, name, 0, new Date(), null, 0.0, 0.0, null, TaskState.Canceled, taskInfo);
}
@@ -225,9 +223,6 @@ private void verifyTaskProperties(String message, String mediaProcessorId, TaskO
assertNotNull(message + " getErrorDetails", actual.getErrorDetails());
assertEquals(message + " getErrorDetails.size", 0, actual.getErrorDetails().size());
- // TODO: Add tests for Historical events when added
- // https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/494
-
ListResult<AssetInfo> inputAssets = service.list(Asset.list(actual.getInputAssetsLink()));
ListResult<AssetInfo> outputAssets = service.list(Asset.list(actual.getOutputAssetsLink()));

0 comments on commit 2408048

Please sign in to comment.