Search in sources :

Example 11 with TimerJobQuery

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());
}
Also used : HashMap(java.util.HashMap) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Job(org.activiti.engine.runtime.Job) Date(java.util.Date) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) Deployment(org.activiti.engine.test.Deployment)

Example 12 with TimerJobQuery

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);
}
Also used : TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) JobQuery(org.activiti.engine.runtime.JobQuery) Date(java.util.Date) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 13 with TimerJobQuery

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);
}
Also used : TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) JobQuery(org.activiti.engine.runtime.JobQuery) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 14 with TimerJobQuery

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));
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 15 with TimerJobQuery

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);
}
Also used : TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Aggregations

TimerJobQuery (org.activiti.engine.runtime.TimerJobQuery)35 Deployment (org.activiti.engine.test.Deployment)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)18 Date (java.util.Date)16 Job (org.activiti.engine.runtime.Job)10 JobQuery (org.activiti.engine.runtime.JobQuery)7 Task (org.activiti.engine.task.Task)5 HashMap (java.util.HashMap)3 Execution (org.activiti.engine.runtime.Execution)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 List (java.util.List)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1 Test (org.junit.Test)1