Search in sources :

Example 6 with UserTask

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"));
}
Also used : UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 7 with UserTask

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 8 with UserTask

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ArrayList(java.util.ArrayList) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 9 with UserTask

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());
}
Also used : Task(org.camunda.bpm.engine.task.Task) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) Test(org.junit.Test)

Example 10 with UserTask

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();
}
Also used : Definitions(org.camunda.bpm.model.bpmn.instance.Definitions) StartEvent(org.camunda.bpm.model.bpmn.instance.StartEvent) UserTask(org.camunda.bpm.model.bpmn.instance.UserTask) Process(org.camunda.bpm.model.bpmn.instance.Process) Test(org.junit.Test)

Aggregations

UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)22 Test (org.junit.Test)18 MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)12 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)12 Task (org.camunda.bpm.engine.task.Task)12 DelegateTask (org.camunda.bpm.engine.delegate.DelegateTask)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3 ResourceRole (org.camunda.bpm.model.bpmn.instance.ResourceRole)3 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)2 Definitions (org.camunda.bpm.model.bpmn.instance.Definitions)2 HumanPerformer (org.camunda.bpm.model.bpmn.instance.HumanPerformer)2 Process (org.camunda.bpm.model.bpmn.instance.Process)2 StartEvent (org.camunda.bpm.model.bpmn.instance.StartEvent)2 CamundaTaskListener (org.camunda.bpm.model.bpmn.instance.camunda.CamundaTaskListener)2 ArrayList (java.util.ArrayList)1 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)1 Association (org.camunda.bpm.model.bpmn.instance.Association)1 BaseElement (org.camunda.bpm.model.bpmn.instance.BaseElement)1 BoundaryEvent (org.camunda.bpm.model.bpmn.instance.BoundaryEvent)1 Performer (org.camunda.bpm.model.bpmn.instance.Performer)1