Permalink
Browse files

fix broken unit tests

  • Loading branch information...
1 parent 87dcf54 commit eca474166880de4688056f9deadcdaa16b8ce176 Albert Cheng committed Dec 19, 2012
@@ -40,10 +40,11 @@ public void ProtectionKeyIdReturnsPayloadWithTheRightProtectionKeyType() {
@Test
public void ProtectionKeyReturnsPayloadWithTheRightProtectionKeyId() {
- String expectedProtectionKey = "expectedProtectionKey";
- String actualProtectionKey = ProtectionKey.getProtectionKey(expectedProtectionKey).getQueryParameters()
+ String expectedProtectionKeyId = "expectedProtectionKey";
+ String actualProtectionKeyId = ProtectionKey.getProtectionKey(expectedProtectionKeyId).getQueryParameters()
.getFirst("ProtectionKeyId");
+ expectedProtectionKeyId = String.format("'%s'", expectedProtectionKeyId);
- assertEquals(expectedProtectionKey, actualProtectionKey);
+ assertEquals(expectedProtectionKeyId, actualProtectionKeyId);
}
}
@@ -19,18 +19,12 @@
import java.net.URLEncoder;
-import javax.ws.rs.core.MultivaluedMap;
import javax.xml.bind.JAXBElement;
import org.junit.Test;
import com.microsoft.windowsazure.services.media.implementation.atom.EntryType;
import com.microsoft.windowsazure.services.media.implementation.content.TaskType;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityDeleteOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityGetOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityListOperation;
-import com.microsoft.windowsazure.services.media.implementation.entities.EntityUpdateOperation;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
/**
* Tests for the methods and factories of the Task entity.
@@ -56,7 +50,7 @@ public TaskEntityTest() throws Exception {
}
@Test
- public void TaskCreateReturnsDefaultCreatePayload() {
+ public void taskCreateReturnsDefaultCreatePayload() {
String expectedMediaProcessorId = "expectedMediaProcessorId";
String expectedTaskBody = "expectedTaskBody";
@@ -68,7 +62,7 @@ public void TaskCreateReturnsDefaultCreatePayload() {
}
@Test
- public void TaskCreateCanSetTaskName() {
+ public void taskCreateCanSetTaskName() {
String expectedName = "TaskCreateCanSetTaskName";
String expectedMediaProcessorId = "expectedMediaProcessorId";
@@ -82,83 +76,100 @@ public void TaskCreateCanSetTaskName() {
}
@Test
- public void TaskGetReturnsExpectedUri() throws Exception {
- String expectedUri = String.format("Tasks('%s')", URLEncoder.encode(sampleTaskId, "UTF-8"));
+ public void taskCreateCanSetConfiguration() {
+ String expectedConfiguration = "TaskCreateCanSetTaskCofniguration";
- EntityGetOperation<TaskInfo> getter = Task.get(sampleTaskId);
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
+
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setConfiguration(expectedConfiguration).getEntryType());
- assertEquals(expectedUri, getter.getUri());
+ assertNotNull(taskType);
+ assertEquals(expectedConfiguration, taskType.getConfiguration());
}
@Test
- public void TaskListReturnsExpectedUri() {
- EntityListOperation<TaskInfo> lister = Task.list();
+ public void taskCreateCanSetPriority() {
+ Integer expectedPriority = 3;
- assertEquals("Tasks", lister.getUri());
- assertNotNull(lister.getQueryParameters());
- assertEquals(0, lister.getQueryParameters().size());
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
+
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setPriority(expectedPriority).getEntryType());
+
+ assertNotNull(taskType);
+ assertEquals(expectedPriority, taskType.getPriority());
}
@Test
- public void TaskListCanTakeQueryParameters() {
- MultivaluedMap<String, String> queryParams = new MultivaluedMapImpl();
- queryParams.add("$top", "10");
- queryParams.add("$skip", "2");
+ public void taskCreateCanSetTaskBody() {
+ String expectedTaskBodyResult = "expectedTaskBodyResult";
- EntityListOperation<TaskInfo> lister = Task.list(queryParams);
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
- assertEquals("10", lister.getQueryParameters().getFirst("$top"));
- assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
- assertEquals(2, lister.getQueryParameters().size());
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setTaskBody(expectedTaskBodyResult).getEntryType());
+
+ assertNotNull(taskType);
+ assertEquals(expectedTaskBodyResult, taskType.getTaskBody());
}
@Test
- public void TaskListCanTakeQueryParametersChained() {
- EntityListOperation<TaskInfo> lister = Task.list().setTop(10).setSkip(2).set("filter", "something");
+ public void taskCreateCanSetEncryptionKeyId() {
+ String expectedEncryptionKeyId = "expectedEncryptionKeyId";
- assertEquals("10", lister.getQueryParameters().getFirst("$top"));
- assertEquals("2", lister.getQueryParameters().getFirst("$skip"));
- assertEquals("something", lister.getQueryParameters().getFirst("filter"));
- assertEquals(3, lister.getQueryParameters().size());
- }
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
- @Test
- public void TaskUpdateReturnsExpectedUri() throws Exception {
- EntityUpdateOperation updater = Task.update(sampleTaskId);
- assertEquals(expectedUri, updater.getUri());
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setEncryptionKeyId(expectedEncryptionKeyId).getEntryType());
+
+ assertNotNull(taskType);
+ assertEquals(expectedEncryptionKeyId, taskType.getTaskBody());
}
@Test
- public void TaskUpdateCanSetNameAndAltId() throws Exception {
-
- String expectedName = "newTaskName";
- String expectedAltId = "newAltId";
+ public void taskCreateCanSetEncryptionScheme() {
+ String expectedEncryptionScheme = "expectedEncryptionScheme";
- EntityUpdateOperation updater = Task.update(sampleTaskId).setName(expectedName).setAlternateId(expectedAltId);
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
- TaskType payload = (TaskType) updater.getRequestContents();
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setEncryptionScheme(expectedEncryptionScheme).getEntryType());
- assertEquals(expectedName, payload.getName());
- assertEquals(expectedAltId, payload.getAlternateId());
+ assertNotNull(taskType);
+ assertEquals(expectedEncryptionScheme, taskType.getEncryptionScheme());
}
@Test
- public void TaskDeleteReturnsExpectedUri() throws Exception {
- EntityDeleteOperation deleter = Task.delete(sampleTaskId);
+ public void taskCreateCanSetEncryptionVersion() {
+ String expectedEncryptionVersion = "expectedEncryptionVersion";
- assertEquals(expectedUri, deleter.getUri());
- }
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
- private static final String expectedOutputTask = "Job(someJobId)/OutputTasks";
- private static final String expectedInputTask = "Job(someJobId)/InputTasks";
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setEncryptionVersion(expectedEncryptionVersion).getEntryType());
+
+ assertNotNull(taskType);
+ assertEquals(expectedEncryptionVersion, taskType.getTaskBody());
+ }
@Test
- public void listForLinkReturnsExpectedUri() throws Exception {
- JobInfo fakeJob = createJob();
+ public void taskCreateCanSetInitializationVector() {
+ String expectedInitializationVector = "expectedEncryptionKeyId";
+
+ String expectedMediaProcessorId = "expectedMediaProcessorId";
+ String expectedTaskBody = "expectedTaskBody";
- EntityListOperation<TaskInfo> lister = Task.list(fakeJob.getInputTasksLink());
+ TaskType taskType = getTaskType(Task.create(expectedMediaProcessorId, expectedTaskBody)
+ .setEncryptionKeyId(expectedInitializationVector).getEntryType());
- assertEquals(lister.getUri(), expectedInputTask);
+ assertNotNull(taskType);
+ assertEquals(expectedInitializationVector, taskType.getTaskBody());
}
-
}

0 comments on commit eca4741

Please sign in to comment.