use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationBoundaryEventsTest method testMigrateSignalBoundaryEventKeepTrigger.
@Test
public void testMigrateSignalBoundaryEventKeepTrigger() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).signal(SIGNAL_NAME).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).signal("new" + SIGNAL_NAME).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(targetProcess);
Map<String, String> activities = new HashMap<String, String>();
activities.put(USER_TASK_ID, USER_TASK_ID);
activities.put(BOUNDARY_ID, BOUNDARY_ID);
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(BOUNDARY_ID, BOUNDARY_ID).build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertEventSubscriptionMigrated(BOUNDARY_ID, BOUNDARY_ID, SIGNAL_NAME);
// and no event subscription for the new message name exists
EventSubscription eventSubscription = rule.getRuntimeService().createEventSubscriptionQuery().eventName("new" + SIGNAL_NAME).singleResult();
assertNull(eventSubscription);
assertEquals(1, rule.getRuntimeService().createEventSubscriptionQuery().count());
// and it is possible to trigger the event with the old message name and successfully complete the migrated instance
rule.getProcessEngine().getRuntimeService().signalEventReceived(SIGNAL_NAME);
testHelper.completeTask(AFTER_BOUNDARY_TASK);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationBoundaryEventsTest method testUpdateEventMessageNameWithExpression.
@Test
public void testUpdateEventMessageNameWithExpression() {
// given
String messageNameWithExpression = "new" + MESSAGE_NAME + "-${var}";
BpmnModelInstance sourceProcess = ProcessModels.ONE_TASK_PROCESS;
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).message(messageNameWithExpression).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
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).build();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("var", "foo");
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan, variables);
// the message event subscription's event name has changed
String resolvedMessageName = "new" + MESSAGE_NAME + "-foo";
testHelper.assertEventSubscriptionCreated(BOUNDARY_ID, resolvedMessageName);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().correlateMessage(resolvedMessageName);
testHelper.completeTask(AFTER_BOUNDARY_TASK);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationEventSubProcessTest method testUpdateEventMessage.
@Test
public void testUpdateEventMessage() {
// given
BpmnModelInstance sourceProcess = EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS;
BpmnModelInstance targetProcess = modify(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS).renameMessage(EventSubProcessModels.MESSAGE_NAME, "new" + EventSubProcessModels.MESSAGE_NAME);
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(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).updateEventTrigger().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.MESSAGE_NAME, EVENT_SUB_PROCESS_START_ID, "new" + EventSubProcessModels.MESSAGE_NAME);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().correlateMessage("new" + EventSubProcessModels.MESSAGE_NAME);
testHelper.completeTask(EVENT_SUB_PROCESS_TASK_ID);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationEventSubProcessTest method testUpdateEventMessageWithExpression.
@Test
public void testUpdateEventMessageWithExpression() {
// given
String newMessageNameWithExpression = "new" + EventSubProcessModels.MESSAGE_NAME + "-${var}";
BpmnModelInstance sourceProcess = EventSubProcessModels.MESSAGE_INTERMEDIATE_EVENT_SUBPROCESS_PROCESS;
BpmnModelInstance targetProcess = modify(EventSubProcessModels.MESSAGE_INTERMEDIATE_EVENT_SUBPROCESS_PROCESS).renameMessage(EventSubProcessModels.MESSAGE_NAME, newMessageNameWithExpression);
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("eventSubProcess", "eventSubProcess").mapActivities("catchMessage", "catchMessage").updateEventTrigger().build();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("var", "foo");
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan, variables);
// then
String resolvedMessageName = "new" + EventSubProcessModels.MESSAGE_NAME + "-foo";
testHelper.assertEventSubscriptionMigrated("catchMessage", EventSubProcessModels.MESSAGE_NAME, "catchMessage", resolvedMessageName);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().correlateMessage(resolvedMessageName);
testHelper.completeTask(USER_TASK_ID);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationEventSubProcessTest method testUpdateEventSignalWithExpression.
@Test
public void testUpdateEventSignalWithExpression() {
// given
String newSignalNameWithExpression = "new" + EventSubProcessModels.MESSAGE_NAME + "-${var}";
BpmnModelInstance sourceProcess = EventSubProcessModels.SIGNAL_EVENT_SUBPROCESS_PROCESS;
BpmnModelInstance targetProcess = modify(EventSubProcessModels.SIGNAL_EVENT_SUBPROCESS_PROCESS).renameSignal(EventSubProcessModels.SIGNAL_NAME, newSignalNameWithExpression);
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(EVENT_SUB_PROCESS_START_ID, EVENT_SUB_PROCESS_START_ID).updateEventTrigger().build();
HashMap<String, Object> variables = new HashMap<String, Object>();
variables.put("var", "foo");
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan, variables);
// then
String resolvedsignalName = "new" + EventSubProcessModels.MESSAGE_NAME + "-foo";
testHelper.assertEventSubscriptionMigrated(EVENT_SUB_PROCESS_START_ID, EventSubProcessModels.SIGNAL_NAME, EVENT_SUB_PROCESS_START_ID, resolvedsignalName);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().signalEventReceived(resolvedsignalName);
testHelper.completeTask(EVENT_SUB_PROCESS_TASK_ID);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Aggregations