use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testCancellationAndCreationInNestedOneTaskProcess.
@Deployment(resources = NESTED_PARALLEL_ONE_TASK_PROCESS)
public void testCancellationAndCreationInNestedOneTaskProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneTaskProcess");
String processInstanceId = processInstance.getId();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "innerTask")).startBeforeActivity("innerTask").execute();
assertProcessNotEnded(processInstanceId);
// assert activity instance
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertTrue(!getInstanceIdForActivity(tree, "innerTask").equals(getInstanceIdForActivity(updatedTree, "innerTask")));
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").beginScope("subProcess").activity("innerTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("outerTask").concurrent().noScope().up().child(null).concurrent().noScope().child("innerTask").scope().done());
// assert successful completion of process
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(2, tasks.size());
for (Task task : tasks) {
taskService.complete(task.getId());
}
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testCreationAndCancellationInOneTaskProcess.
@Deployment(resources = ONE_TASK_PROCESS)
public void testCreationAndCancellationInOneTaskProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String processInstanceId = processInstance.getId();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("theTask").cancelActivityInstance(getInstanceIdForActivity(tree, "theTask")).execute();
assertProcessNotEnded(processInstanceId);
// assert activity instance
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertTrue(!getInstanceIdForActivity(tree, "theTask").equals(getInstanceIdForActivity(updatedTree, "theTask")));
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree("theTask").scope().done());
// assert successful completion of process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testScopeCancellationInNestedOneScopeTaskProcess.
@Deployment(resources = NESTED_PARALLEL_ONE_SCOPE_TASK_PROCESS)
public void testScopeCancellationInNestedOneScopeTaskProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("nestedOneScopeTaskProcess");
String processInstanceId = processInstance.getId();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "subProcess")).execute();
assertProcessNotEnded(processInstanceId);
// assert activity instance
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("outerTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
// assert successful completion of process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testCancellationAndCreationInOneScopeTaskProcess.
@Deployment(resources = ONE_SCOPE_TASK_PROCESS)
public void testCancellationAndCreationInOneScopeTaskProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("oneTaskProcess");
String processInstanceId = processInstance.getId();
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(getInstanceIdForActivity(tree, "theTask")).startBeforeActivity("theTask").execute();
assertProcessNotEnded(processInstanceId);
// assert activity instance
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertTrue(!getInstanceIdForActivity(tree, "theTask").equals(getInstanceIdForActivity(updatedTree, "theTask")));
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("theTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("theTask").scope().done());
// assert successful completion of process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCancellationTest method testCancelAllInConcurrentScopeTasksProcess.
@Deployment(resources = CONCURRENT_SCOPE_TASKS_PROCESS)
public void testCancelAllInConcurrentScopeTasksProcess() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("parallelGateway");
String processInstanceId = processInstance.getId();
// two instances of task1
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("task1").execute();
// when
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelAllForActivity("task1").execute();
assertProcessNotEnded(processInstanceId);
// assert activity instance
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("task2").scope().done());
// assert successful completion of process
Task task = taskService.createTaskQuery().singleResult();
taskService.complete(task.getId());
assertProcessEnded(processInstanceId);
}
Aggregations