diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java index fcd0f4111099a..9bd0954e367ee 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/media/JobIntegrationTest.java +++ b/microsoft-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 @@ 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()); @@ -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 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()); + } } }); }