use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class ExclusiveTimerEventTest method testCatchingTimerEvent.
@Deployment
public void testCatchingTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be 3 timers created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveTimers");
TimerJobQuery jobQuery = managementService.createTimerJobQuery().processInstanceId(pi.getId());
assertThat(jobQuery.count()).isEqualTo(3);
// After setting the clock to time '50minutes and 5 seconds', the timers should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobsAndExecutableTimerJobs(5000L, 500L);
assertThat(jobQuery.count()).isEqualTo(0);
assertProcessEnded(pi.getProcessInstanceId());
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class StartTimerEventTest method testDurationStartTimerEvent.
@Deployment
public void testDurationStartTimerEvent() throws Exception {
// Set the clock fixed
Date startTime = new Date();
// After process start, there should be timer created
TimerJobQuery jobQuery = managementService.createTimerJobQuery();
assertThat(jobQuery.count()).isEqualTo(1);
// After setting the clock to time '50 minutes and 5 seconds', the second timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 200L);
List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
assertThat(pi).hasSize(1);
assertThat(jobQuery.count()).isEqualTo(0);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class StartTimerEventTest method testCycleDateStartTimerEvent.
// FIXME: This test likes to run in an endless loop when invoking the
// waitForJobExecutorOnCondition method
@Deployment
public void testCycleDateStartTimerEvent() throws Exception {
processEngineConfiguration.getClock().setCurrentTime(new Date());
// After process start, there should be timer created
TimerJobQuery jobQuery = managementService.createTimerJobQuery();
assertThat(jobQuery.count()).isEqualTo(1);
final ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 1 == piq.count();
}
});
assertThat(jobQuery.count()).isEqualTo(1);
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 2 == piq.count();
}
});
assertThat(jobQuery.count()).isEqualTo(1);
// have to manually delete pending timer
cleanDB();
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class StartTimerEventTest method testTimerShouldNotBeRecreatedOnDeploymentCacheReboot.
@Deployment
public void testTimerShouldNotBeRecreatedOnDeploymentCacheReboot() {
// Just to be sure, I added this test. Sounds like something that could easily happen
// when the order of deploy/parsing is altered.
// After process start, there should be timer created
TimerJobQuery jobQuery = managementService.createTimerJobQuery();
assertThat(jobQuery.count()).isEqualTo(1);
// Reset deployment cache
processEngineConfiguration.getProcessDefinitionCache().clear();
// Start one instance of the process definition, this will trigger a
// cache reload
runtimeService.startProcessInstanceByKey("startTimer");
// No new jobs should have been created
assertThat(jobQuery.count()).isEqualTo(1);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class StartTimerEventTest method testExpressionStartTimerEvent.
@Deployment
public void testExpressionStartTimerEvent() throws Exception {
// ACT-1415: fixed start-date is an expression
TimerJobQuery jobQuery = managementService.createTimerJobQuery();
assertThat(jobQuery.count()).isEqualTo(1);
processEngineConfiguration.getClock().setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30"));
waitForJobExecutorToProcessAllJobs(5000L, 200L);
List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
assertThat(pi).hasSize(1);
assertThat(jobQuery.count()).isEqualTo(0);
}
Aggregations