use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtConcurrentAndScopeExecutionBecomeNonScope.
@Test
public void testVariableAtConcurrentAndScopeExecutionBecomeNonScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree scopeExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
ExecutionTree concurrentExecution = scopeExecution.getParent();
runtimeService.setVariableLocal(scopeExecution.getId(), "foo", 42);
runtimeService.setVariableLocal(concurrentExecution.getId(), "foo", 42);
// when
try {
testHelper.migrateProcessInstance(migrationPlan, processInstance);
Assert.fail("expected exception");
} catch (ProcessEngineException e) {
Assert.assertThat(e.getMessage(), CoreMatchers.containsString("The variable 'foo' exists in both, this scope" + " and concurrent local in the parent scope. Migrating to a non-scope activity would overwrite one of them."));
}
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent.
@Test
public void testVariableAtConcurrentExecutionAddParentScopeBecomeNonConcurrent() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_TASK_AND_SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaInputParameter("foo", "subProcessValue").done());
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 task1CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
ExecutionTree task2CcExecution = executionTreeBeforeMigration.getLeafExecutions("userTask2").get(0);
runtimeService.setVariableLocal(task1CcExecution.getId(), "foo", "task1Value");
runtimeService.setVariableLocal(task2CcExecution.getId(), "foo", "task2Value");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then the io mapping variable was overwritten due to a compacted execution tree
Assert.assertEquals(2, testHelper.snapshotAfterMigration.getVariables().size());
List<String> values = new ArrayList<String>();
for (VariableInstance variable : testHelper.snapshotAfterMigration.getVariables()) {
values.add((String) variable.getValue());
}
Assert.assertTrue(values.contains("task1Value"));
Assert.assertTrue(values.contains("task2Value"));
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtScopeExecutionBecomeNonScope.
@Test
public void testVariableAtScopeExecutionBecomeNonScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree scopeExecution = executionTreeBeforeMigration.getExecutions().get(0);
runtimeService.setVariableLocal(scopeExecution.getId(), "foo", 42);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
testHelper.assertVariableMigratedToExecution(beforeMigration, processInstance.getId());
// and the variable is concurrent local, i.e. expands on tree expansion
runtimeService.createProcessInstanceModification(processInstance.getId()).startBeforeActivity("userTask").execute();
VariableInstance variableAfterExpansion = runtimeService.createVariableInstanceQuery().singleResult();
Assert.assertNotNull(variableAfterExpansion);
Assert.assertNotSame(processInstance.getId(), variableAfterExpansion.getExecutionId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testAddScopeWithInputMappingAndVariableOnConcurrentExecutions.
@Test
public void testAddScopeWithInputMappingAndVariableOnConcurrentExecutions() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.PARALLEL_GATEWAY_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.PARALLEL_GATEWAY_SUBPROCESS_PROCESS).activityBuilder("subProcess").camundaInputParameter("foo", "inputOutputValue").done());
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);
ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2").get(0);
runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", "customValue");
runtimeService.setVariableLocal(userTask2CCExecutionBefore.getId(), "foo", "customValue");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then the scope variable instance has been overwritten during compaction (conform to prior behavior);
// although this is tested here, changing this behavior may be ok in the future
Collection<VariableInstance> variables = testHelper.snapshotAfterMigration.getVariables();
Assert.assertEquals(2, variables.size());
for (VariableInstance variable : variables) {
Assert.assertEquals("customValue", variable.getValue());
}
ExecutionTree subProcessExecution = testHelper.snapshotAfterMigration.getExecutionTree().getLeafExecutions("userTask2").get(0).getParent();
Assert.assertNotNull(testHelper.snapshotAfterMigration.getSingleVariable(subProcessExecution.getId(), "foo"));
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtScopeExecutionInScopeActivityAddParentScope.
@Test
public void testVariableAtScopeExecutionInScopeActivityAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_CONCURRENT_BOUNDARY_TASKS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask1").build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree scopeExecution = executionTreeBeforeMigration.getExecutions().get(0);
runtimeService.setVariableLocal(scopeExecution.getId(), "foo", 42);
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
VariableInstance beforeMigration = testHelper.snapshotBeforeMigration.getSingleVariable("foo");
Assert.assertEquals(1, testHelper.snapshotAfterMigration.getVariables().size());
testHelper.assertVariableMigratedToExecution(beforeMigration, beforeMigration.getExecutionId());
}
Aggregations