use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertExecutionTree.
@Test
public void testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertExecutionTree() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_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());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCannotTriggerAddedCompensationForCompletedInstances.
@Test
public void testCannotTriggerAddedCompensationForCompletedInstances() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask1", "userTask1").mapActivities("userTask2", "userTask2").build();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
Assert.assertEquals(0, testHelper.snapshotAfterMigration.getEventSubscriptions().size());
testHelper.completeTask("userTask2");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertActivityInstance.
@Test
public void testCanMigrateWithCompensationSubscriptionsInMigratingScopeAssertActivityInstance() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_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");
// a migrated process instance
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// when triggering compensation
testHelper.completeTask("userTask2");
// then the activity instance tree is correct
ActivityInstance activityInstance = rule.getRuntimeService().getActivityInstance(processInstance.getId());
assertThat(activityInstance).hasStructure(describeActivityInstanceTree(targetProcessDefinition.getId()).activity("compensationEvent").activity("compensationHandler").done());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCannotRemoveCompensationEventSubscriptions.
@Test
public void testCannotRemoveCompensationEventSubscriptions() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.ONE_COMPENSATION_TASK_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.TWO_TASKS_PROCESS);
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").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 'compensationHandler'. " + "There is no migration instruction for the compensation boundary event");
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationCompensationTest method testCanMigrateWithCompensationEventScopeExecutionChangeIds.
@Test
public void testCanMigrateWithCompensationEventScopeExecutionChangeIds() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(CompensationModels.COMPENSATION_ONE_TASK_SUBPROCESS_MODEL).changeElementId("subProcess", "newSubProcess").changeElementId("userTask1", "newUserTask1").changeElementId("compensationBoundary", "newCompensationBoundary").changeElementId("compensationHandler", "newCompensationHandler"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("userTask2", "userTask2").mapActivities("subProcess", "newSubProcess").mapActivities("compensationBoundary", "newCompensationBoundary").build();
ProcessInstance processInstance = rule.getRuntimeService().startProcessInstanceById(sourceProcessDefinition.getId());
testHelper.completeTask("userTask1");
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
testHelper.assertEventSubscriptionMigrated("subProcess", "newSubProcess", null);
testHelper.assertEventSubscriptionMigrated("compensationHandler", "newCompensationHandler", null);
// and the compensation can be triggered and completed
testHelper.completeTask("userTask2");
testHelper.completeTask("newCompensationHandler");
testHelper.assertProcessEnded(processInstance.getId());
}
Aggregations