use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testCancelInnerActivityParallelTasks.
@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testCancelInnerActivityParallelTasks() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
completeTasksInOrder("beforeTask");
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[0].getId()).execute();
// then
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miTasks").activity("miTasks").activity("miTasks").endScope().done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("miTasks").concurrent().noScope().up().child("miTasks").concurrent().noScope().up().done());
// and the process is able to complete successfully
completeTasksInOrder("miTasks", "miTasks", "afterTask");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySequentialSubprocess.
@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySequentialSubprocess() {
// given the mi body is not yet instantiated
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("subProcessTask").execute();
// then the mi variables should be correct
Execution leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
assertNotNull(leafExecution);
assertVariable(leafExecution, "loopCounter", 0);
assertVariable(leafExecution, "nrOfInstances", 1);
assertVariable(leafExecution, "nrOfCompletedInstances", 0);
assertVariable(leafExecution, "nrOfActiveInstances", 1);
// and the trees should be correct
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("beforeTask").concurrent().noScope().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
// and the process is able to complete successfully
completeTasksInOrder("subProcessTask", "afterTask", "beforeTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeInnerActivityWithMiBodySetNrOfInstancesSequentialSubprocess.
@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeInnerActivityWithMiBodySetNrOfInstancesSequentialSubprocess() {
// given the mi body is not yet instantiated
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("subProcessTask").setVariable("nrOfInstances", 3).execute();
// then the mi variables should be correct
Execution leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
assertNotNull(leafExecution);
assertVariable(leafExecution, "loopCounter", 0);
assertVariable(leafExecution, "nrOfInstances", 3);
assertVariable(leafExecution, "nrOfCompletedInstances", 0);
assertVariable(leafExecution, "nrOfActiveInstances", 1);
// and the trees should be correct
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child("beforeTask").concurrent().noScope().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
// and two following sequential instances should be created
completeTasksInOrder("subProcessTask");
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).activity("beforeTask").beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").done());
leafExecution = runtimeService.createExecutionQuery().activityId("subProcessTask").singleResult();
assertNotNull(leafExecution);
assertVariable(leafExecution, "loopCounter", 1);
assertVariable(leafExecution, "nrOfInstances", 3);
assertVariable(leafExecution, "nrOfCompletedInstances", 1);
assertVariable(leafExecution, "nrOfActiveInstances", 1);
completeTasksInOrder("subProcessTask");
// and the remainder of the process completes successfully
completeTasksInOrder("subProcessTask", "beforeTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask", "afterTask");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testCancelInnerActivityParallelTasksAllButOne.
/**
* Ensures that the modification cmd does not prune the last concurrent execution
* because parallel MI requires this
*/
@Deployment(resources = PARALLEL_MULTI_INSTANCE_TASK_PROCESS)
public void testCancelInnerActivityParallelTasksAllButOne() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miParallelUserTasks");
completeTasksInOrder("beforeTask");
// when
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
runtimeService.createProcessInstanceModification(processInstance.getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[0].getId()).cancelActivityInstance(tree.getActivityInstances("miTasks")[1].getId()).execute();
// then
tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miTasks").activity("miTasks").endScope().done());
// the execution tree should still be in the expected shape
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("miTasks").concurrent().noScope().done());
// and the process is able to complete successfully
completeTasksInOrder("miTasks", "afterTask");
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationMultiInstanceTest method testStartBeforeMultiInstanceBodySequentialSubprocess.
@Deployment(resources = SEQUENTIAL_MULTI_INSTANCE_SUBPROCESS_PROCESS)
public void testStartBeforeMultiInstanceBodySequentialSubprocess() {
// given
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miSequentialSubprocess");
completeTasksInOrder("beforeTask");
// when
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("miSubProcess#multiInstanceBody").execute();
// then
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertThat(tree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().endScope().beginMiBody("miSubProcess").beginScope("miSubProcess").activity("subProcessTask").endScope().done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstance.getId(), processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().up().up().up().child(null).concurrent().noScope().child(null).scope().child("subProcessTask").scope().done());
// and the process is able to complete successfully
completeTasksInOrder("subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "subProcessTask", "afterTask", "afterTask");
assertProcessEnded(processInstance.getId());
}
Aggregations