use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationPlanGenerationTest method testMapEqualActivitiesWithParallelMultiInstance.
@Test
public void testMapEqualActivitiesWithParallelMultiInstance() {
BpmnModelInstance testProcess = modify(ProcessModels.ONE_TASK_PROCESS).<UserTask>getModelElementById("userTask").builder().multiInstance().parallel().cardinality("3").multiInstanceDone().done();
assertGeneratedMigrationPlan(testProcess, testProcess).hasInstructions(migrate("userTask").to("userTask"), migrate("userTask#multiInstanceBody").to("userTask#multiInstanceBody"));
}
use of org.camunda.bpm.model.bpmn.instance.UserTask in project camunda-bpm-platform by camunda.
the class MigrationAddSubprocessTest method testCanMigrateParentScopeWayTooHigh.
@Test
public void testCanMigrateParentScopeWayTooHigh() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TRIPLE_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "subProcess1").mapActivities("userTask", "userTask").build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then there is only one instance of outerSubProcess
testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree(null).scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).child(null).scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("subProcess")).child(null).scope().child("userTask").scope().done());
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess1", testHelper.getSingleActivityInstanceBeforeMigration("subProcess").getId()).beginScope("subProcess2").beginScope("subProcess3").activity("userTask", testHelper.getSingleActivityInstanceBeforeMigration("userTask").getId()).done());
Task migratedTask = testHelper.snapshotAfterMigration.getTaskForKey("userTask");
Assert.assertNotNull(migratedTask);
// 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 testAddParentScopeToMultiInstance.
/**
* Readd when we implement migration for multi-instance
*/
@Test
@Ignore
public void testAddParentScopeToMultiInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.ONE_TASK_PROCESS).<UserTask>getModelElementById("userTask").builder().multiInstance().parallel().camundaCollection("collectionVar").camundaElementVariable("elementVar").done());
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(ProcessModels.SUBPROCESS_PROCESS).<UserTask>getModelElementById("userTask").builder().multiInstance().parallel().camundaCollection("collectionVar").camundaElementVariable("elementVar").done());
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask#multiInstanceBody", "userTask#multiInstanceBody").mapActivities("userTask", "userTask").build();
List<String> miElements = new ArrayList<String>();
miElements.add("a");
miElements.add("b");
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId(), Variables.createVariables().putValue("collectionVar", miElements));
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertActivityTreeAfterMigration().hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).beginScope("subProcess").beginMiBody("userTask").activity("userTask").activity("userTask").activity("userTask").done());
// the element variables still exist
List<Task> migratedTasks = testHelper.snapshotAfterMigration.getTasks();
assertEquals(2, migratedTasks.size());
List<String> collectedElementsVars = new ArrayList<String>();
for (Task migratedTask : migratedTasks) {
collectedElementsVars.add((String) rule.getTaskService().getVariable(migratedTask.getId(), "elementVar"));
}
Assert.assertTrue(collectedElementsVars.contains("a"));
Assert.assertTrue(collectedElementsVars.contains("b"));
// 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 testScopeUserTaskMigration.
@Test
public void testScopeUserTaskMigration() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SCOPE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SCOPE_TASK_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(null).scope().child("userTask").scope().id(testHelper.getSingleExecutionIdForActivityBeforeMigration("userTask")).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-bpmn-model by camunda.
the class GenerateIdTest method shouldGenerateIdsOnCreate.
@Test
public void shouldGenerateIdsOnCreate() {
BpmnModelInstance modelInstance = Bpmn.createEmptyModel();
Definitions definitions = modelInstance.newInstance(Definitions.class);
assertThat(definitions.getId()).isNotNull();
Process process = modelInstance.newInstance(Process.class);
assertThat(process.getId()).isNotNull();
StartEvent startEvent = modelInstance.newInstance(StartEvent.class);
assertThat(startEvent.getId()).isNotNull();
UserTask userTask = modelInstance.newInstance(UserTask.class);
assertThat(userTask.getId()).isNotNull();
}
Aggregations