StartExecutionParameters startExecutionParameters = new StartExecutionParameters();
startExecutionParameters.setManual(false);
startExecutionParameters.setFired(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));
startExecutionParameters.setScheduled(ChronometerUtils.parseMoment("2012-01-02 12:32:12.000 UTC"));
ScheduleExecution scheduleExecution =
scheduleExecutionManagementService.startExecution(scheduleJob.getId(), startExecutionParameters);
Assert.assertNotNull(scheduleExecution);
Assert.assertNull(scheduleExecution.getFinished());
entityManager.flush();
entityManager.clear();
ScheduleExecution scheduleExecutionModified =
scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertEquals(scheduleExecution, scheduleExecutionModified);
Assert.assertEquals(ScheduleExecutionStatus.INPROGRESS, scheduleExecutionModified.getStatus());
Assert.assertEquals(3, scheduleExecutionModified.getNodes().size());
ScheduleExecutionNode scheduleExecutionNode1 = scheduleExecutionModified.getNodes().get(0);
Assert.assertNotNull(scheduleExecutionNode1);
Assert.assertEquals(0, scheduleExecutionNode1.getOrderIndex());
Assert.assertEquals(clusterNode2.getAddress(), scheduleExecutionNode1.getAddress());
ScheduleExecutionNode scheduleExecutionNode2 = scheduleExecutionModified.getNodes().get(1);
Assert.assertNotNull(scheduleExecutionNode2);
Assert.assertEquals(1, scheduleExecutionNode2.getOrderIndex());
Assert.assertEquals(clusterNode3.getAddress(), scheduleExecutionNode2.getAddress());
ScheduleExecutionNode scheduleExecutionNode3 = scheduleExecutionModified.getNodes().get(2);
Assert.assertNotNull(scheduleExecutionNode3);
Assert.assertEquals(2, scheduleExecutionNode3.getOrderIndex());
Assert.assertEquals(clusterNode1.getAddress(), scheduleExecutionNode3.getAddress());
// Search all executions
List<ScheduleExecution> scheduleExecutions = scheduleExecutionManagementService.findAll(Extraction.ALL);
Assert.assertNotNull(scheduleExecutions);
Assert.assertTrue(scheduleExecutions.size() > 0);
Assert.assertTrue(Iterators.contains(scheduleExecutions.iterator(), scheduleExecution));
// Make some progress
ScheduleExecutionResult scheduleExecutionResult;
scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode1.getId());
Assert.assertNotNull(scheduleExecutionResult);
scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
true, null);
Assert.assertNotNull(scheduleExecutionResult);
scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode2.getId());
Assert.assertNotNull(scheduleExecutionResult);
scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
true, null);
Assert.assertNotNull(scheduleExecutionResult);
scheduleExecutionResult = scheduleExecutionManagementService.startExecutionResult(scheduleExecutionNode3.getId());
Assert.assertNotNull(scheduleExecutionResult);
scheduleExecutionResult = scheduleExecutionManagementService.finishExecutionResult(scheduleExecutionResult.getId(),
false, null);
Assert.assertNotNull(scheduleExecutionResult);
entityManager.flush();
entityManager.clear();
scheduleExecutionModified =
scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertEquals(scheduleExecution, scheduleExecutionModified);
Assert.assertEquals(3, scheduleExecutionModified.getResults().size());
scheduleExecutionResult = scheduleExecutionModified.getResults().get(0);
Assert.assertNotNull(scheduleExecutionResult);
Assert.assertEquals(0, scheduleExecutionResult.getOrderIndex());
Assert.assertTrue(scheduleExecutionResult.isSucceed());
scheduleExecutionResult = scheduleExecutionModified.getResults().get(1);
Assert.assertNotNull(scheduleExecutionResult);
Assert.assertEquals(1, scheduleExecutionResult.getOrderIndex());
Assert.assertTrue(scheduleExecutionResult.isSucceed());
scheduleExecutionResult = scheduleExecutionModified.getResults().get(2);
Assert.assertEquals(2, scheduleExecutionResult.getOrderIndex());
Assert.assertNotNull(scheduleExecutionResult);
Assert.assertFalse(scheduleExecutionResult.isSucceed());
// Finish execution
scheduleExecutionModified = scheduleExecutionManagementService.finishExecution(
scheduleExecution.getId(), ScheduleExecutionStatus.SUCCEED);
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertNotNull(scheduleExecutionModified.getFinished());
entityManager.flush();
entityManager.clear();
scheduleExecutionModified =