Permalink
Browse files

fix task unit tests

  • Loading branch information...
1 parent bab9d55 commit 656e49124bec64ccf3c469169a6bd4579666ea46 Albert Cheng committed Dec 14, 2012
@@ -52,8 +52,8 @@ private Task() {
* the options
* @return the creates the batch operation
*/
- public static CreateBatchOperation create(String mediaProcessorId, String taskBody, int options) {
- return new CreateBatchOperation(mediaProcessorId, taskBody, options);
+ public static CreateBatchOperation create(String mediaProcessorId, String taskBody) {
+ return new CreateBatchOperation(mediaProcessorId, taskBody);
}
/**
@@ -96,13 +96,12 @@ public static CreateBatchOperation create(String mediaProcessorId, String taskBo
* @param options
* the options
*/
- public CreateBatchOperation(String mediaProcessorId, String taskBody, int options) {
+ public CreateBatchOperation(String mediaProcessorId, String taskBody) {
this.verb = "POST";
taskType = new TaskType();
addContentObject(taskType);
this.taskType.setMediaProcessorId(mediaProcessorId);
this.taskType.setTaskBody(taskBody);
- this.taskType.setOptions(options);
}
/**
@@ -98,13 +98,10 @@ private JobInfo createJob(String name) throws ServiceException {
private CreateBatchOperation getTaskCreator(int outputAssetPosition) {
return Task
- .create()
- .setConfiguration("H.264 256k DSL CBR")
- .setMediaProcessorId("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5")
- .setName("My encoding Task")
- .setTaskBody(
+ .create("nb:mpid:UUID:2f381738-c504-4e4a-a38e-d199e207fcd5",
"<taskBody>" + "<inputAsset>JobInputAsset(0)</inputAsset>" + "<outputAsset>JobOutputAsset("
- + outputAssetPosition + ")</outputAsset>" + "</taskBody>");
+ + outputAssetPosition + ")</outputAsset>" + "</taskBody>")
+ .setConfiguration("H.264 256k DSL CBR").setName("My encoding Task");
}
@BeforeClass
@@ -80,7 +80,10 @@ public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBExc
ParserConfigurationException {
// Arrange
URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build();
- Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation();
+ String mediaProcessorId = "testMediaProcessorId";
+ String taskBody = "testTaskBody";
+
+ Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(mediaProcessorId, taskBody);
// Act
MediaBatchOperations mediaBatchOperations = new MediaBatchOperations(serviceUri);
@@ -95,8 +98,10 @@ public void addCreateTaskOperationToMediaBatchOperationsSuccess() throws JAXBExc
public void getMimeMultipartSuccess() throws JAXBException, ParserConfigurationException, MessagingException,
IOException {
// Arrange
+ String mediaProcessorId = "testMediaProcessorId";
+ String taskBody = "testTaskBody";
URI serviceUri = UriBuilder.fromPath("http://www.contoso.com/media").build();
- Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation();
+ Task.CreateBatchOperation taskCreateBatchOperation = new Task.CreateBatchOperation(mediaProcessorId, taskBody);
Job.CreateBatchOperation jobCreateBatchOperation = new Job.CreateBatchOperation(serviceUri);
// Act
@@ -216,51 +216,53 @@ public JobInfo createJob(String jobName, AssetInfo inputAsset, List<Task.CreateB
// Process
public Task.CreateBatchOperation createTaskOptionsWindowsAzureMediaEncoder(String taskName, int inputAssetId,
int outputAssetId) throws ServiceException {
- Task.CreateBatchOperation taskCreate = Task.create().setName(taskName)
- .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER))
- .setConfiguration("H.264 256k DSL CBR");
- setTaskBody(taskCreate, inputAssetId, outputAssetId);
+ String taskBody = getTaskBody(inputAssetId, outputAssetId);
+ Task.CreateBatchOperation taskCreate = Task
+ .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_WINDOWS_AZURE_MEDIA_ENCODER), taskBody)
+ .setName(taskName).setConfiguration("H.264 256k DSL CBR");
+
return taskCreate;
}
// Process
public Task.CreateBatchOperation createTaskOptionsPlayReadyProtection(String taskName,
String playReadyConfiguration, int inputAssetId, int outputAssetId) throws ServiceException {
+ String taskBody = getTaskBody(inputAssetId, outputAssetId);
Task.CreateBatchOperation taskCreate = Task
- .create()
- .setName(taskName)
+ .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION), taskBody).setName(taskName)
// TODO: Re-enable
// https://github.com/WindowsAzure/azure-sdk-for-java-pr/issues/499
// .setTaskCreationOptions(TaskCreationOptions.ProtectedConfiguration)
- .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_PLAYREADY_PROTECTION))
.setConfiguration(playReadyConfiguration);
- setTaskBody(taskCreate, inputAssetId, outputAssetId);
+
return taskCreate;
}
// Process
public Task.CreateBatchOperation createTaskOptionsMp4ToSmoothStreams(String taskName, int inputAssetId,
int outputAssetId) throws ServiceException {
- Task.CreateBatchOperation taskCreate = Task.create().setName(taskName)
- .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS))
+ String taskBody = getTaskBody(inputAssetId, outputAssetId);
+ Task.CreateBatchOperation taskCreate = Task
+ .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_MP4_TO_SMOOTH_STREAMS), taskBody).setName(taskName)
.setConfiguration(configMp4ToSmoothStreams);
- setTaskBody(taskCreate, inputAssetId, outputAssetId);
+
return taskCreate;
}
// Process
public Task.CreateBatchOperation createTaskOptionsSmoothStreamsToHls(String taskName, int inputAssetId,
int outputAssetId) throws ServiceException {
- Task.CreateBatchOperation taskCreate = Task.create().setName(taskName)
- .setMediaProcessorId(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS))
+ String taskBody = getTaskBody(inputAssetId, outputAssetId);
+ Task.CreateBatchOperation taskCreate = Task
+ .create(getMediaProcessorIdByName(MEDIA_PROCESSOR_SMOOTH_STREAMS_TO_HLS), taskBody).setName(taskName)
.setConfiguration(configSmoothStreamsToAppleHttpLiveStreams);
- setTaskBody(taskCreate, inputAssetId, outputAssetId);
+
return taskCreate;
}
- private void setTaskBody(Task.CreateBatchOperation taskCreate, int inputAssetId, int outputAssetId) {
- taskCreate.setTaskBody("<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>"
- + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>");
+ private String getTaskBody(int inputAssetId, int outputAssetId) {
+ return "<taskBody><inputAsset>JobInputAsset(" + inputAssetId + ")</inputAsset>"
+ + "<outputAsset>JobOutputAsset(" + outputAssetId + ")</outputAsset></taskBody>";
}
private String getMediaProcessorIdByName(String processorName) throws ServiceException {

0 comments on commit 656e491

Please sign in to comment.