use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MessageEventSubprocessTest method testNonInterruptingWithParallelForkInsideEmbeddedSubProcess.
@Deployment
public void testNonInterruptingWithParallelForkInsideEmbeddedSubProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
runtimeService.messageEventReceived("newMessage", runtimeService.createEventSubscriptionQuery().singleResult().getExecutionId());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("firstUserTask").concurrent().noScope().up().child("secondUserTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").done());
List<Task> tasks = taskService.createTaskQuery().list();
for (Task task : tasks) {
taskService.complete(task.getId());
}
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MessageEventSubprocessTest method testMultipleNonInterruptingInEmbeddedSubprocess.
@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());
}
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
// check that the parent execution of the event sub process task execution is the event
// sub process execution
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("subProcessTask").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().up().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
// complete sub process task
taskService.complete(subProcessTask.getId());
// after complete the sub process task all task should be deleted because of the terminating end event
assertEquals(0, taskService.createTaskQuery().count());
// and the process instance should be ended
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MessageNonInterruptingBoundaryEventTest method testNonInterruptingEventInCombinationWithUserTask.
@Deployment
public void testNonInterruptingEventInCombinationWithUserTask() {
// given
String processInstanceId = runtimeService.startProcessInstanceByKey("process").getId();
// when (1)
runtimeService.correlateMessage("firstMessage");
// then (1)
assertEquals(2, taskService.createTaskQuery().count());
Task task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
assertNotNull(task1);
Task innerTask = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult();
assertNotNull(innerTask);
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").noScope().concurrent().up().child(null).noScope().concurrent().child("innerTask").scope().done());
// when (2)
taskService.complete(innerTask.getId());
// then (2)
assertEquals(2, taskService.createTaskQuery().count());
task1 = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult();
assertNotNull(task1);
Task task2 = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult();
assertNotNull(task2);
executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").noScope().concurrent().up().child("task2").noScope().concurrent().done());
assertEquals(0, runtimeService.createEventSubscriptionQuery().count());
taskService.complete(task1.getId());
taskService.complete(task2.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class CompensateEventTest method testConcurrentExecutionsAndPendingCompensation.
@Deployment
public void testConcurrentExecutionsAndPendingCompensation() {
// given
ProcessInstance instance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = instance.getId();
String taskId = taskService.createTaskQuery().taskDefinitionKey("innerTask").singleResult().getId();
// when (1)
taskService.complete(taskId);
// then (1)
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task1").concurrent().noScope().up().child("task2").concurrent().noScope().up().child("subProcess").eventScope().scope().up().done());
ActivityInstance tree = runtimeService.getActivityInstance(processInstanceId);
assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task1").activity("task2").done());
// when (2)
taskId = taskService.createTaskQuery().taskDefinitionKey("task1").singleResult().getId();
taskService.complete(taskId);
// then (2)
executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree("task2").scope().child("subProcess").eventScope().scope().up().done());
tree = runtimeService.getActivityInstance(processInstanceId);
assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("task2").done());
// when (3)
taskId = taskService.createTaskQuery().taskDefinitionKey("task2").singleResult().getId();
taskService.complete(taskId);
// then (3)
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationTest method testScopeTaskStartBefore.
@Deployment(resources = ONE_SCOPE_TASK_PROCESS)
public void testScopeTaskStartBefore() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String processInstanceId = processInstance.getId();
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("theTask").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").activity("theTask").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child("theTask").scope().up().up().child(null).concurrent().noScope().child("theTask").scope().done());
assertEquals(2, taskService.createTaskQuery().count());
completeTasksInOrder("theTask", "theTask");
assertProcessEnded(processInstanceId);
}
Aggregations