use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class SuspendJobDefinitionTest method testSuspensionByProcessDefinitionIdAndSuspendJobsFlag_shouldSuspendJobs.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" })
public void testSuspensionByProcessDefinitionIdAndSuspendJobsFlag_shouldSuspendJobs() {
// given
// a deployed process definition with asynchronous continuation
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
// a running process instance with a failed job
Map<String, Object> params = new HashMap<String, Object>();
params.put("fail", Boolean.TRUE);
runtimeService.startProcessInstanceByKey("suspensionProcess", params);
// a job definition (which was created for the asynchronous continuation)
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// when
// suspend the job definition
managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId(), true);
// then
// there exists a suspended job definition...
JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended();
assertEquals(1, jobDefinitionQuery.count());
JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult();
assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId());
assertTrue(suspendedJobDefinition.isSuspended());
// ...and a suspended job of the provided job definition
JobQuery jobQuery = managementService.createJobQuery().suspended();
assertEquals(1, jobQuery.count());
Job suspendedJob = jobQuery.singleResult();
assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId());
assertTrue(suspendedJob.isSuspended());
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class SuspendJobDefinitionTest method testSuspensionByProcessDefinitionId_shouldRetainJobs.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" })
public void testSuspensionByProcessDefinitionId_shouldRetainJobs() {
// given
// a deployed process definition with asynchronous continuation
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
// a running process instance with a failed job
Map<String, Object> params = new HashMap<String, Object>();
params.put("fail", Boolean.TRUE);
runtimeService.startProcessInstanceByKey("suspensionProcess", params);
// a job definition (which was created for the asynchronous continuation)
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// when
// suspend the job definition
managementService.suspendJobDefinitionByProcessDefinitionId(processDefinition.getId());
// then
// there exists a suspended job definition
JobDefinitionQuery jobDefinitionQuery = managementService.createJobDefinitionQuery().suspended();
assertEquals(1, jobDefinitionQuery.count());
JobDefinition suspendedJobDefinition = jobDefinitionQuery.singleResult();
assertEquals(jobDefinition.getId(), suspendedJobDefinition.getId());
// there does not exist any active job definition
jobDefinitionQuery = managementService.createJobDefinitionQuery().active();
assertTrue(jobDefinitionQuery.list().isEmpty());
// the corresponding job is still active
JobQuery jobQuery = managementService.createJobQuery().active();
assertEquals(1, jobQuery.count());
Job activeJob = jobQuery.singleResult();
assertEquals(jobDefinition.getId(), activeJob.getJobDefinitionId());
assertFalse(activeJob.isSuspended());
jobQuery = managementService.createJobQuery().suspended();
assertEquals(0, jobQuery.count());
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testByInvalidJobDefinitionId.
public void testByInvalidJobDefinitionId() {
JobQuery query = managementService.createJobQuery().jobDefinitionId("invalid");
verifyQueryResults(query, 0);
try {
managementService.createJobQuery().jobDefinitionId(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 testQueryByDuedateLowerThen.
public void testQueryByDuedateLowerThen() {
JobQuery query = managementService.createJobQuery().duedateLowerThen(testStartTime);
verifyQueryResults(query, 0);
query = managementService.createJobQuery().duedateLowerThen(new Date(timerOneFireTime.getTime() + ONE_SECOND));
verifyQueryResults(query, 1);
query = managementService.createJobQuery().duedateLowerThen(new Date(timerTwoFireTime.getTime() + ONE_SECOND));
verifyQueryResults(query, 2);
query = managementService.createJobQuery().duedateLowerThen(new Date(timerThreeFireTime.getTime() + ONE_SECOND));
verifyQueryResults(query, 3);
}
use of org.camunda.bpm.engine.runtime.JobQuery in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryBySuspended.
public void testQueryBySuspended() {
JobQuery query = managementService.createJobQuery().suspended();
verifyQueryResults(query, 0);
managementService.suspendJobDefinitionByProcessDefinitionKey("timerOnTask", true);
verifyQueryResults(query, 3);
}
Aggregations