use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationReceiveTaskTest method testMigrateEventSubscriptionUpdateMessageName.
@Test
public void testMigrateEventSubscriptionUpdateMessageName() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS).renameMessage(MessageReceiveModels.MESSAGE_NAME, "new" + MessageReceiveModels.MESSAGE_NAME));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "receiveTask").updateEventTrigger().build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then the message event subscription's event name has not changed
testHelper.assertEventSubscriptionMigrated("receiveTask", MessageReceiveModels.MESSAGE_NAME, "receiveTask", "new" + MessageReceiveModels.MESSAGE_NAME);
// and it is possible to trigger the event
rule.getRuntimeService().correlateMessage("new" + MessageReceiveModels.MESSAGE_NAME);
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationReceiveTaskTest method testMigrateEventSubscriptionChangeActivityId.
@Test
public void testMigrateEventSubscriptionChangeActivityId() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(modify(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS).changeElementId("receiveTask", "newReceiveTask"));
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask", "newReceiveTask").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
testHelper.assertEventSubscriptionMigrated("receiveTask", "newReceiveTask", MessageReceiveModels.MESSAGE_NAME);
// and it is possible to trigger the receive task
rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationReceiveTaskTest method testMigrateSequentialMultiInstanceEventSubscription.
@Test
public void testMigrateSequentialMultiInstanceEventSubscription() {
BpmnModelInstance parallelMiReceiveTaskProcess = modify(MessageReceiveModels.ONE_RECEIVE_TASK_PROCESS).activityBuilder("receiveTask").multiInstance().sequential().cardinality("3").done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(parallelMiReceiveTaskProcess);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(parallelMiReceiveTaskProcess);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("receiveTask#multiInstanceBody", "receiveTask#multiInstanceBody").mapActivities("receiveTask", "receiveTask").build();
// when
ProcessInstance processInstance = testHelper.createProcessInstanceAndMigrate(migrationPlan);
testHelper.assertEventSubscriptionsMigrated("receiveTask", "receiveTask", MessageReceiveModels.MESSAGE_NAME);
// and it is possible to trigger the receive tasks
for (int i = 0; i < 3; i++) {
rule.getRuntimeService().correlateMessage(MessageReceiveModels.MESSAGE_NAME);
}
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationProcessInstanceTest method testNullProcessInstanceIdsArray.
@Test
public void testNullProcessInstanceIdsArray() {
ProcessDefinition testProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(testProcessDefinition.getId(), testProcessDefinition.getId()).mapEqualActivities().build();
try {
runtimeService.newMigration(migrationPlan).processInstanceIds((String[]) null).execute();
fail("Should not be able to migrate");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), CoreMatchers.containsString("process instance ids is empty"));
}
}
use of org.camunda.bpm.engine.migration.MigrationPlan in project camunda-bpm-platform by camunda.
the class MigrationProcessInstanceTest method testNotMigrateProcessInstanceOfWrongProcessDefinition.
@Test
public void testNotMigrateProcessInstanceOfWrongProcessDefinition() {
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition wrongProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.SUBPROCESS_PROCESS);
ProcessInstance processInstance = runtimeService.startProcessInstanceById(wrongProcessDefinition.getId());
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
try {
runtimeService.newMigration(migrationPlan).processInstanceIds(Collections.singletonList(processInstance.getId())).execute();
fail("Should not be able to migrate");
} catch (ProcessEngineException e) {
assertThat(e.getMessage(), CoreMatchers.startsWith("ENGINE-23002"));
}
}
Aggregations