use of org.activiti.engine.impl.jobexecutor.GetUnlockedTimersByDuedateCmd in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testSuspendedProcessTimerExecution.
@Deployment
public void testSuspendedProcessTimerExecution() throws Exception {
// Process with boundary timer-event that fires in 1 hour
ProcessInstance procInst = runtimeService.startProcessInstanceByKey("suspendProcess");
assertNotNull(procInst);
assertEquals(1, managementService.createJobQuery().processInstanceId(procInst.getId()).count());
// Roll time ahead to be sure timer is due to fire
Calendar tomorrow = Calendar.getInstance();
tomorrow.add(Calendar.DAY_OF_YEAR, 1);
processEngineConfiguration.getClock().setCurrentTime(tomorrow.getTime());
// Check if timer is eligable to be executed, when process in not yet suspended
CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor();
List<TimerEntity> jobs = commandExecutor.execute(new GetUnlockedTimersByDuedateCmd(processEngineConfiguration.getClock().getCurrentTime(), new Page(0, 1)));
assertEquals(1, jobs.size());
// Suspend process instancd
runtimeService.suspendProcessInstanceById(procInst.getId());
// Check if the timer is NOT aquired, even though the duedate is reached
jobs = commandExecutor.execute(new GetUnlockedTimersByDuedateCmd(processEngineConfiguration.getClock().getCurrentTime(), new Page(0, 1)));
assertEquals(0, jobs.size());
}
Aggregations