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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations