use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testRepeatedStartAndCancellationForTransitionInstance.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testRepeatedStartAndCancellationForTransitionInstance() {
// given there is one transition instance in a scope
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("innerTask1").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
// when I start an activity in the same scope
// and cancel the first transition instance
runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity(// expand tree
"innerTask2").cancelAllForActivity(// compact tree
"innerTask2").startBeforeActivity(// expand tree
"innerTask2").cancelAllForActivity(// compact tree
"innerTask2").startBeforeActivity(// expand tree
"innerTask2").cancelAllForActivity(// compact tree
"innerTask2").cancelTransitionInstance(transitionInstance.getId()).execute();
// then the process has ended
assertProcessEnded(instance.getId());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationAsyncTest method testStartBeforeAndCancelSingleTransitionInstance.
/**
* CAM-4090
*/
@Deployment(resources = NESTED_PARALLEL_ASYNC_BEFORE_SCOPE_TASK_PROCESS)
public void testStartBeforeAndCancelSingleTransitionInstance() {
// given there is one transition instance in a scope
ProcessInstance instance = runtimeService.createProcessInstanceByKey("nestedConcurrentTasksProcess").startBeforeActivity("innerTask1").execute();
ActivityInstance tree = runtimeService.getActivityInstance(instance.getId());
TransitionInstance transitionInstance = tree.getTransitionInstances("innerTask1")[0];
// when I start an activity in the same scope
// and cancel the first transition instance
runtimeService.createProcessInstanceModification(instance.getId()).startBeforeActivity("innerTask2").cancelTransitionInstance(transitionInstance.getId()).execute();
// then the activity was successfully instantiated
tree = runtimeService.getActivityInstance(instance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(instance.getProcessDefinitionId()).beginScope("subProcess").transition("innerTask2").done());
// assert executions
ExecutionTree executionTree = ExecutionTree.forExecution(instance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("innerTask2").scope().done());
}
use of org.camunda.bpm.engine.runtime.TransitionInstance 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.TransitionInstance 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.TransitionInstance in project camunda-bpm-platform by camunda.
the class ActivityInstanceImpl method collectTransitionInstances.
protected void collectTransitionInstances(String activityId, List<TransitionInstance> instances) {
boolean instanceFound = false;
for (TransitionInstance childTransitionInstance : childTransitionInstances) {
if (activityId.equals(childTransitionInstance.getActivityId())) {
instances.add(childTransitionInstance);
instanceFound = true;
}
}
if (!instanceFound) {
for (ActivityInstance childActivityInstance : childActivityInstances) {
((ActivityInstanceImpl) childActivityInstance).collectTransitionInstances(activityId, instances);
}
}
}
Aggregations