use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testCancelAllTransitionInstanceInScope.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_ASYNC_BEFORE_TASK_PROCESS)
public void testCancelAllTransitionInstanceInScope() {
// given there are two transition instances in an inner scope
// and an active activity instance in an outer scope
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedOneTaskProcess").startBeforeActivity("innerTask").startBeforeActivity("innerTask").startBeforeActivity("outerTask").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
// when i cancel both transition instances
TransitionInstance[] transitionInstances = tree.getTransitionInstances("innerTask");
runtimeService.createProcessInstanceModification(instance.getId()).cancelTransitionInstance(transitionInstances[0].getId()).cancelTransitionInstance(transitionInstances[1].getId()).execute();
// then the outer activity instance is the only one remaining
tree = runtimeService.getActivityInstance(instance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("outerTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testStartBeforeSyncEndAndCancelSingleTransitionInstance.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testStartBeforeSyncEndAndCancelSingleTransitionInstance() {
// given there is one transition instance in a scope and an outer activity instance
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("outerTask").startBeforeActivity("innerTask1").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
// when I start an activity in the same scope that ends immediately
// and cancel the first transition instance
runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("subProcessEnd2").cancelTransitionInstance(transitionInstance.getId()).execute();
// then only the outer activity instance is left
tree = runtimeService.getActivityInstance(instance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).activity("outerTask").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree("outerTask").scope().done());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeTaskAfterBoundaryEventInsideSubProcess.
@Deployment(resources = INTERRUPTING_BOUNDARY_EVENT_INSIDE_SUBPROCESS)
public void testTask2AndStartBeforeTaskAfterBoundaryEventInsideSubProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("innerTaskAfterBoundaryEvent").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("innerTask2").activity("innerTaskAfterBoundaryEvent").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("innerTaskAfterBoundaryEvent").concurrent().noScope().up().child("innerTask2").concurrent().noScope().done());
completeTasksInOrder("innerTask2", "innerTaskAfterBoundaryEvent");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeNonInterruptingBoundaryEvent.
@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT)
public void testTask2AndStartBeforeNonInterruptingBoundaryEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("boundaryEvent").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").activity("taskAfterBoundaryEvent").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("taskAfterBoundaryEvent").concurrent().noScope().up().child("task2").concurrent().noScope().done());
completeTasksInOrder("task2", "taskAfterBoundaryEvent");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationBoundaryEventTest method testTask2AndStartBeforeTaskAfterNonInterruptingBoundaryEvent.
@Deployment(resources = NON_INTERRUPTING_BOUNDARY_EVENT)
public void testTask2AndStartBeforeTaskAfterNonInterruptingBoundaryEvent() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("taskAfterBoundaryEvent").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("task2").activity("taskAfterBoundaryEvent").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("taskAfterBoundaryEvent").concurrent().noScope().up().child("task2").concurrent().noScope().done());
completeTasksInOrder("task2", "taskAfterBoundaryEvent");
assertProcessEnded(processInstanceId);
}
Aggregations