Search in sources :

Example 1 with TimerJobQuery

use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.

the class JobQueryTest method testQueryByNoCriteria.

public void testQueryByNoCriteria() {
    JobQuery query = managementService.createJobQuery();
    verifyQueryResults(query, 1);
    TimerJobQuery timerQuery = managementService.createTimerJobQuery();
    verifyQueryResults(timerQuery, 3);
}
Also used : TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) JobQuery(org.activiti.engine.runtime.JobQuery) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 2 with TimerJobQuery

use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.

the class JobQueryTest method testQueryByOnlyTimers.

public void testQueryByOnlyTimers() {
    JobQuery query = managementService.createJobQuery().timers();
    verifyQueryResults(query, 0);
    TimerJobQuery timerQuery = managementService.createTimerJobQuery().timers();
    verifyQueryResults(timerQuery, 3);
}
Also used : TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) JobQuery(org.activiti.engine.runtime.JobQuery) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 3 with TimerJobQuery

use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.

the class JobQueryTest method testQueryByExecutionId.

public void testQueryByExecutionId() {
    Job job = managementService.createTimerJobQuery().processInstanceId(processInstanceIdOne).singleResult();
    TimerJobQuery query = managementService.createTimerJobQuery().executionId(job.getExecutionId());
    assertThat(job.getId()).isEqualTo(query.singleResult().getId());
    verifyQueryResults(query, 1);
}
Also used : Job(org.activiti.engine.runtime.Job) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 4 with TimerJobQuery

use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.

the class JobQueryTest method testQueryByInvalidExecutionId.

public void testQueryByInvalidExecutionId() {
    JobQuery query = managementService.createJobQuery().executionId("invalid");
    verifyQueryResults(query, 0);
    TimerJobQuery timerQuery = managementService.createTimerJobQuery().executionId("invalid");
    verifyQueryResults(timerQuery, 0);
    assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> managementService.createJobQuery().executionId(null).list());
    assertThatExceptionOfType(ActivitiIllegalArgumentException.class).isThrownBy(() -> managementService.createTimerJobQuery().executionId(null).list());
}
Also used : ActivitiIllegalArgumentException(org.activiti.engine.ActivitiIllegalArgumentException) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery) JobQuery(org.activiti.engine.runtime.JobQuery) TimerJobQuery(org.activiti.engine.runtime.TimerJobQuery)

Example 5 with TimerJobQuery

use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.

the class ProcessInstanceQueryAndWithExceptionTest method testQueryWithException.

public void testQueryWithException() throws InterruptedException {
    ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
    ProcessInstanceQuery queryNoException = runtimeService.createProcessInstanceQuery();
    assertThat(queryNoException.count()).isEqualTo(1);
    assertThat(queryNoException.list()).hasSize(1);
    assertThat(queryNoException.list().get(0).getId()).isEqualTo(processNoException.getId());
    ProcessInstanceQuery queryWithException = runtimeService.createProcessInstanceQuery();
    assertThat(queryWithException.withJobException().count()).isEqualTo(0);
    assertThat(queryWithException.withJobException().list()).hasSize(0);
    ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
    TimerJobQuery jobQuery1 = managementService.createTimerJobQuery().processInstanceId(processWithException1.getId());
    assertThat(jobQuery1.withException().count()).isEqualTo(1);
    assertThat(jobQuery1.withException().list()).hasSize(1);
    assertThat(queryWithException.withJobException().count()).isEqualTo(1);
    assertThat(queryWithException.withJobException().list()).hasSize(1);
    assertThat(queryWithException.withJobException().list().get(0).getId()).isEqualTo(processWithException1.getId());
    ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
    TimerJobQuery jobQuery2 = managementService.createTimerJobQuery().processInstanceId(processWithException2.getId());
    assertThat(jobQuery2.withException().count()).isEqualTo(2);
    assertThat(jobQuery2.withException().list()).hasSize(2);
    assertThat(queryWithException.withJobException().count()).isEqualTo(2);
    assertThat(queryWithException.withJobException().list()).hasSize(2);
    assertThat(queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId()).isEqualTo(processWithException1.getId());
    assertThat(queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId()).isEqualTo(processWithException2.getId());
}
Also used : ProcessInstanceQuery(org.activiti.engine.runtime.ProcessInstanceQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) 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