use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationAddSubprocessTest method testNestedScopesMigration2.
@Test
public void testNestedScopesMigration2() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.DOUBLE_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").mapActivities("subProcess", "innerSubProcess").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().child("userTask").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("subProcess")).done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("outerSubProcess").beginScope("innerSubProcess", testHelper.getSingleActivityInstanceBeforeMigration("subProcess").getId()).activity("userTask", testHelper.getSingleActivityInstanceBeforeMigration("userTask").getId()).done());
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertNotNull(migratedTask);
assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
// and it is possible to successfully complete the migrated instance
rule.getTaskService().complete(migratedTask.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationAddSubprocessTest method testMultipleInstancesOfScope.
@Test
public void testMultipleInstancesOfScope() {
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.DOUBLE_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask").mapActivities("subProcess", "outerSubProcess").build();
ProcessInstance processInstance = rule.getRuntimeService().createProcessInstanceById(sourceProcessDefinition.getId()).startBeforeActivity("subProcess").startBeforeActivity("subProcess").execute();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).concurrent().noScope().child(null).scope().child("userTask").scope().up().up().up().child(null).concurrent().noScope().child(null).scope().child("userTask").scope().done());
ActivityInstance activityInstance = testHelper.snapshotBeforeMigration.getActivityTree();
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("outerSubProcess", activityInstance.getActivityInstances("subProcess")[0].getId()).beginScope("innerSubProcess").activity("userTask", activityInstance.getActivityInstances("subProcess")[0].getActivityInstances("userTask")[0].getId()).endScope().endScope().beginScope("outerSubProcess", activityInstance.getActivityInstances("subProcess")[1].getId()).beginScope("innerSubProcess").activity("userTask", activityInstance.getActivityInstances("subProcess")[1].getActivityInstances("userTask")[0].getId()).done());
List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
assertEquals(2, migratedTasks.size());
for (Task migratedTask : migratedTasks) {
assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
}
// 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.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationAddSubprocessTest method testUserTaskMigration.
@Test
public void testUserTaskMigration() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_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").scope().done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess").activity("userTask", testHelper.getSingleActivityInstanceBeforeMigration("userTask").getId()).done());
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertNotNull(migratedTask);
assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
// and it is possible to successfully complete the migrated instance
rule.getTaskService().complete(migratedTask.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationUserTaskTest method testUserTaskMigrationInProcessDefinitionScope.
@Test
public void testUserTaskMigrationInProcessDefinitionScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
// the entities were migrated
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).done());
Task task = testHelper.snapshotBeforeMigration.getTaskForKey("userTask");
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertEquals(task.getId(), migratedTask.getId());
// and it is possible to successfully complete the migrated instance
rule.getTaskService().complete(migratedTask.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationUserTaskTest method testUserTaskMigrationInSubProcessScope.
@Test
public void testUserTaskMigrationInSubProcessScope() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
// the entities were migrated
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child("userTask").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("userTask")).done());
Task task = testHelper.snapshotBeforeMigration.getTaskForKey("userTask");
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertEquals(task.getId(), migratedTask.getId());
Assert.assertEquals(targetProcessDefinition.getId(), migratedTask.getProcessDefinitionId());
// and it is possible to successfully complete the migrated instance
rule.getTaskService().complete(migratedTask.getId());
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Aggregations