Search in sources :

Example 16 with JobQuery

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

the class JobQueryTest method testQuerySorting.

//sorting //////////////////////////////////////////
public void testQuerySorting() {
    // asc
    assertEquals(4, managementService.createJobQuery().orderByJobId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobDuedate().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByExecutionId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().asc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobRetries().asc().count());
    // desc
    assertEquals(4, managementService.createJobQuery().orderByJobId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobDuedate().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByExecutionId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().desc().count());
    assertEquals(4, managementService.createJobQuery().orderByJobRetries().desc().count());
    // sorting on multiple fields
    setRetries(processInstanceIdTwo, 2);
    // make sure all timers can fire
    processEngineConfiguration.getClock().setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
    JobQuery query = managementService.createJobQuery().timers().executable().orderByJobRetries().asc().orderByJobDuedate().desc();
    List<Job> jobs = query.list();
    assertEquals(3, jobs.size());
    assertEquals(2, jobs.get(0).getRetries());
    assertEquals(3, jobs.get(1).getRetries());
    assertEquals(3, jobs.get(2).getRetries());
    assertEquals(processInstanceIdTwo, jobs.get(0).getProcessInstanceId());
    assertEquals(processInstanceIdThree, jobs.get(1).getProcessInstanceId());
    assertEquals(processInstanceIdOne, jobs.get(2).getProcessInstanceId());
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) Job(org.activiti.engine.runtime.Job) Date(java.util.Date)

Example 17 with JobQuery

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

the class JobQueryTest method testQueryByExceptionMessage.

@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testQueryByExceptionMessage() {
    JobQuery query = managementService.createJobQuery().exceptionMessage(EXCEPTION_MESSAGE);
    verifyQueryResults(query, 0);
    ProcessInstance processInstance = startProcessInstanceWithFailingJob();
    query = managementService.createJobQuery().exceptionMessage(EXCEPTION_MESSAGE);
    verifyFailedJob(query, processInstance);
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 18 with JobQuery

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

the class JobQueryTest method testQueryByExceptionMessageEmpty.

@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testQueryByExceptionMessageEmpty() {
    JobQuery query = managementService.createJobQuery().exceptionMessage("");
    verifyQueryResults(query, 0);
    startProcessInstanceWithFailingJob();
    query = managementService.createJobQuery().exceptionMessage("");
    verifyQueryResults(query, 0);
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) Deployment(org.activiti.engine.test.Deployment)

Example 19 with JobQuery

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

the class JobQueryTest method testQueryByException.

@Deployment(resources = { "org/activiti/engine/test/api/mgmt/ManagementServiceTest.testGetJobExceptionStacktrace.bpmn20.xml" })
public void testQueryByException() {
    JobQuery query = managementService.createJobQuery().withException();
    verifyQueryResults(query, 0);
    ProcessInstance processInstance = startProcessInstanceWithFailingJob();
    query = managementService.createJobQuery().processInstanceId(processInstance.getId()).withException();
    verifyFailedJob(query, processInstance);
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) Deployment(org.activiti.engine.test.Deployment)

Example 20 with JobQuery

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

the class JobQueryTest method testQueryByExecutable.

public void testQueryByExecutable() {
    // all jobs should be executable at t3 + 1hour.1second
    processEngineConfiguration.getClock().setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
    JobQuery query = managementService.createJobQuery().executable();
    verifyQueryResults(query, 4);
    // Setting retries of one job to 0, makes it non-executable
    setRetries(processInstanceIdOne, 0);
    verifyQueryResults(query, 3);
    // Setting the clock before the start of the process instance, makes none of the jobs executable
    processEngineConfiguration.getClock().setCurrentTime(testStartTime);
    verifyQueryResults(query, 0);
}
Also used : JobQuery(org.activiti.engine.runtime.JobQuery) Date(java.util.Date)

Aggregations

JobQuery (org.activiti.engine.runtime.JobQuery)39 Deployment (org.activiti.engine.test.Deployment)20 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)17 Date (java.util.Date)15 Job (org.activiti.engine.runtime.Job)9 Task (org.activiti.engine.task.Task)5 HashMap (java.util.HashMap)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)2 Execution (org.activiti.engine.runtime.Execution)2 ProcessInstanceQuery (org.activiti.engine.runtime.ProcessInstanceQuery)2 Test (org.junit.Test)2 InOrder (org.mockito.InOrder)2 ArrayList (java.util.ArrayList)1 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)1