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());
// Cancel execution
ScheduleExecution scheduleExecutionModified = scheduleExecutionManagementService.cancelExecution(
scheduleExecution.getId());
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertNull(scheduleExecutionModified.getFinished());
Assert.assertTrue(scheduleExecutionModified.isCancelled());
entityManager.flush();
entityManager.clear();
scheduleExecutionModified = scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertNull(scheduleExecutionModified.getFinished());
Assert.assertTrue(scheduleExecutionModified.isCancelled());
// Finish execution
scheduleExecutionModified = scheduleExecutionManagementService.finishExecution(
scheduleExecution.getId(), ScheduleExecutionStatus.SUCCEED);
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertNotNull(scheduleExecutionModified.getFinished());
entityManager.flush();
entityManager.clear();
scheduleExecutionModified =
scheduleExecutionManagementService.findExecution(scheduleExecution.getId());
Assert.assertNotNull(scheduleExecutionModified);
Assert.assertNotNull(scheduleExecutionModified.getFinished());
Assert.assertFalse(scheduleExecutionModified.isCancelled());
}