use of org.activiti.engine.runtime.TimerJobQuery 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() {
TimerJobQuery query = managementService.createTimerJobQuery().exceptionMessage(EXCEPTION_MESSAGE);
verifyQueryResults(query, 0);
ProcessInstance processInstance = startProcessInstanceWithFailingJob();
query = managementService.createTimerJobQuery().exceptionMessage(EXCEPTION_MESSAGE);
verifyFailedJob(query, processInstance);
}
use of org.activiti.engine.runtime.TimerJobQuery 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() {
TimerJobQuery query = managementService.createTimerJobQuery().withException();
verifyQueryResults(query, 0);
ProcessInstance processInstance = startProcessInstanceWithFailingJob();
query = managementService.createTimerJobQuery().processInstanceId(processInstance.getId()).withException();
verifyFailedJob(query, processInstance);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByRetriesLeft.
public void testQueryByRetriesLeft() {
JobQuery query = managementService.createJobQuery();
verifyQueryResults(query, 1);
TimerJobQuery timerQuery = managementService.createTimerJobQuery();
verifyQueryResults(timerQuery, 3);
final Job job = managementService.createTimerJobQuery().processInstanceId(processInstanceIdOne).singleResult();
managementService.setTimerJobRetries(job.getId(), 0);
managementService.moveJobToDeadLetterJob(job.getId());
// Re-running the query should give only 3 jobs now, since one job has retries=0
verifyQueryResults(query, 1);
verifyQueryResults(timerQuery, 2);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQuerySorting.
// sorting //////////////////////////////////////////
public void testQuerySorting() {
// asc
assertThat(managementService.createJobQuery().orderByJobId().asc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByJobDuedate().asc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByExecutionId().asc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByProcessInstanceId().asc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByJobRetries().asc().count()).isEqualTo(1);
assertThat(managementService.createTimerJobQuery().orderByJobId().asc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByJobDuedate().asc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByExecutionId().asc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByProcessInstanceId().asc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByJobRetries().asc().count()).isEqualTo(3);
// desc
assertThat(managementService.createJobQuery().orderByJobId().desc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByJobDuedate().desc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByExecutionId().desc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByProcessInstanceId().desc().count()).isEqualTo(1);
assertThat(managementService.createJobQuery().orderByJobRetries().desc().count()).isEqualTo(1);
assertThat(managementService.createTimerJobQuery().orderByJobId().desc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByJobDuedate().desc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByExecutionId().desc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByProcessInstanceId().desc().count()).isEqualTo(3);
assertThat(managementService.createTimerJobQuery().orderByJobRetries().desc().count()).isEqualTo(3);
// sorting on multiple fields
setRetries(processInstanceIdTwo, 2);
// make sure all timers can fire
processEngineConfiguration.getClock().setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
TimerJobQuery query = managementService.createTimerJobQuery().timers().executable().orderByJobRetries().asc().orderByJobDuedate().desc();
List<Job> jobs = query.list();
assertThat(jobs).hasSize(3);
assertThat(jobs.get(0).getRetries()).isEqualTo(2);
assertThat(jobs.get(1).getRetries()).isEqualTo(3);
assertThat(jobs.get(2).getRetries()).isEqualTo(3);
assertThat(jobs.get(0).getProcessInstanceId()).isEqualTo(processInstanceIdTwo);
assertThat(jobs.get(1).getProcessInstanceId()).isEqualTo(processInstanceIdThree);
assertThat(jobs.get(2).getProcessInstanceId()).isEqualTo(processInstanceIdOne);
}
use of org.activiti.engine.runtime.TimerJobQuery in project Activiti by Activiti.
the class JobQueryTest method testQueryByExecutable.
public void testQueryByExecutable() {
// all obs should be executable at t3 + 1hour.1second
processEngineConfiguration.getClock().setCurrentTime(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
JobQuery query = managementService.createJobQuery();
verifyQueryResults(query, 1);
TimerJobQuery timerQuery = managementService.createTimerJobQuery().executable();
verifyQueryResults(timerQuery, 3);
// Setting retries of one job to 0, makes it non-executable
final Job job = managementService.createTimerJobQuery().processInstanceId(processInstanceIdOne).singleResult();
managementService.setTimerJobRetries(job.getId(), 0);
managementService.moveJobToDeadLetterJob(job.getId());
verifyQueryResults(query, 1);
verifyQueryResults(timerQuery, 2);
// Setting the clock before the start of the process instance, makes
// none of the timer jobs executable
processEngineConfiguration.getClock().setCurrentTime(testStartTime);
verifyQueryResults(query, 1);
verifyQueryResults(timerQuery, 0);
// Moving the job back to be executable
managementService.moveDeadLetterJobToExecutableJob(job.getId(), 5);
verifyQueryResults(query, 2);
verifyQueryResults(timerQuery, 0);
}
Aggregations