use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventSubProcessTest method testStartBeforeTaskInsideNonInterruptingEventSubProcessInsideSubProcessTask2ShouldStay.
@Deployment(resources = NON_INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS)
public void testStartBeforeTaskInsideNonInterruptingEventSubProcessInsideSubProcessTask2ShouldStay() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcessTask").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("task2").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task2").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
completeTasksInOrder("task2", "eventSubProcessTask");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationEventSubProcessTest method testStartBeforeTaskInsideEventSubProcessInsideSubProcessTask2ShouldStay.
@Deployment(resources = INTERRUPTING_EVENT_SUBPROCESS_INSIDE_SUBPROCESS)
public void testStartBeforeTaskInsideEventSubProcessInsideSubProcessTask2ShouldStay() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process");
String processInstanceId = processInstance.getId();
String taskId = taskService.createTaskQuery().singleResult().getId();
taskService.complete(taskId);
runtimeService.createProcessInstanceModification(processInstanceId).startBeforeActivity("eventSubProcessTask").execute();
ActivityInstance updatedTree = runtimeService.getActivityInstance(processInstanceId);
assertNotNull(updatedTree);
assertEquals(processInstanceId, updatedTree.getProcessInstanceId());
assertThat(updatedTree).hasStructure(describeActivityInstanceTree(processInstance.getProcessDefinitionId()).beginScope("subProcess").activity("task2").beginScope("eventSubProcess").activity("eventSubProcessTask").done());
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
assertThat(executionTree).matches(describeExecutionTree(null).scope().child(null).scope().child("task2").concurrent().noScope().up().child(null).concurrent().noScope().child("eventSubProcessTask").scope().done());
completeTasksInOrder("task2", "eventSubProcessTask");
assertProcessEnded(processInstanceId);
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope.
@Test
public void testVariableAtConcurrentExecutionInScopeActivityRemoveParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0).getParent();
runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", 42);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
ExecutionTree userTask1CCExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0).getParent();
Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
// for variables at concurrent executions that are parent of a leaf-scope-execution, the activity instance is
// the activity instance id of the parent activity instance (which is probably a bug)
testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1CCExecutionAfter.getId(), processInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtTaskAddParentScope.
@Test
public void testVariableAtTaskAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask1").singleResult();
taskService.setVariableLocal(task.getId(), "foo", 42);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
ExecutionTree userTask1ExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
testHelper.assertVariableMigratedToExecution(beforeMigration, userTask1ExecutionAfter.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtTaskAndConcurrentExecutionAddParentScope.
@Test
public void testVariableAtTaskAndConcurrentExecutionAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
Task task = taskService.createTaskQuery().taskDefinitionKey("userTask1").singleResult();
taskService.setVariableLocal(task.getId(), "foo", 42);
runtimeService.setVariableLocal(task.getExecutionId(), "foo", 52);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
VariableInstance taskVarBeforeMigration = testHelper.snapshotBeforeMigration.getSingleTaskVariable(task.getId(), "foo");
ExecutionTree userTask1ExecutionAfter = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask1").get(0);
Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().size());
testHelper.assertVariableMigratedToExecution(taskVarBeforeMigration, userTask1ExecutionAfter.getId());
}
Aggregations