use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobDefinitionQueryTest method testQueryBySuspended.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/JobDefinitionQueryTest.testBase.bpmn" })
public void testQueryBySuspended() {
JobDefinitionQuery query = managementService.createJobDefinitionQuery().suspended();
verifyQueryResults(query, 0);
// suspend first one
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobType(AsyncContinuationJobHandler.TYPE).singleResult();
managementService.suspendJobDefinitionById(jobDefinition.getId());
// only one is suspended
verifyQueryResults(query, 1);
// Suspend second one
jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerStartEventJobHandler.TYPE).singleResult();
managementService.suspendJobDefinitionById(jobDefinition.getId());
// only two are suspended
verifyQueryResults(query, 2);
// suspend third one
jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerCatchIntermediateEventJobHandler.TYPE).singleResult();
managementService.suspendJobDefinitionById(jobDefinition.getId());
// only three are suspended
verifyQueryResults(query, 3);
// suspend fourth one
jobDefinition = managementService.createJobDefinitionQuery().jobType(TimerExecuteNestedActivityJobHandler.TYPE).singleResult();
managementService.suspendJobDefinitionById(jobDefinition.getId());
// all are suspended
verifyQueryResults(query, 4);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class JobQueryTest method testQueryByActivityId.
public void testQueryByActivityId() {
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
JobQuery query = managementService.createJobQuery().activityId(jobDefinition.getActivityId());
verifyQueryResults(query, 3);
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchPriorityTest method seedJobShouldGetPriorityFromOverridingJobDefinitionPriority.
@Test
public void seedJobShouldGetPriorityFromOverridingJobDefinitionPriority() {
// given
Batch batch = helper.migrateProcessInstancesAsync(2);
JobDefinition seedJobDefinition = helper.getSeedJobDefinition(batch);
managementService.setOverridingJobPriorityForJobDefinition(seedJobDefinition.getId(), CUSTOM_PRIORITY);
// when
helper.executeSeedJob(batch);
// then
Job seedJob = helper.getSeedJob(batch);
assertEquals(CUSTOM_PRIORITY, seedJob.getPriority());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class BatchPriorityTest method monitorJobShouldGetPriorityOverridingJobDefinitionPriority.
@Test
public void monitorJobShouldGetPriorityOverridingJobDefinitionPriority() {
// given
Batch batch = helper.migrateProcessInstancesAsync(1);
JobDefinition monitorJobDefinition = helper.getMonitorJobDefinition(batch);
managementService.setOverridingJobPriorityForJobDefinition(monitorJobDefinition.getId(), CUSTOM_PRIORITY);
// when
helper.executeSeedJob(batch);
// then
Job monitorJob = helper.getMonitorJob(batch);
assertEquals(CUSTOM_PRIORITY, monitorJob.getPriority());
}
use of org.camunda.bpm.engine.management.JobDefinition in project camunda-bpm-platform by camunda.
the class ActivateJobTest method testActivateByProcessInstanceId_shouldActivateJob.
@Deployment(resources = { "org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn" })
public void testActivateByProcessInstanceId_shouldActivateJob() {
// given
// a running process instance with a failed job
Map<String, Object> params = new HashMap<String, Object>();
params.put("fail", Boolean.TRUE);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("suspensionProcess", params);
// suspended job definitions and corresponding jobs
managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);
// the job definition
JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();
// the failed job
JobQuery jobQuery = managementService.createJobQuery();
Job job = jobQuery.singleResult();
assertTrue(job.isSuspended());
// when
// the job will be activate
managementService.activateJobByProcessInstanceId(processInstance.getId());
// then
// the job should be suspended
assertEquals(1, jobQuery.active().count());
assertEquals(0, jobQuery.suspended().count());
Job suspendedJob = jobQuery.active().singleResult();
assertEquals(job.getId(), suspendedJob.getId());
assertEquals(jobDefinition.getId(), suspendedJob.getJobDefinitionId());
assertFalse(suspendedJob.isSuspended());
}
Aggregations