}
@Deployment
public void testExclusiveJobs() {
JobDefinition jobDefinition = managementService.createJobDefinitionQuery()
.activityIdIn("task2")
.singleResult();
// given that the second task is suspended
managementService.suspendJobDefinitionById(jobDefinition.getId());
// if I start a process instance
runtimeService.startProcessInstanceByKey("testProcess");
waitForJobExecutorToProcessAllJobs(6000);
// then the second task is not executed
assertEquals(1, runtimeService.createProcessInstanceQuery().count());
// there is a suspended job instance
Job job = managementService.createJobQuery()
.singleResult();
assertEquals(job.getJobDefinitionId(), jobDefinition.getId());
assertTrue(job.isSuspended());
// if I unsuspend the job definition, the job is executed:
managementService.activateJobDefinitionById(jobDefinition.getId(), true);
waitForJobExecutorToProcessAllJobs(5000);
assertEquals(0, runtimeService.createProcessInstanceQuery().count());