use of org.camunda.bpm.engine.runtime.EventSubscription 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.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MigrationMessageStartEventTest method testMigrateEventSubscriptionWithEventSubProcess.
@Test
public void testMigrateEventSubscriptionWithEventSubProcess() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(EventSubProcessModels.MESSAGE_EVENT_SUBPROCESS_PROCESS);
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId());
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
EventSubscription eventSubscriptionAfter = runtimeService.createEventSubscriptionQuery().singleResult();
assertNotNull(eventSubscriptionAfter);
assertEquals(EventSubProcessModels.MESSAGE_NAME, eventSubscriptionAfter.getEventName());
runtimeService.correlateMessage(EventSubProcessModels.MESSAGE_NAME);
testHelper.completeTask("eventSubProcessTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MigrationMessageStartEventTest method testMigrateEventSubscription.
@Test
public void testMigrateEventSubscription() {
// given
ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(MessageReceiveModels.MESSAGE_START_PROCESS);
String sourceProcessDefinitionId = sourceProcessDefinition.getId();
MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinitionId, sourceProcessDefinitionId).mapEqualActivities().build();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinitionId);
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().activityId("startEvent").eventName(MessageReceiveModels.MESSAGE_NAME).singleResult();
// when
runtimeService.newMigration(migrationPlan).processInstanceIds(processInstance.getId()).execute();
// then
assertEventSubscriptionMigrated(eventSubscription, "startEvent", MessageReceiveModels.MESSAGE_NAME);
testHelper.completeTask("userTask");
testHelper.assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class CallActivityTest method testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml" })
public void testInterruptingMessageEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the message interrupting event sub process
runtimeService.correlateMessage("newMessage");
Task taskAfterMessageStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterMessageStartEvent", taskAfterMessageStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterMessageStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class CallActivityTest method testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity.
@Deployment(resources = { "org/camunda/bpm/engine/test/bpmn/callactivity/CallActivity.testInterruptingEventSubProcessEventSubscriptions.bpmn20.xml", "org/camunda/bpm/engine/test/bpmn/callactivity/interruptingEventSubProcessEventSubscriptions.bpmn20.xml" })
public void testInterruptingSignalEventSubProcessEventSubscriptionsInsideCallActivity() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callInterruptingEventSubProcess");
// one task in the call activity subprocess should be active after starting the process instance
TaskQuery taskQuery = taskService.createTaskQuery();
Task taskInsideCallActivity = taskQuery.singleResult();
assertEquals("taskBeforeInterruptingEventSubprocess", taskInsideCallActivity.getTaskDefinitionKey());
// we should have no event subscriptions for the parent process
assertEquals(0, runtimeService.createEventSubscriptionQuery().processInstanceId(processInstance.getId()).count());
// we should have two event subscriptions for the called process instance, one for message and one for signal
String calledProcessInstanceId = taskInsideCallActivity.getProcessInstanceId();
EventSubscriptionQuery eventSubscriptionQuery = runtimeService.createEventSubscriptionQuery().processInstanceId(calledProcessInstanceId);
List<EventSubscription> subscriptions = eventSubscriptionQuery.list();
assertEquals(2, subscriptions.size());
// start the signal interrupting event sub process
runtimeService.signalEventReceived("newSignal");
Task taskAfterSignalStartEvent = taskQuery.processInstanceId(calledProcessInstanceId).singleResult();
assertEquals("taskAfterSignalStartEvent", taskAfterSignalStartEvent.getTaskDefinitionKey());
// no subscriptions left
assertEquals(0, eventSubscriptionQuery.count());
// Complete the task inside the called process instance
taskService.complete(taskAfterSignalStartEvent.getId());
assertProcessEnded(calledProcessInstanceId);
assertProcessEnded(processInstance.getId());
}
Aggregations