@Deployment
public void testMultipleNonInterruptingInEmbeddedSubprocess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
// the process instance must have a message event subscription:
Execution subProcess = runtimeService.createExecutionQuery()
.messageEventSubscriptionName("newMessage")
.singleResult();
assertNotNull(subProcess);
assertEquals(1, createEventSubscriptionQuery().count());
Task subProcessTask = taskService.createTaskQuery().taskDefinitionKey("subProcessTask").singleResult();
assertNotNull(subProcessTask);
// start event sub process multiple times
for (int i = 1; i < 3; i++) {
runtimeService.messageEventReceived("newMessage", subProcess.getId());
// check that now i event sub process tasks exist
List<Task> eventSubProcessTasks = taskService.createTaskQuery().taskDefinitionKey("eventSubProcessTask").list();
assertEquals(i, eventSubProcessTasks.size());
// check that the parent execution of the event sub process task execution is the parent
// sub process
String taskExecutionId = eventSubProcessTasks.get(i-1).getExecutionId();
ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(taskExecutionId).singleResult();
assertEquals(subProcess.getId(), taskExecution.getParentId());
}
// complete sub process task
taskService.complete(subProcessTask.getId());