use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtScopeExecutionInScopeActivity.
@Test
public void testVariableAtScopeExecutionInScopeActivity() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ONE_BOUNDARY_TASK);
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, beforeMigration.getExecutionId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtConcurrentExecutionInScopeActivityAddParentScope.
@Test
public void testVariableAtConcurrentExecutionInScopeActivityAddParentScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_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());
ActivityInstance subProcessInstance = testHelper.getSingleActivityInstanceAfterMigration("subProcess");
// 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(), subProcessInstance.getId());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationVariablesTest method testVariableAtScopeAndConcurrentExecutionAddParentScope.
@Test
public void testVariableAtScopeAndConcurrentExecutionAddParentScope() {
// 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());
ExecutionTree executionTreeBeforeMigration = ExecutionTree.forExecution(processInstance.getId(), rule.getProcessEngine());
ExecutionTree userTask1CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask1").get(0);
ExecutionTree userTask2CCExecutionBefore = executionTreeBeforeMigration.getLeafExecutions("userTask2").get(0);
runtimeService.setVariableLocal(processInstance.getId(), "foo", "processInstanceValue");
runtimeService.setVariableLocal(userTask1CCExecutionBefore.getId(), "foo", "task1Value");
runtimeService.setVariableLocal(userTask2CCExecutionBefore.getId(), "foo", "task2Value");
VariableInstance processScopeVariable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "processInstanceValue").singleResult();
VariableInstance task1Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task1Value").singleResult();
VariableInstance task2Variable = runtimeService.createVariableInstanceQuery().variableValueEquals("foo", "task2Value").singleResult();
// 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
Assert.assertEquals(3, testHelper.snapshotAfterMigration.getVariables().size());
VariableInstance processScopeVariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(processScopeVariable.getId());
Assert.assertNotNull(processScopeVariableAfterMigration);
Assert.assertEquals("processInstanceValue", processScopeVariableAfterMigration.getValue());
VariableInstance task1VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task1Variable.getId());
Assert.assertNotNull(task1VariableAfterMigration);
Assert.assertEquals("task1Value", task1VariableAfterMigration.getValue());
VariableInstance task2VariableAfterMigration = testHelper.snapshotAfterMigration.getVariable(task2Variable.getId());
Assert.assertNotNull(task2VariableAfterMigration);
Assert.assertEquals("task2Value", task2VariableAfterMigration.getValue());
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class ProcessInstanceSnapshotBuilder method executionTree.
public ProcessInstanceSnapshotBuilder executionTree() {
ExecutionTree executionTree = ExecutionTree.forExecution(processInstanceId, processEngine);
snapshot.setExecutionTree(executionTree);
return this;
}
use of org.camunda.bpm.engine.test.util.ExecutionTree in project camunda-bpm-platform by camunda.
the class MigrationHistoricVariablesTest method noHistoryUpdateOnAddScopeMigration.
@Test
@RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL)
public void noHistoryUpdateOnAddScopeMigration() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CONCURRENT_BOUNDARY_TASKS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(SUBPROCESS_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 there is still one historic variable instance
Assert.assertEquals(1, historyService.createHistoricVariableInstanceQuery().count());
// and no additional historic details
Assert.assertEquals(1, historyService.createHistoricDetailQuery().count());
}
Aggregations