Search in sources :

Example 6 with Page

use of org.activiti.engine.impl.Page 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

Page (org.activiti.engine.impl.Page)6 JobEntity (org.activiti.engine.impl.persistence.entity.JobEntity)3 AcquiredJobEntities (org.activiti.engine.impl.asyncexecutor.AcquiredJobEntities)2 CommandExecutor (org.activiti.engine.impl.interceptor.CommandExecutor)2 TimerEntity (org.activiti.engine.impl.persistence.entity.TimerEntity)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1 SimulationEvent (org.activiti.crystalball.simulator.SimulationEvent)1 ActivitiOptimisticLockingException (org.activiti.engine.ActivitiOptimisticLockingException)1 ProcessDefinitionQueryImpl (org.activiti.engine.impl.ProcessDefinitionQueryImpl)1 AcquiredJobs (org.activiti.engine.impl.jobexecutor.AcquiredJobs)1 GetUnlockedTimersByDuedateCmd (org.activiti.engine.impl.jobexecutor.GetUnlockedTimersByDuedateCmd)1 MessageEntity (org.activiti.engine.impl.persistence.entity.MessageEntity)1 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 Deployment (org.activiti.engine.test.Deployment)1