Search in sources :

Example 1 with GetUnlockedTimersByDuedateCmd

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());
}
Also used : TimerEntity(org.activiti.engine.impl.persistence.entity.TimerEntity) Calendar(java.util.Calendar) CommandExecutor(org.activiti.engine.impl.interceptor.CommandExecutor) GetUnlockedTimersByDuedateCmd(org.activiti.engine.impl.jobexecutor.GetUnlockedTimersByDuedateCmd) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Page(org.activiti.engine.impl.Page) Deployment(org.activiti.engine.test.Deployment)

Aggregations

Calendar (java.util.Calendar)1 Page (org.activiti.engine.impl.Page)1 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)1 GetUnlockedTimersByDuedateCmd (org.activiti.engine.impl.jobexecutor.GetUnlockedTimersByDuedateCmd)1 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Deployment (org.activiti.engine.test.Deployment)1