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());
}