use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterWithExecutionListener.
/**
* Test for CAM-2518: Fixes an issue that creates an infinite loop when using
* asyncAfter together with an execution listener on sequence flow event "take".
* So the only required assertion here is that the process executes successfully.
*/
@Deployment
public void testAsyncAfterWithExecutionListener() {
// given an async after job and an execution listener on that task
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess");
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
assertNotListenerTakeInvoked(processInstance);
// when the job is executed
managementService.executeJob(job.getId());
// then the process should advance and not recreate the job
job = managementService.createJobQuery().singleResult();
assertNull(job);
Task task = taskService.createTaskQuery().singleResult();
assertNotNull(task);
assertListenerTakeInvoked(processInstance);
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterAndBeforeServiceTask.
@Deployment
public void testAsyncAfterAndBeforeServiceTask() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess");
// the service task is not yet invoked
assertNotListenerStartInvoked(pi);
assertNotBehaviorInvoked(pi);
assertNotListenerEndInvoked(pi);
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// if the job is executed
managementService.executeJob(job.getId());
// the manual task is invoked
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// and now the process is waiting *after* the manual task
job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// after executing the waiting job, the process instance will end
managementService.executeJob(job.getId());
assertProcessEnded(pi.getId());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterOnParallelGatewayFork.
@Deployment
public void testAsyncAfterOnParallelGatewayFork() {
String configuration = PvmAtomicOperation.TRANSITION_NOTIFY_LISTENER_TAKE.getCanonicalName();
String config1 = configuration + "$afterForkFlow1";
String config2 = configuration + "$afterForkFlow2";
runtimeService.startProcessInstanceByKey("process");
// there are two jobs
List<Job> jobs = managementService.createJobQuery().list();
assertEquals(2, jobs.size());
Job jobToExecute = fetchFirstJobByHandlerConfiguration(jobs, config1);
assertNotNull(jobToExecute);
managementService.executeJob(jobToExecute.getId());
Task task1 = taskService.createTaskQuery().taskDefinitionKey("theTask1").singleResult();
assertNotNull(task1);
// there is one left
jobs = managementService.createJobQuery().list();
assertEquals(1, jobs.size());
jobToExecute = fetchFirstJobByHandlerConfiguration(jobs, config2);
managementService.executeJob(jobToExecute.getId());
Task task2 = taskService.createTaskQuery().taskDefinitionKey("theTask2").singleResult();
assertNotNull(task2);
assertEquals(2, taskService.createTaskQuery().count());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterServiceTaskMultipleTransitions.
@Deployment
public void testAsyncAfterServiceTaskMultipleTransitions() {
// start process instance
Map<String, Object> varMap = new HashMap<String, Object>();
varMap.put("flowToTake", "flow2");
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testProcess", varMap);
// the service task is completely invoked
assertListenerStartInvoked(pi);
assertBehaviorInvoked(pi);
assertListenerEndInvoked(pi);
// and the execution is waiting *after* the service task
Job continuationJob = managementService.createJobQuery().singleResult();
assertNotNull(continuationJob);
// if we execute the job, the process instance continues along the selected path
managementService.executeJob(continuationJob.getId());
assertNotNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow2").singleResult());
assertNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow3").singleResult());
// end the process
runtimeService.signal(pi.getId());
// ////////////////////////////////////////////////////////////
// start process instance
varMap = new HashMap<String, Object>();
varMap.put("flowToTake", "flow3");
pi = runtimeService.startProcessInstanceByKey("testProcess", varMap);
// the service task is completely invoked
assertListenerStartInvoked(pi);
assertBehaviorInvoked(pi);
assertListenerEndInvoked(pi);
// and the execution is waiting *after* the service task
continuationJob = managementService.createJobQuery().singleResult();
assertNotNull(continuationJob);
// if we execute the job, the process instance continues along the selected path
managementService.executeJob(continuationJob.getId());
assertNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow2").singleResult());
assertNotNull(runtimeService.createExecutionQuery().activityId("taskAfterFlow3").singleResult());
}
use of org.camunda.bpm.engine.runtime.Job in project camunda-bpm-platform by camunda.
the class AsyncAfterTest method testAsyncAfterManualTask.
@Deployment
public void testAsyncAfterManualTask() {
// start process instance
ProcessInstance pi = runtimeService.startProcessInstanceByKey("testManualTask");
// listeners should be fired by now
assertListenerStartInvoked(pi);
assertListenerEndInvoked(pi);
// the process should wait *after* the catch event
Job job = managementService.createJobQuery().singleResult();
assertNotNull(job);
// if the waiting job is executed, the process instance should end
managementService.executeJob(job.getId());
assertProcessEnded(pi.getId());
}
Aggregations