use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationPlanGenerationTest method testMapIntermediateConditionalEvent.
@Test
public void testMapIntermediateConditionalEvent() {
BpmnModelInstance sourceProcess = Bpmn.createExecutableProcess(CONDITIONAL_PROCESS_KEY).startEvent().intermediateCatchEvent(CONDITION_ID).condition(VAR_CONDITION).userTask(USER_TASK_ID).endEvent().done();
assertGeneratedMigrationPlan(sourceProcess, sourceProcess, false).hasInstructions(migrate(CONDITION_ID).to(CONDITION_ID).updateEventTrigger(true), migrate(USER_TASK_ID).to(USER_TASK_ID).updateEventTrigger(false));
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance 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.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationActiveEventSubProcessTest method testMigrateActiveCompensationEventSubProcess.
@Test
public void testMigrateActiveCompensationEventSubProcess() {
// given
BpmnModelInstance processModel = ProcessModels.ONE_TASK_PROCESS.clone();
MigratingBpmnEventTrigger eventTrigger = eventFactory.addEventSubProcess(rule.getProcessEngine(), processModel, ProcessModels.PROCESS_KEY, "eventSubProcess", "eventSubProcessStart");
ModifiableBpmnModelInstance.wrap(processModel).startEventBuilder("eventSubProcessStart").userTask("eventSubProcessTask").endEvent().done();
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(processModel);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(processModel);
ProcessInstance processInstance = rule.getRuntimeService().createProcessInstanceById(sourceProcessDefinition.getId()).startBeforeActivity("eventSubProcessStart").executeWithVariablesInReturn();
MigrationPlan migrationPlan = rule.getRuntimeService().createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapActivities("eventSubProcess", "eventSubProcess").mapActivities("eventSubProcessStart", "eventSubProcessStart").updateEventTrigger().mapActivities("eventSubProcessTask", "eventSubProcessTask").build();
// when
testHelper.migrateProcessInstance(migrationPlan, processInstance);
// then
eventTrigger.assertEventTriggerMigrated(testHelper, "eventSubProcessStart");
// and it is possible to complete the process instance
testHelper.completeTask("eventSubProcessTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.model.bpmn.BpmnModelInstance in project camunda-bpm-platform by camunda.
the class MigrationBoundaryEventsTest method testUpdateEventTimer.
@Test
public void testUpdateEventTimer() {
// given
ClockTestUtil.setClockToDateWithoutMilliseconds();
BpmnModelInstance sourceProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDate(TIMER_DATE).userTask(AFTER_BOUNDARY_TASK).endEvent().done();
BpmnModelInstance targetProcess = modify(ProcessModels.ONE_TASK_PROCESS).activityBuilder(USER_TASK_ID).boundaryEvent(BOUNDARY_ID).timerWithDuration("PT50M").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
Date newDueDate = new DateTime(ClockUtil.getCurrentTime()).plusMinutes(50).toDate();
testHelper.assertJobMigrated(testHelper.snapshotBeforeMigration.getJobs().get(0), BOUNDARY_ID, newDueDate);
// and it is possible to successfully complete the migrated instance
Job jobAfterMigration = testHelper.snapshotAfterMigration.getJobs().get(0);
rule.getManagementService().executeJob(jobAfterMigration.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 testMigrateMessageBoundaryEventKeepTrigger.
@Test
public void testMigrateMessageBoundaryEventKeepTrigger() {
// 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);
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, MESSAGE_NAME);
// and no event subscription for the new message name exists
EventSubscription eventSubscription = rule.getRuntimeService().createEventSubscriptionQuery().eventName("new" + MESSAGE_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().correlateMessage(MESSAGE_NAME);
testHelper.completeTask(AFTER_BOUNDARY_TASK);
testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId());
}
Aggregations