Search in sources :

Example 16 with UserTask

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());
}
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 17 with UserTask

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

Example 18 with UserTask

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());
}
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 19 with UserTask

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

Example 20 with UserTask

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