Search in sources :

Example 36 with MigrationPlan

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

the class MigrationCompensationTest method testCanMigrateWithCompensationSubscriptionsInMigratingScopeChangeIds.

@Test
public void testCanMigrateWithCompensationSubscriptionsInMigratingScopeChangeIds() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.ONE_COMPENSATION_TASK_MODEL).changeElementId("userTask1", "newUserTask1").changeElementId("compensationBoundary", "newCompensationBoundary").changeElementId("compensationHandler", "newCompensationHandler"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "newCompensationBoundary").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertEventSubscriptionMigrated("compensationHandler", "newCompensationHandler", null);
    // and the compensation can be triggered and completed
    testHelper.completeTask("userTask2");
    testHelper.completeTask("newCompensationHandler");
    testHelper.assertProcessEnded(processInstance.getId());
}
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 37 with MigrationPlan

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

the class MigrationCompensationTest method testCanMigrateWithEventSubProcessHandlerChangeIds.

@Test
public void testCanMigrateWithEventSubProcessHandlerChangeIds() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL).changeElementId("eventSubProcess", "newEventSubProcess"));
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").mapActivities("subProcess", "subProcess").mapActivities("eventSubProcessStart", "eventSubProcessStart").build();
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    // when
    testHelper.migrateProcessInstance(migrationPlan, processInstance);
    // then
    testHelper.assertEventSubscriptionMigrated("eventSubProcess", "newEventSubProcess", null);
    // and the compensation can be triggered and completed
    testHelper.completeTask("userTask2");
    testHelper.completeTask("eventSubProcessTask");
    testHelper.completeTask("compensationHandler");
    testHelper.assertProcessEnded(processInstance.getId());
}
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 38 with MigrationPlan

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

the class MigrationCompensationTest method testCannotMigrateWithoutCompensationStartEventCase1.

@Test
public void testCannotMigrateWithoutCompensationStartEventCase1() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_EVENT_SUBPROCESS_MODEL);
    ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
    testHelper.completeTask("userTask1");
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("subProcess", "subProcess").mapActivities("userTask2", "userTask2").mapActivities("compensationBoundary", "compensationBoundary").build();
    // when
    try {
        testHelper.migrateProcessInstance(migrationPlan, processInstance);
        Assert.fail("should fail");
    } catch (MigratingProcessInstanceValidationException e) {
        // then
        assertThat(e.getValidationReport()).hasProcessInstanceId(testHelper.snapshotBeforeMigration.getProcessInstanceId()).hasActivityInstanceFailures(sourceProcessDefinition.getId(), "Cannot migrate subscription for compensation handler 'eventSubProcess'. " + "There is no migration instruction for the compensation start event");
    }
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) MigratingProcessInstanceValidationException(org.camunda.bpm.engine.migration.MigratingProcessInstanceValidationException) Test(org.junit.Test)

Example 39 with MigrationPlan

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

the class MigrationCompensationTest method testCanTriggerAddedCompensationForActiveInstances.

@Test
public void testCanTriggerAddedCompensationForActiveInstances() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask", "userTask1").build();
    // when
    ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.completeTask("userTask1");
    Assert.assertEquals(1, rule.getRuntimeService().createEventSubscriptionQuery().count());
    testHelper.completeTask("userTask2");
    testHelper.completeTask("compensationHandler");
    testHelper.assertProcessEnded(processInstance.getId());
}
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 40 with MigrationPlan

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

the class MigrationEventBasedGatewayTest method testMigrateGatewayRemoveMessageEvent.

@Test
public void testMigrateGatewayRemoveMessageEvent() {
    // given
    ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(modify(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS).flowNodeBuilder("eventBasedGateway").intermediateCatchEvent("oldMessageCatch").message("old" + EventBasedGatewayModels.MESSAGE_NAME).endEvent().done());
    ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventBasedGatewayModels.MESSAGE_EVENT_BASED_GW_PROCESS);
    MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventBasedGateway", "eventBasedGateway").mapActivities("messageCatch", "messageCatch").build();
    // when
    testHelper.createProcessInstanceAndMigrate(migrationPlan);
    // then
    testHelper.assertEventSubscriptionRemoved("oldMessageCatch", "old" + EventBasedGatewayModels.MESSAGE_NAME);
    testHelper.assertEventSubscriptionMigrated("messageCatch", "messageCatch", EventBasedGatewayModels.MESSAGE_NAME);
}
Also used : MigrationPlan(org.camunda.bpm.engine.migration.MigrationPlan) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) 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