use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class EventSubscriptionAuthorizationTest method testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess.
public void testSimpleQueryWithReadInstancesPermissionOnOneTaskProcess() {
// given
String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId();
createGrantAuthorization(PROCESS_DEFINITION, ONE_TASK_PROCESS_KEY, userId, READ_INSTANCE);
// when
EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery();
// then
verifyQueryResults(query, 1);
EventSubscription eventSubscription = query.singleResult();
assertNotNull(eventSubscription);
assertEquals(processInstanceId, eventSubscription.getProcessInstanceId());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MultiTenancyExecutionPropagationTest method testPropagateTenantIdToStartMessageEventSubscription.
public void testPropagateTenantIdToStartMessageEventSubscription() {
deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY).startEvent().message("start").endEvent().done());
// the event subscription of the message start is created on deployment
EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult();
assertThat(eventSubscription, is(notNullValue()));
// inherit the tenant id from process definition
assertThat(eventSubscription.getTenantId(), is(TENANT_ID));
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MigrationTestRule method assertEventSubscriptionMigrated.
protected void assertEventSubscriptionMigrated(EventSubscription eventSubscriptionBefore, String activityIdAfter, String eventName) {
EventSubscription eventSubscriptionAfter = snapshotAfterMigration.getEventSubscriptionById(eventSubscriptionBefore.getId());
assertNotNull("Expected that an event subscription with id '" + eventSubscriptionBefore.getId() + "' " + "exists after migration", eventSubscriptionAfter);
assertEquals(eventSubscriptionBefore.getEventType(), eventSubscriptionAfter.getEventType());
assertEquals(activityIdAfter, eventSubscriptionAfter.getActivityId());
assertEquals(eventName, eventSubscriptionAfter.getEventName());
}
use of org.camunda.bpm.engine.runtime.EventSubscription in project camunda-bpm-platform by camunda.
the class MigrationTestRule method assertEventSubscriptionRemoved.
public void assertEventSubscriptionRemoved(String activityId, String eventName) {
EventSubscription eventSubscriptionBefore = snapshotBeforeMigration.getEventSubscriptionForActivityIdAndEventName(activityId, eventName);
assertNotNull("Expected an event subscription for activity '" + activityId + "' before the migration", eventSubscriptionBefore);
for (EventSubscription eventSubscription : snapshotAfterMigration.getEventSubscriptions()) {
if (eventSubscriptionBefore.getId().equals(eventSubscription.getId())) {
fail("Expected event subscription '" + eventSubscriptionBefore.getId() + "' to be removed after migration");
}
}
}
use of org.camunda.bpm.engine.runtime.EventSubscription 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