use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationBoundaryEventsTest method testUpdateEventMessage.
@Test
public void testUpdateEventMessage() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).message(MESSAGE_NAME).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).message("new" + MESSAGE_NAME).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).mapActivities(BOUNDARY_ID, BOUNDARY_ID).updateEventTrigger().build();
// when
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then
testHelper.assertEventSubscriptionMigrated(BOUNDARY_ID, MESSAGE_NAME, BOUNDARY_ID, "new" + MESSAGE_NAME);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().correlateMessage("new" + MESSAGE_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 testUpdateEventSignalNameWithExpression.
@Test
public void testUpdateEventSignalNameWithExpression() {
// given
String signalNameWithExpression = "new" + SIGNAL_NAME + "-${var}";
BpmnModelInstance sourceProcess = ProcessModels.ONE_TASK_PROCESS;
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).signal(signalNameWithExpression).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 signal event subscription's event name has changed
String resolvedSignalName = "new" + SIGNAL_NAME + "-foo";
testHelper.assertEventSubscriptionCreated(BOUNDARY_ID, resolvedSignalName);
// and it is possible to successfully complete the migrated instance
rule.getRuntimeService().signalEventReceived(resolvedSignalName);
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 testUpdateConditionalEventExpression.
@Test
public void testUpdateConditionalEventExpression() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).condition(FALSE_CONDITION).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).condition(VAR_CONDITION).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).mapActivities(BOUNDARY_ID, BOUNDARY_ID).updateEventTrigger().build();
// when process is migrated without update event trigger
testHelper.createProcessInstanceAndMigrate(migrationPlan);
// then condition is migrated and has new condition expr
testHelper.assertEventSubscriptionMigrated(BOUNDARY_ID, BOUNDARY_ID, null);
// and it is possible to successfully complete the migrated instance
testHelper.setAnyVariable(testHelper.snapshotAfterMigration.getProcessInstanceId());
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 testMigrateTimerBoundaryEventKeepTrigger.
@Test
public void testMigrateTimerBoundaryEventKeepTrigger() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT5S").userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT10M").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.assertJobMigrated(BOUNDARY_ID, BOUNDARY_ID, TimerExecuteNestedActivityJobHandler.TYPE);
// and it is possible to trigger the event and successfully complete the migrated instance
ManagementService managementService = rule.getManagementService();
Job job = managementService.createJobQuery().singleResult();
managementService.executeJob(job.getId());
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 testMigrateConditionalBoundaryEventKeepTrigger.
@Test
public void testMigrateConditionalBoundaryEventKeepTrigger() {
// given
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).condition(FALSE_CONDITION).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(sourceProcess);
// expected migration validation exception
exceptionRule.expect(MigrationPlanValidationException.class);
exceptionRule.expectMessage(MIGRATION_CONDITIONAL_VALIDATION_ERROR_MSG);
// when conditional boundary event is migrated without update event trigger
rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities(USER_TASK_ID, USER_TASK_ID).mapActivities(BOUNDARY_ID, BOUNDARY_ID).build();
}
Aggregations