use of org.activiti.engine.runtime.JobQuery in project Activiti by Activiti.
the class StartTimerEventTest method testExpressionStartTimerEvent.
@Deployment
public void testExpressionStartTimerEvent() throws Exception {
// ACT-1415: fixed start-date is an expression
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
processEngineConfiguration.getClock().setCurrentTime(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("15/11/2036 11:12:30"));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
assertEquals(1, pi.size());
assertEquals(0, jobQuery.count());
}
use of org.activiti.engine.runtime.JobQuery 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
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
final ProcessInstanceQuery piq = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample");
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 1 == piq.count();
}
});
assertEquals(1, jobQuery.count());
moveByMinutes(5);
waitForJobExecutorOnCondition(10000, 500, new Callable<Boolean>() {
public Boolean call() throws Exception {
return 2 == piq.count();
}
});
assertEquals(1, jobQuery.count());
//have to manually delete pending timer
cleanDB();
}
use of org.activiti.engine.runtime.JobQuery 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
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// 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
assertEquals(1, jobQuery.count());
}
use of org.activiti.engine.runtime.JobQuery 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
JobQuery jobQuery = managementService.createJobQuery();
assertEquals(1, jobQuery.count());
// After setting the clock to time '50minutes and 5 seconds', the second timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
assertEquals(1, pi.size());
assertEquals(0, jobQuery.count());
}
use of org.activiti.engine.runtime.JobQuery 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");
JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());
assertEquals(3, jobQuery.count());
// 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)));
waitForJobExecutorToProcessAllJobs(5000L, 100L);
assertEquals(0, jobQuery.count());
assertProcessEnded(pi.getProcessInstanceId());
}
Aggregations