Search in sources :

Example 11 with MigrationPlan

use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.

the class MigrationCompensationRemoveSubProcessTest method testCase1AssertActivityInstance.

@Test
public void testCase1AssertActivityInstance() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_TWO_TASKS_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // when
    testHelper.completeTask("userTask2");
    // then
    ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
    assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").activity("compensationHandler").done());
}
Also used : 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 12 with MigrationPlan

use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.

the class MigrationCompensationRemoveSubProcessTest method testCase2AssertExecutionTree.

@Test
public void testCase2AssertExecutionTree() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertExecutionTreeAfterMigration().hasProcessDefinitionId(targetProcessDefinition.getId()).matches(describeExecutionTree("userTask2").scope().id(testHelper.snapshotBeforeMigration.getProcessInstanceId()).done());
}
Also used : 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 13 with MigrationPlan

use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.

the class MigrationBoundaryEventsParameterizedTest method testMigrateBoundaryEventOnConcurrentUserTaskAndTriggerEvent.

@Test
public void testMigrateBoundaryEventOnConcurrentUserTaskAndTriggerEvent() {
    // given
    BpmnModelInstance sourceProcess = ProcessModels.PARALLEL_GATEWAY_PROCESS.clone();
    MigratingBpmnEventTrigger eventTrigger = eventFactory.addBoundaryEvent(rule.getProcessEngine(), sourceProcess, USER_TASK_1_ID, BOUNDARY_ID);
    ModifiableBpmnModelInstance.wrap(sourceProcess).flowNodeBuilder(BOUNDARY_ID).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
    BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId("boundary", "newBoundary");
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_1_ID, USER_TASK_1_ID).mapActivities(USER_TASK_2_ID, USER_TASK_2_ID).mapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID).updateEventTrigger().build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then it is possible to trigger the event and successfully complete the migrated instance
    eventTrigger.inContextOf(NEW_BOUNDARY_ID).trigger(processInstance.getId());
    testHelper.completeTask(AFTER_BOUNDARY_TASK);
    testHelper.completeTask(USER_TASK_2_ID);
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : MigratingBpmnEventTrigger(org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 14 with MigrationPlan

use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.

the class MigrationBoundaryEventsParameterizedTest method testMigrateBoundaryEventOnConcurrentUserTask.

@Test
public void testMigrateBoundaryEventOnConcurrentUserTask() {
    // given
    BpmnModelInstance sourceProcess = ProcessModels.PARALLEL_GATEWAY_PROCESS.clone();
    MigratingBpmnEventTrigger eventTrigger = eventFactory.addBoundaryEvent(rule.getProcessEngine(), sourceProcess, USER_TASK_1_ID, BOUNDARY_ID);
    ModifiableBpmnModelInstance.wrap(sourceProcess).flowNodeBuilder(BOUNDARY_ID).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
    BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId("boundary", "newBoundary");
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_1_ID, USER_TASK_1_ID).mapActivities(USER_TASK_2_ID, USER_TASK_2_ID).mapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID).updateEventTrigger().build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    eventTrigger.assertEventTriggerMigrated(testHelper, NEW_BOUNDARY_ID);
    // and it is possible to successfully complete the migrated instance
    testHelper.completeTask(USER_TASK_1_ID);
    testHelper.completeTask(USER_TASK_2_ID);
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : MigratingBpmnEventTrigger(org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Example 15 with MigrationPlan

use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.

the class MigrationBoundaryEventsParameterizedTest method testMigrateBoundaryEventOnUserTaskAndTriggerEvent.

@Test
public void testMigrateBoundaryEventOnUserTaskAndTriggerEvent() {
    // given
    BpmnModelInstance sourceProcess = ProcessModels.ONE_TASK_PROCESS.clone();
    MigratingBpmnEventTrigger eventTrigger = eventFactory.addBoundaryEvent(rule.getProcessEngine(), sourceProcess, USER_TASK_ID, BOUNDARY_ID);
    ModifiableBpmnModelInstance.wrap(sourceProcess).flowNodeBuilder(BOUNDARY_ID).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
    BpmnModelInstance targetProcess = modify(sourceProcess).changeElementId(BOUNDARY_ID, NEW_BOUNDARY_ID);
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(BOUNDARY_ID, NEW_BOUNDARY_ID).updateEventTrigger().build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then it is possible to trigger boundary event and successfully complete the migrated instance
    eventTrigger.inContextOf(NEW_BOUNDARY_ID).trigger(processInstance.getId());
    testHelper.completeTask(AFTER_BOUNDARY_TASK);
    testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Also used : MigratingBpmnEventTrigger(org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger) MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) Test(org.junit.Test)

Aggregations

MigrationPlan (org.camunda.bpm.engine.migration.MigrationPlan)485 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)474 Test (org.junit.Test)474 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)272 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)67 Job (org.camunda.bpm.engine.runtime.Job)48 Task (org.camunda.bpm.engine.task.Task)45 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)26 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)22 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)22 MigratingProcessInstanceValidationException (org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException)21 UserTask (org.camunda.bpm.model.bpmn.instance.UserTask)21 ExecutionTree (org.camunda.bpm.engine.test.util.ExecutionTree)20 Incident (org.camunda.bpm.engine.runtime.Incident)14 ProcessInstanceQuery (org.camunda.bpm.engine.runtime.ProcessInstanceQuery)14 MigratingBpmnEventTrigger (org.camunda.bpm.engine.test.api.runtime.migration.util.MigratingBpmnEventTrigger)14 Batch (org.camunda.bpm.engine.batch.Batch)13 LockedExternalTask (org.camunda.bpm.engine.externaltask.LockedExternalTask)13 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)13 Execution (org.camunda.bpm.engine.runtime.Execution)11