use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class BoundaryTimerEventTest method testExpressionOnTimer.
@Deployment
public void testExpressionOnTimer() {
// Set the clock fixed
Date startTime = new Date();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("duration", "PT1H");
// After process start, there should be a timer created
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);
TimerJobQuery jobQuery = managementService.createTimerJobQuery().processInstanceId(pi.getId());
List<Job> jobs = jobQuery.list();
assertThat(jobs).hasSize(1);
// After setting the clock to time '1 hour and 5 seconds', the second
// timer should fire
processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000)));
waitForJobExecutorToProcessAllJobs(5000L, 25L);
assertThat(jobQuery.count()).isEqualTo(0L);
// start execution listener is not executed
assertThat(listenerExecutedStartEvent).isFalse();
assertThat(listenerExecutedEndEvent).isTrue();
// which means the process has ended
assertProcessEnded(pi.getId());
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByDuedateLowerThan.
public void testQueryByDuedateLowerThan() {
JobQuery query = managementService.createJobQuery().duedateLowerThan(testStartTime);
verifyQueryResults(query, 0);
TimerJobQuery timerQuery = managementService.createTimerJobQuery().duedateLowerThan(testStartTime);
verifyQueryResults(timerQuery, 0);
timerQuery = managementService.createTimerJobQuery().duedateLowerThan(new Date(timerOneFireTime.getTime() + ONE_SECOND));
verifyQueryResults(timerQuery, 1);
timerQuery = managementService.createTimerJobQuery().duedateLowerThan(new Date(timerTwoFireTime.getTime() + ONE_SECOND));
verifyQueryResults(timerQuery, 2);
timerQuery = managementService.createTimerJobQuery().duedateLowerThan(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
verifyQueryResults(timerQuery, 3);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByDuedateHigherThan.
public void testQueryByDuedateHigherThan() {
JobQuery query = managementService.createJobQuery().duedateHigherThan(testStartTime);
verifyQueryResults(query, 0);
query = managementService.createJobQuery();
verifyQueryResults(query, 1);
TimerJobQuery timerQuery = managementService.createTimerJobQuery().duedateHigherThan(testStartTime);
verifyQueryResults(timerQuery, 3);
query = managementService.createJobQuery().duedateHigherThan(timerOneFireTime);
verifyQueryResults(query, 0);
timerQuery = managementService.createTimerJobQuery().duedateHigherThan(timerOneFireTime);
verifyQueryResults(timerQuery, 2);
timerQuery = managementService.createTimerJobQuery().duedateHigherThan(timerTwoFireTime);
verifyQueryResults(timerQuery, 1);
timerQuery = managementService.createTimerJobQuery().duedateHigherThan(timerThreeFireTime);
verifyQueryResults(timerQuery, 0);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByInvalidProcessInstanceId.
public void testQueryByInvalidProcessInstanceId() {
TimerJobQuery query = managementService.createTimerJobQuery().processInstanceId("invalid");
verifyQueryResults(query, 0);
assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> managementService.createJobQuery().processInstanceId(null));
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByProcessInstanceId.
public void testQueryByProcessInstanceId() {
TimerJobQuery query = managementService.createTimerJobQuery().processInstanceId(processInstanceIdOne);
verifyQueryResults(query, 1);
}
Aggregations