use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
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());
assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().asc().count());
assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().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());
assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().desc().count());
assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().desc().count());
// sorting on multiple fields
setRetries(processInstanceIdTwo, 2);
// make sure all timers can fire
ClockUtil.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.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryByNoCriteria.
public void testQueryByNoCriteria() {
JobQuery query = managementService.createJobQuery();
verifyQueryResults(query, 4);
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryByOnlyTimers.
public void testQueryByOnlyTimers() {
JobQuery query = managementService.createJobQuery().timers();
verifyQueryResults(query, 3);
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryByInvalidProcessDefinitionKey.
public void testQueryByInvalidProcessDefinitionKey() {
JobQuery query = managementService.createJobQuery().processDefinitionKey("invalid");
verifyQueryResults(query, 0);
try {
managementService.createJobQuery().processDefinitionKey(null).list();
fail();
} catch (ProcessEngineException e) {
}
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryByException.
@Deployment(resources = { "org/camunda/bpm/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().withException();
verifyFailedJob(query, processInstance);
}
Aggregations