Skip to content

Commit

Permalink
Remove TODO in JobIntegration test by adding validation for the numbe…
Browse files Browse the repository at this point in the history
…r of tasks.

For #593
  • Loading branch information
jcookems committed Jan 8, 2013
1 parent 1e0beaa commit f86ea9c
Showing 1 changed file with 18 additions and 9 deletions.
Expand Up @@ -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;
Expand All @@ -40,16 +41,16 @@ public class JobIntegrationTest extends IntegrationTestBase {

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());
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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());
}
}
});
}
Expand Down

0 comments on commit f86ea9c

Please sign in to comment.