use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationRemoveMultiInstanceTest method testRemoveParallelMultiInstanceBody.
@Test
public void testRemoveParallelMultiInstanceBody() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("userTask").concurrent().noScope().up().child("userTask").concurrent().noScope().up().child("userTask").concurrent().noScope().done());
ActivityInstance[] userTaskInstances = testHelper.snapshotBeforeMigration.getActivityTree().getActivityInstances("userTask");
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("userTask", userTaskInstances[0].getId()).activity("userTask", userTaskInstances[1].getId()).activity("userTask", userTaskInstances[2].getId()).done());
List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
Assert.assertEquals(3, migratedTasks.size());
// and it is possible to successfully complete the migrated instance
for (Task migratedTask : migratedTasks) {
rule.getTaskService().complete(migratedTask.getId());
}
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationRemoveMultiInstanceTest method testRemoveParallelMultiInstanceBodyOneInstanceFinished.
@Test
public void testRemoveParallelMultiInstanceBodyOneInstanceFinished() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(migrationPlan.getSourceProcessDefinitionId());
Task firstTask = rule.getTaskService().createTaskQuery().listPage(0, 1).get(0);
rule.getTaskService().complete(firstTask.getId());
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("userTask").concurrent().noScope().up().child("userTask").concurrent().noScope().done());
ActivityInstance[] userTaskInstances = testHelper.snapshotBeforeMigration.getActivityTree().getActivityInstances("userTask");
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("userTask", userTaskInstances[0].getId()).activity("userTask", userTaskInstances[1].getId()).done());
List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
Assert.assertEquals(2, migratedTasks.size());
// and it is possible to successfully complete the migrated instance
for (Task migratedTask : migratedTasks) {
rule.getTaskService().complete(migratedTask.getId());
}
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class MigrationRemoveMultiInstanceTest method testRemoveParallelMultiInstanceBodyScope.
@Test
public void testRemoveParallelMultiInstanceBodyScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MultiInstanceProcessModels.PAR_MI_SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "subProcess").mapActivities("userTask", "userTask").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
ActivityInstance[] subProcessInstances = testHelper.snapshotBeforeMigration.getActivityTree().getActivityInstances("subProcess");
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).concurrent().noScope().child("userTask").scope().id(testHelper.getSingleExecutionIdForActivity(subProcessInstances[0], "subProcess")).up().up().child(null).concurrent().noScope().child("userTask").scope().id(testHelper.getSingleExecutionIdForActivity(subProcessInstances[1], "subProcess")).up().up().child(null).concurrent().noScope().child("userTask").scope().id(testHelper.getSingleExecutionIdForActivity(subProcessInstances[2], "subProcess")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess", subProcessInstances[0].getId()).activity("userTask", subProcessInstances[0].getActivityInstances("userTask")[0].getId()).endScope().beginScope("subProcess", subProcessInstances[1].getId()).activity("userTask", subProcessInstances[1].getActivityInstances("userTask")[0].getId()).endScope().beginScope("subProcess", subProcessInstances[2].getId()).activity("userTask", subProcessInstances[2].getActivityInstances("userTask")[0].getId()).endScope().done());
List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
Assert.assertEquals(3, migratedTasks.size());
// and it is possible to successfully complete the migrated instance
for (Task migratedTask : migratedTasks) {
rule.getTaskService().complete(migratedTask.getId());
}
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testSimpleSubProcessVariables.
@Deployment
public void testSimpleSubProcessVariables() {
// given
Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("processVariable", "aProcessVariable");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess", processVariables);
Task task = taskService.createTaskQuery().taskDefinitionKey("UserTask_1").singleResult();
runtimeService.setVariableLocal(task.getExecutionId(), "aLocalVariable", "aLocalValue");
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertEquals(1, tree.getChildActivityInstances().length);
ActivityInstance subProcessInstance = tree.getActivityInstances("SubProcess_1")[0];
// then the local variable has activity instance Id of the subprocess
VariableInstanceQuery query = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(subProcessInstance.getId());
VariableInstance localVariable = query.singleResult();
assertNotNull(localVariable);
assertEquals("aLocalVariable", localVariable.getName());
assertEquals("aLocalValue", localVariable.getValue());
// and the global variable has the activity instance Id of the process instance:
query = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(processInstance.getId());
VariableInstance globalVariable = query.singleResult();
assertNotNull(localVariable);
assertEquals("processVariable", globalVariable.getName());
assertEquals("aProcessVariable", globalVariable.getValue());
taskService.complete(task.getId());
}
use of org.camunda.bpm.engine.runtime.ActivityInstance in project camunda-bpm-platform by camunda.
the class VariableInstanceQueryTest method testSubProcessVariables.
@Test
@Deployment
public void testSubProcessVariables() {
// given
Map<String, Object> processVariables = new HashMap<String, Object>();
processVariables.put("processVariable", "aProcessVariable");
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("processWithSubProcess", processVariables);
ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId());
assertNotNull(tree);
assertEquals(1, tree.getChildActivityInstances().length);
// when
VariableInstanceQuery query1 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(tree.getId());
// then
VariableInstance processVariable = query1.singleResult();
assertNotNull(processVariable);
assertEquals("processVariable", processVariable.getName());
assertEquals("aProcessVariable", processVariable.getValue());
// when
ActivityInstance subProcessActivityInstance = tree.getActivityInstances("SubProcess_1")[0];
VariableInstanceQuery query2 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(subProcessActivityInstance.getId());
// then
checkVariables(query2.list());
// when setting a task local variable
Task task = taskService.createTaskQuery().singleResult();
taskService.setVariableLocal(task.getId(), "taskVariable", "taskVariableValue");
// skip mi body instance
ActivityInstance taskActivityInstance = subProcessActivityInstance.getChildActivityInstances()[0];
VariableInstanceQuery query3 = runtimeService.createVariableInstanceQuery().activityInstanceIdIn(taskActivityInstance.getId());
// then
List<VariableInstance> variables = query3.list();
VariableInstance taskVariable = query3.singleResult();
assertNotNull(taskVariable);
assertEquals("taskVariable", taskVariable.getName());
assertEquals("taskVariableValue", taskVariable.getValue());
}
Aggregations