Java Code Examples for org.camunda.bpm.engine.runtime.JobQuery#list()
The following examples show how to use
org.camunda.bpm.engine.runtime.JobQuery#list() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Override public List<JobDto> queryJobs(JobQueryDto queryDto, Integer firstResult, Integer maxResults) { ProcessEngine engine = getProcessEngine(); queryDto.setObjectMapper(getObjectMapper()); JobQuery query = queryDto.toQuery(engine); List<Job> matchingJobs; if (firstResult != null || maxResults != null) { matchingJobs = executePaginatedQuery(query, firstResult, maxResults); } else { matchingJobs = query.list(); } List<JobDto> jobResults = new ArrayList<JobDto>(); for (Job job : matchingJobs) { JobDto resultJob = JobDto.fromJob(job); jobResults.add(resultJob); } return jobResults; }
Example 2
Source File: TaskListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment public void testRecalculateTimeoutTaskListenerDuedateCreationDateBased() { // given ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", Variables.putValue("duration", "PT1H")); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); // when runtimeService.setVariable(pi.getId(), "duration", "PT15M"); managementService.recalculateJobDuedate(job.getId(), true); // then Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertTrue(oldDate.after(jobUpdated.getDuedate())); assertEquals(LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(15).toDate(), jobUpdated.getDuedate()); }
Example 3
Source File: TaskListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = "org/camunda/bpm/engine/test/bpmn/tasklistener/TaskListenerTest.testRecalculateTimeoutTaskListenerDuedateCreationDateBased.bpmn20.xml") public void testRecalculateTimeoutTaskListenerDuedateCurrentDateBased() { // given ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", Variables.putValue("duration", "PT1H")); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); ClockUtil.offset(2000L); // when managementService.recalculateJobDuedate(job.getId(), false); // then Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertTrue(oldDate.before(jobUpdated.getDuedate())); }
Example 4
Source File: TaskListenerTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment public void testRecalculateTimeoutTaskListenerDuedateCreationDateBasedWithDefinedBoundaryEvent() { // given ProcessInstance pi = runtimeService.startProcessInstanceByKey("process", Variables.putValue("duration", "PT1H")); JobQuery jobQuery = managementService.createJobQuery() .processInstanceId(pi.getId()) .activityId("userTask"); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); // when runtimeService.setVariable(pi.getId(), "duration", "PT15M"); managementService.recalculateJobDuedate(job.getId(), true); // then Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertTrue(oldDate.after(jobUpdated.getDuedate())); assertEquals(LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(15).toDate(), jobUpdated.getDuedate()); }
Example 5
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment public void testMultipleTimersOnUserTask() { // Set the clock fixed Date startTime = new Date(); // After process start, there should be 3 timers created ProcessInstance pi = runtimeService.startProcessInstanceByKey("multipleTimersOnUserTask"); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(3, jobs.size()); // After setting the clock to time '1 hour and 5 seconds', the second timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means that the third task is reached Task task = taskService.createTaskQuery().singleResult(); assertEquals("Third Task", task.getName()); }
Example 6
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); // After setting the clock to time '1 hour and 5 seconds', the second timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
Example 7
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testRecalculateUnchangedExpressionOnTimerCurrentDateBased.bpmn20.xml") public void testRecalculateChangedExpressionOnTimerCreationDateBased(){ // Set the clock fixed Date startTime = new Date(); HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("duedate", "PT1H"); // After process start, there should be a timer created ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); // After recalculation of the timer, the job's duedate should be the same runtimeService.setVariable(pi.getId(), "duedate", "PT15M"); managementService.recalculateJobDuedate(job.getId(), true); Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertEquals(LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusMinutes(15).toDate(), jobUpdated.getDuedate()); // After setting the clock to time '16 minutes', the timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + TimeUnit.MINUTES.toMillis(16L))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
Example 8
Source File: StartTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void testStartTimerEventSubProcessInParallelMultiInstanceSubProcess() { DummyServiceTask.wasExecuted = false; // start process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("startTimerEventSubProcessInParallelMultiInstanceSubProcess"); // check if execution exists ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()); assertEquals(6, executionQuery.count()); // check if user task exists TaskQuery taskQuery = taskService.createTaskQuery(); assertEquals(2, taskQuery.count()); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(2, jobQuery.count()); // execute timer job for (Job job : jobQuery.list()) { managementService.executeJob(job.getId()); assertEquals(true, DummyServiceTask.wasExecuted); DummyServiceTask.wasExecuted = false; } // check if user task doesn't exist because timer start event is // interrupting assertEquals(0, taskQuery.count()); // check if execution doesn't exist because timer start event is // interrupting assertEquals(0, executionQuery.count()); // check if process instance doesn't exist because timer start event is // interrupting ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()); assertEquals(0, processInstanceQuery.count()); }
Example 9
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testRecalculateUnchangedExpressionOnTimerCurrentDateBased.bpmn20.xml") public void testRecalculateChangedExpressionOnTimerCurrentDateBased(){ // Set the clock fixed Date startTime = new Date(); HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("duedate", "PT1H"); // After process start, there should be a timer created ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); ClockUtil.offset(2000L); // After recalculation of the timer, the job's duedate should be changed managementService.recalculateJobDuedate(job.getId(), false); Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertTrue(oldDate.before(jobUpdated.getDuedate())); // After setting the clock to time '16 minutes', the timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + TimeUnit.HOURS.toMillis(2L))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
Example 10
Source File: JobQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testQueryByCreateTimeCombinations() { JobQuery query = managementService.createJobQuery() .processInstanceId(processInstanceIdOne); List<Job> jobs = query.list(); assertEquals(1, jobs.size()); Date jobCreateTime = jobs.get(0).getCreateTime(); query = managementService.createJobQuery() .processInstanceId(processInstanceIdOne) .createdAfter(new Date(jobCreateTime.getTime() - 1)); verifyQueryResults(query, 1); query = managementService.createJobQuery() .processInstanceId(processInstanceIdOne) .createdAfter(jobCreateTime); verifyQueryResults(query, 0); query = managementService.createJobQuery() .processInstanceId(processInstanceIdOne) .createdBefore(jobCreateTime); verifyQueryResults(query, 1); query = managementService.createJobQuery() .processInstanceId(processInstanceIdOne) .createdBefore(new Date(jobCreateTime.getTime() - 1)); verifyQueryResults(query, 0); }
Example 11
Source File: BoundaryTimerNonInterruptingEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment /* * see http://jira.codehaus.org/browse/ACT-1106 */ @Test public void testReceiveTaskWithBoundaryTimer(){ HashMap<String, Object> variables = new HashMap<>(); variables.put("timeCycle", "R/PT1H"); // After process start, there should be a timer created ProcessInstance pi = runtimeService.startProcessInstanceByKey("nonInterruptingCycle",variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); // The Execution Query should work normally and find executions in state "task" List<Execution> executions = runtimeService.createExecutionQuery() .activityId("task") .list(); assertEquals(1, executions.size()); List<String> activeActivityIds = runtimeService.getActiveActivityIds(executions.get(0).getId()); assertEquals(1, activeActivityIds.size()); assertEquals("task", activeActivityIds.get(0)); runtimeService.signal(executions.get(0).getId()); // // After setting the clock to time '1 hour and 5 seconds', the second timer should fire // ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000))); // waitForJobExecutorToProcessAllJobs(5000L); // assertEquals(0L, jobQuery.count()); // which means the process has ended testHelper.assertProcessEnded(pi.getId()); }
Example 12
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void testRecalculateUnchangedExpressionOnTimerCurrentDateBased(){ // Set the clock fixed Date startTime = new Date(); HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("duedate", "PT1H"); // After process start, there should be a timer created ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); Date oldDate = job.getDuedate(); // After recalculation of the timer, the job's duedate should be changed Date currentTime = new Date(startTime.getTime() + TimeUnit.MINUTES.toMillis(5)); ClockUtil.setCurrentTime(currentTime); managementService.recalculateJobDuedate(job.getId(), false); Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); assertNotEquals(oldDate, jobUpdated.getDuedate()); assertTrue(oldDate.before(jobUpdated.getDuedate())); Date expectedDate = LocalDateTime.fromDateFields(currentTime).plusHours(1).toDate(); assertThat(jobUpdated.getDuedate()).isCloseTo(expectedDate, 1000l); // After setting the clock to time '1 hour and 6 min', the second timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + TimeUnit.HOURS.toMillis(1L) + TimeUnit.MINUTES.toMillis(6L))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
Example 13
Source File: BoundaryTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/event/timer/BoundaryTimerEventTest.testRecalculateUnchangedExpressionOnTimerCurrentDateBased.bpmn20.xml") public void testRecalculateUnchangedExpressionOnTimerCreationDateBased(){ // Set the clock fixed Date startTime = new Date(); HashMap<String, Object> variables = new HashMap<String, Object>(); variables.put("duedate", "PT1H"); // After process start, there should be a timer created ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(1, jobs.size()); Job job = jobs.get(0); // After recalculation of the timer, the job's duedate should be based on the creation date ClockUtil.setCurrentTime(new Date(startTime.getTime() + TimeUnit.SECONDS.toMillis(5))); managementService.recalculateJobDuedate(job.getId(), true); Job jobUpdated = jobQuery.singleResult(); assertEquals(job.getId(), jobUpdated.getId()); Date expectedDate = LocalDateTime.fromDateFields(jobUpdated.getCreateTime()).plusHours(1).toDate(); assertEquals(expectedDate, jobUpdated.getDuedate()); // After setting the clock to time '1 hour and 15 seconds', the second timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + TimeUnit.HOURS.toMillis(1L) + TimeUnit.SECONDS.toMillis(15L))); waitForJobExecutorToProcessAllJobs(5000L); assertEquals(0L, jobQuery.count()); // which means the process has ended assertProcessEnded(pi.getId()); }
Example 14
Source File: BoundaryTimerNonInterruptingEventTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment @Test public void testMultipleTimersOnUserTask() { // Set the clock fixed Date startTime = new Date(); // After process start, there should be 3 timers created ProcessInstance pi = runtimeService.startProcessInstanceByKey("nonInterruptingTimersOnUserTask"); Task task1 = taskService.createTaskQuery().singleResult(); assertEquals("First Task", task1.getName()); JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId()); List<Job> jobs = jobQuery.list(); assertEquals(2, jobs.size()); // After setting the clock to time '1 hour and 5 seconds', the first timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000))); testHelper.waitForJobExecutorToProcessAllJobs(5000L); // we still have one timer more to fire assertEquals(1L, jobQuery.count()); // and we are still in the first state, but in the second state as well! assertEquals(2L, taskService.createTaskQuery().count()); List<Task> taskList = taskService.createTaskQuery().orderByTaskName().desc().list(); assertEquals("First Task", taskList.get(0).getName()); assertEquals("Escalation Task 1", taskList.get(1).getName()); // complete the task and end the forked execution taskService.complete(taskList.get(1).getId()); // but we still have the original executions assertEquals(1L, taskService.createTaskQuery().count()); assertEquals("First Task", taskService.createTaskQuery().singleResult().getName()); // After setting the clock to time '2 hour and 5 seconds', the second timer should fire ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((2 * 60 * 60 * 1000) + 5000))); testHelper.waitForJobExecutorToProcessAllJobs(5000L); // no more timers to fire assertEquals(0L, jobQuery.count()); // and we are still in the first state, but in the next escalation state as well assertEquals(2L, taskService.createTaskQuery().count()); taskList = taskService.createTaskQuery().orderByTaskName().desc().list(); assertEquals("First Task", taskList.get(0).getName()); assertEquals("Escalation Task 2", taskList.get(1).getName()); // This time we end the main task taskService.complete(taskList.get(0).getId()); // but we still have the escalation task assertEquals(1L, taskService.createTaskQuery().count()); Task escalationTask = taskService.createTaskQuery().singleResult(); assertEquals("Escalation Task 2", escalationTask.getName()); taskService.complete(escalationTask.getId()); // now we are really done :-) testHelper.assertProcessEnded(pi.getId()); }
Example 15
Source File: StartTimerEventTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Deployment public void testNonInterruptingStartTimerEventSubProcessWithParallelMultiInstance() { DummyServiceTask.wasExecuted = false; // start process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nonInterruptingParallelMultiInstance"); // check if execution exists ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(processInstance.getId()); assertEquals(6, executionQuery.count()); // check if user task exists TaskQuery taskQuery = taskService.createTaskQuery(); assertEquals(2, taskQuery.count()); JobQuery jobQuery = managementService.createJobQuery(); assertEquals(2, jobQuery.count()); // execute all timer jobs for (Job job : jobQuery.list()) { managementService.executeJob(job.getId()); assertEquals(true, DummyServiceTask.wasExecuted); DummyServiceTask.wasExecuted = false; } assertEquals(0, jobQuery.count()); // check if user task doesn't exist because timer start event is // interrupting assertEquals(2, taskQuery.count()); // check if execution doesn't exist because timer start event is // interrupting assertEquals(6, executionQuery.count()); // check if process instance doesn't exist because timer start event is // interrupting ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId()); assertEquals(1, processInstanceQuery.count()); }
Example 16
Source File: HistoryServiceAsyncOperationsTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void testDeleteHistoryProcessInstancesAsyncWithListForDeletedDeployment() throws Exception { // given a second deployment prepareData(); ProcessDefinitionQuery definitionQuery = engineRule.getRepositoryService().createProcessDefinitionQuery(); String firstDeploymentId = definitionQuery.processDefinitionVersion(1).singleResult().getDeploymentId(); String secondDeploymentId = definitionQuery.processDefinitionVersion(2).singleResult().getDeploymentId(); engineRule.getRepositoryService().deleteDeployment(secondDeploymentId); engineRule.getProcessEngineConfiguration().setInvocationsPerBatchJob(2); // when Batch batch = historyService.deleteHistoricProcessInstancesAsync(historicProcessInstances, TEST_REASON); // then a seed job with the lowest deployment id exist Job seedJob = getSeedJob(batch); assertEquals(firstDeploymentId, seedJob.getDeploymentId()); // when executeSeedJob(batch); // then seedJob = getSeedJob(batch); assertEquals(firstDeploymentId, seedJob.getDeploymentId()); // when executeSeedJob(batch); // then batch jobs with different deployment ids exist JobQuery batchJobQuery = managementService.createJobQuery().jobDefinitionId(batch.getBatchJobDefinitionId()); List<Job> batchJobs = batchJobQuery.list(); assertThat(batchJobs.size(), is(2)); assertThat(batchJobs.get(0).getDeploymentId(), anyOf(is(firstDeploymentId), is(nullValue()))); assertThat(batchJobs.get(1).getDeploymentId(), anyOf(is(firstDeploymentId), is(nullValue()))); assertThat(batchJobs.get(0).getDeploymentId(), is(not(batchJobs.get(1).getDeploymentId()))); assertThat(historicProcessInstances.size(), is(4)); assertThat(getHistoricProcessInstanceCountByDeploymentId(firstDeploymentId), is(2L)); // when the batch jobs for the first deployment are executed getJobIdsByDeployment(batchJobs, firstDeploymentId).forEach(managementService::executeJob); // then the historic process instances related to the first deployment should be deleted assertThat(getHistoricProcessInstanceCountByDeploymentId(firstDeploymentId), is(0L)); // and historic process instances related to the second deployment should not be deleted assertThat(historyService.createHistoricProcessInstanceQuery().count(), is(2L)); // when the remaining batch jobs are executed batchJobQuery.list().forEach(j -> managementService.executeJob(j.getId())); // then assertNoHistoryForTasks(); assertHistoricBatchExists(testRule); assertAllHistoricProcessInstancesAreDeleted(); }
Example 17
Source File: JobQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test 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); ClockUtil.setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND)); // make sure all timers can fire 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()); }