org.camunda.bpm.engine.runtime.EventSubscription Java Examples
The following examples show how to use
org.camunda.bpm.engine.runtime.EventSubscription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConditionalStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { ONE_TASK_PROCESS }) public void testStartInstanceByProcessDefinitionIdWithoutCondition() { // given deployed process without conditional start event String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("oneTaskProcess").singleResult().getId(); List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); assertEquals(0, eventSubscriptions.size()); thrown.expect(ProcessEngineException.class); thrown.expectMessage("Process definition with id '" + processDefinitionId + "' does not declare conditional start event"); // when runtimeService .createConditionEvaluation() .processDefinitionId(processDefinitionId) .evaluateStartConditions(); }
Example #2
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.singleReceiveTask.bpmn20.xml") public void testSupportsMessageEventReceivedOnSingleReceiveTask() { // given: a process instance waiting in the receive task ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there is a message event subscription for the task List<EventSubscription> subscriptionList = getEventSubscriptionList(); assertEquals(1, subscriptionList.size()); EventSubscription subscription = subscriptionList.get(0); // then: we can trigger the event subscription runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId()); // expect: subscription is removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #3
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.parallelGatewayReceiveTask.bpmn20.xml") public void testSupportsCorrelateMessageOnReceiveTaskBehindParallelGateway() { // given: a process instance waiting in two receive tasks ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there are two message event subscriptions List<EventSubscription> subscriptions = getEventSubscriptionList(); assertEquals(2, subscriptions.size()); // then: we can trigger both receive task event subscriptions runtimeService.correlateMessage(subscriptions.get(0).getEventName()); runtimeService.correlateMessage(subscriptions.get(1).getEventName()); // expect: subscriptions are removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #4
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTaskBoundary.bpmn20.xml") public void testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundary() { // given: a process instance waiting in two receive tasks ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there are three message event subscriptions assertEquals(3, getEventSubscriptionList().size()); // expect: there are two message event subscriptions for the receive tasks List<EventSubscription> subscriptions = getEventSubscriptionList("waitState"); assertEquals(2, subscriptions.size()); // then: we can trigger both receive task event subscriptions runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId()); runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId()); // expect: all subscriptions are removed (boundary subscription is removed too) assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #5
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.parallelGatewayReceiveTask.bpmn20.xml") public void testSupportsMessageEventReceivedOnReceiveTaskBehindParallelGateway() { // given: a process instance waiting in two receive tasks ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there are two message event subscriptions List<EventSubscription> subscriptions = getEventSubscriptionList(); assertEquals(2, subscriptions.size()); // then: we can trigger both receive task event subscriptions runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId()); runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId()); // expect: subscriptions are removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #6
Source File: InvocationContextTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @OperateOnDeployment("app") public void testInvokeProcessApplicationWithContextOnMessageReceived() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("messageProcess"); ProcessApplicationWithInvocationContext.clearInvocationContext(); EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().eventType("message").processInstanceId(processInstance.getId()).singleResult(); assertThat(messageSubscription, is(notNullValue())); runtimeService.messageEventReceived(messageSubscription.getEventName(), messageSubscription.getExecutionId()); InvocationContext invocationContext = ProcessApplicationWithInvocationContext.getInvocationContext(); assertThat(invocationContext, is(notNullValue())); assertThat(invocationContext.getExecution(), is(notNullValue())); assertThat(invocationContext.getExecution().getId(), is(messageSubscription.getExecutionId())); }
Example #7
Source File: ConditionalStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = SINGLE_CONDITIONAL_START_EVENT_XML) public void testDeploymentCreatesSubscriptions() { // given a deployed process String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey(CONDITIONAL_EVENT_PROCESS).singleResult().getId(); // when List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); // then assertEquals(1, eventSubscriptions.size()); EventSubscriptionEntity conditionalEventSubscription = (EventSubscriptionEntity) eventSubscriptions.get(0); assertEquals(EventType.CONDITONAL.name(), conditionalEventSubscription.getEventType()); assertEquals(processDefinitionId, conditionalEventSubscription.getConfiguration()); assertNull(conditionalEventSubscription.getEventName()); assertNull(conditionalEventSubscription.getExecutionId()); assertNull(conditionalEventSubscription.getProcessInstanceId()); }
Example #8
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.subProcessReceiveTask.bpmn20.xml") public void testSupportsMessageEventReceivedOnSubProcessReceiveTask() { // given: a process instance waiting in the sub-process receive task ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there is a message event subscription for the task List<EventSubscription> subscriptionList = getEventSubscriptionList(); assertEquals(1, subscriptionList.size()); EventSubscription subscription = subscriptionList.get(0); // then: we can trigger the event subscription runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId()); // expect: subscription is removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #9
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTaskBoundary.bpmn20.xml") public void testSupportsMessageEventReceivedOnParallelMultiInstanceWithBoundaryEventReceived() { // given: a process instance waiting in two receive tasks ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there are three message event subscriptions assertEquals(3, getEventSubscriptionList().size()); // expect: there is one message event subscription for the boundary event List<EventSubscription> subscriptions = getEventSubscriptionList("cancel"); assertEquals(1, subscriptions.size()); EventSubscription subscription = subscriptions.get(0); // then: we can trigger the boundary subscription to cancel both tasks runtimeService.messageEventReceived(subscription.getEventName(), subscription.getExecutionId()); // expect: all subscriptions are removed (receive task subscriptions too) assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #10
Source File: EventSubscriptionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryByActivityId() { createExampleEventSubscriptions(); List<EventSubscription> list = runtimeService.createEventSubscriptionQuery() .activityId("someOtherActivity") .list(); assertEquals(1, list.size()); list = runtimeService.createEventSubscriptionQuery() .activityId("someActivity") .eventType("message") .list(); assertEquals(2, list.size()); try { runtimeService.createEventSubscriptionQuery().activityId(null).list(); fail("Expected ProcessEngineException"); } catch (ProcessEngineException e) { } cleanDb(); }
Example #11
Source File: BoundaryErrorEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment public void testCatchErrorOnSubprocessThrownByNestedEventSubprocess() { runtimeService.startProcessInstanceByKey("testProcess"); // trigger outer event subprocess EventSubscription messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); runtimeService.messageEventReceived("outerMessage", messageSubscription.getExecutionId()); // trigger inner event subprocess messageSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); runtimeService.messageEventReceived("innerMessage", messageSubscription.getExecutionId()); // should successfully have reached the task following the boundary event Execution taskExecution = runtimeService.createExecutionQuery().activityId("afterBoundaryTask").singleResult(); assertNotNull(taskExecution); Task task = taskService.createTaskQuery().executionId(taskExecution.getId()).singleResult(); assertNotNull(task); }
Example #12
Source File: ConditionalStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { SINGLE_CONDITIONAL_START_EVENT_XML, MULTIPLE_CONDITION_XML, TRUE_CONDITION_START_XML }) public void testStartInstanceWithMultipleSubscriptionsWithoutProvidingAllVariables() { // given three deployed processes List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); assertEquals(5, eventSubscriptions.size()); Map<String, Object> variableMap = new HashMap<String, Object>(); variableMap.put("foo", 1); // when, it should not throw PropertyNotFoundException List<ProcessInstance> instances = runtimeService .createConditionEvaluation() .setVariables(variableMap) .evaluateStartConditions(); // then assertEquals(3, instances.size()); }
Example #13
Source File: ConditionalStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = START_INSTANCE_WITH_VARIABLE_NAME_XML) public void testStartInstanceWithVariableNameNotFullfilled() { // given deployed process // ${true} variableName="foo" // assume List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); assertEquals(1, eventSubscriptions.size()); // when List<ProcessInstance> instances = runtimeService .createConditionEvaluation() .evaluateStartConditions(); // then assertEquals(0, instances.size()); }
Example #14
Source File: ProcessInstanceModificationCancellationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = INTERRUPTING_EVENT_SUBPROCESS) public void testProcessInstanceEventSubscriptionsPreservedOnIntermediateCancellation() { ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process"); // event subscription for the event subprocess EventSubscription subscription = runtimeService.createEventSubscriptionQuery().singleResult(); assertNotNull(subscription); assertEquals(processInstance.getId(), subscription.getProcessInstanceId()); // when I execute cancellation and then start, such that the intermediate state of the process instance // has no activities ActivityInstance tree = runtimeService.getActivityInstance(processInstance.getId()); runtimeService.createProcessInstanceModification(processInstance.getId()) .cancelActivityInstance(getInstanceIdForActivity(tree, "task1")) .startBeforeActivity("task1") .execute(); // then the message event subscription remains (i.e. it is not deleted and later re-created) EventSubscription updatedSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); assertNotNull(updatedSubscription); assertEquals(subscription.getId(), updatedSubscription.getId()); assertEquals(subscription.getProcessInstanceId(), updatedSubscription.getProcessInstanceId()); }
Example #15
Source File: EventSubscriptionAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryWithReadPermissionOnProcessInstance() { // given startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); startProcessInstanceByKey(ONE_TASK_PROCESS_KEY); String processInstanceId = startProcessInstanceByKey(ONE_TASK_PROCESS_KEY).getId(); startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY); startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY); startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY); startProcessInstanceByKey(SIGNAL_BOUNDARY_PROCESS_KEY); createGrantAuthorization(PROCESS_INSTANCE, processInstanceId, userId, READ); // when EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery(); // then verifyQueryResults(query, 1); EventSubscription eventSubscription = query.singleResult(); assertNotNull(eventSubscription); assertEquals(processInstanceId, eventSubscription.getProcessInstanceId()); }
Example #16
Source File: ConditionalStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test @Deployment(resources = { SINGLE_CONDITIONAL_START_EVENT_XML, MULTIPLE_CONDITION_XML }) public void testStartInstanceWithBusinessKey() { // given two deployed processes List<EventSubscription> eventSubscriptions = runtimeService.createEventSubscriptionQuery().list(); assertEquals(4, eventSubscriptions.size()); // when List<ProcessInstance> instances = runtimeService .createConditionEvaluation() .setVariable("foo", 1) .processInstanceBusinessKey("humuhumunukunukuapua") .evaluateStartConditions(); // then assertEquals(2, instances.size()); assertEquals(2, runtimeService.createProcessInstanceQuery().processInstanceBusinessKey("humuhumunukunukuapua").count()); }
Example #17
Source File: MigrationMessageStartEventTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@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()); }
Example #18
Source File: MultiTenancyExecutionPropagationTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testPropagateTenantIdToIntermediateSignalEventSubscription() { deploymentForTenant(TENANT_ID, Bpmn.createExecutableProcess(PROCESS_DEFINITION_KEY) .startEvent() .intermediateCatchEvent() .signal("start") .endEvent() .done()); startProcessInstance(PROCESS_DEFINITION_KEY); EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); assertThat(eventSubscription, is(notNullValue())); // inherit the tenant id from process instance assertThat(eventSubscription.getTenantId(), is(TENANT_ID)); }
Example #19
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.singleReceiveTask.bpmn20.xml") public void testSupportsCorrelateMessageOnSingleReceiveTask() { // given: a process instance waiting in the receive task ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there is a message event subscription for the task List<EventSubscription> subscriptionList = getEventSubscriptionList(); assertEquals(1, subscriptionList.size()); EventSubscription subscription = subscriptionList.get(0); // then: we can correlate the event subscription runtimeService.correlateMessage(subscription.getEventName()); // expect: subscription is removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #20
Source File: ReceiveTaskTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Deployment(resources = "org/camunda/bpm/engine/test/bpmn/receivetask/ReceiveTaskTest.multiParallelReceiveTask.bpmn20.xml") public void testSupportsMessageEventReceivedOnParallelMultiReceiveTask() { // given: a process instance waiting in two receive tasks ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testProcess"); // expect: there are two message event subscriptions List<EventSubscription> subscriptions = getEventSubscriptionList(); assertEquals(2, subscriptions.size()); // then: we can trigger both event subscriptions runtimeService.messageEventReceived(subscriptions.get(0).getEventName(), subscriptions.get(0).getExecutionId()); runtimeService.messageEventReceived(subscriptions.get(1).getEventName(), subscriptions.get(1).getExecutionId()); // expect: both event subscriptions are removed assertEquals(0, getEventSubscriptionList().size()); // expect: this ends the process instance assertProcessEnded(processInstance.getId()); }
Example #21
Source File: EventSubscriptionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
public void testQueryByEventSubscriptionId() { createExampleEventSubscriptions(); List<EventSubscription> list = runtimeService.createEventSubscriptionQuery() .eventName("messageName2") .list(); assertEquals(1, list.size()); EventSubscription eventSubscription = list.get(0); EventSubscriptionQuery query = runtimeService.createEventSubscriptionQuery() .eventSubscriptionId(eventSubscription.getId()); assertEquals(1, query.count()); assertEquals(1, query.list().size()); assertNotNull(query.singleResult()); try { runtimeService.createEventSubscriptionQuery().eventSubscriptionId(null).list(); fail("Expected ProcessEngineException"); } catch (ProcessEngineException e) { } cleanDb(); }
Example #22
Source File: ProcessInstanceSnapshot.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public EventSubscription getEventSubscriptionForActivityIdAndEventName(String activityId, String eventName) { List<EventSubscription> collectedEventsubscriptions = getEventSubscriptionsForActivityIdAndEventName(activityId, eventName); if (collectedEventsubscriptions.isEmpty()) { return null; } else if (collectedEventsubscriptions.size() == 1) { return collectedEventsubscriptions.get(0); } else { throw new RuntimeException("There is more than one event subscription for activity " + activityId + " and event " + eventName); } }
Example #23
Source File: ProcessInstanceSnapshot.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public EventSubscription getEventSubscriptionById(String id) { for (EventSubscription subscription : eventSubscriptions) { if (subscription.getId().equals(id)) { return subscription; } } return null; }
Example #24
Source File: ProcessInstanceSnapshot.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public List<EventSubscription> getEventSubscriptionsForActivityIdAndEventName(String activityId, String eventName) { List<EventSubscription> collectedEventsubscriptions = new ArrayList<EventSubscription>(); for (EventSubscription eventSubscription : getEventSubscriptions()) { if (activityId.equals(eventSubscription.getActivityId())) { if ((eventName == null && eventSubscription.getEventName() == null) || eventName != null && eventName.equals(eventSubscription.getEventName())) { collectedEventsubscriptions.add(eventSubscription); } } } return collectedEventsubscriptions; }
Example #25
Source File: CompensateEventTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
/** * CAM-4387 */ @Deployment public void FAILING_testReceiveTaskCompensationHandler() { // given a process instance ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("receiveTaskCompensationHandler"); // when triggering compensation Task beforeCompensationTask = taskService.createTaskQuery().singleResult(); taskService.complete(beforeCompensationTask.getId()); // then there is a message event subscription for the receive task compensation handler EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); assertNotNull(eventSubscription); assertEquals(EventType.MESSAGE, eventSubscription.getEventType()); // and triggering the message completes compensation runtimeService.correlateMessage("Message"); Task afterCompensationTask = taskService.createTaskQuery().singleResult(); assertNotNull(afterCompensationTask); assertEquals("beforeEnd", afterCompensationTask.getTaskDefinitionKey()); taskService.complete(afterCompensationTask.getId()); // and the process has successfully ended assertProcessEnded(processInstance.getId()); }
Example #26
Source File: MigrationTestRule.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
public void assertEventSubscriptionCreated(String activityId, String eventName) { EventSubscription eventSubscriptionAfter = snapshotAfterMigration.getEventSubscriptionForActivityIdAndEventName(activityId, eventName); assertNotNull("Expected an event subscription for activity '" + activityId + "' after the migration", eventSubscriptionAfter); for (EventSubscription eventSubscription : snapshotBeforeMigration.getEventSubscriptions()) { if (eventSubscriptionAfter.getId().equals(eventSubscription.getId())) { fail("Expected event subscription '" + eventSubscriptionAfter.getId() + "' to be created after migration"); } } }
Example #27
Source File: EventSubscriptionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void cleanDb() { processEngineConfiguration.getCommandExecutorTxRequired() .execute(new Command<Void>() { public Void execute(CommandContext commandContext) { final List<EventSubscription> subscriptions = new EventSubscriptionQueryImpl().list(); for (EventSubscription eventSubscriptionEntity : subscriptions) { ((EventSubscriptionEntity) eventSubscriptionEntity).delete(); } return null; } }); }
Example #28
Source File: BatchMigrationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void testUpdateEventTrigger() { // given String newMessageName = "newMessage"; ProcessDefinition sourceProcessDefinition = migrationRule.deployAndGetDefinition(ProcessModels.ONE_RECEIVE_TASK_PROCESS); ProcessDefinition targetProcessDefinition = migrationRule.deployAndGetDefinition(modify(ProcessModels.ONE_RECEIVE_TASK_PROCESS) .renameMessage("Message", newMessageName) ); ProcessInstance processInstance = runtimeService.startProcessInstanceById(sourceProcessDefinition.getId()); MigrationPlan migrationPlan = runtimeService.createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapEqualActivities() .updateEventTriggers() .build(); Batch batch = runtimeService.newMigration(migrationPlan) .processInstanceIds(Collections.singletonList(processInstance.getId())) .executeAsync(); helper.completeSeedJobs(batch); // when helper.executeJobs(batch); // then the message event subscription's event name was changed EventSubscription eventSubscription = runtimeService.createEventSubscriptionQuery().singleResult(); assertEquals(newMessageName, eventSubscription.getEventName()); }
Example #29
Source File: EventSubscriptionQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Deployment public void testQueryByExecutionId() { // starting two instances: ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("catchSignal"); runtimeService.startProcessInstanceByKey("catchSignal"); // test query by process instance id EventSubscription subscription = runtimeService.createEventSubscriptionQuery() .processInstanceId(processInstance.getId()) .singleResult(); assertNotNull(subscription); Execution executionWaitingForSignal = runtimeService.createExecutionQuery() .activityId("signalEvent") .processInstanceId(processInstance.getId()) .singleResult(); // test query by execution id EventSubscription signalSubscription = runtimeService.createEventSubscriptionQuery() .executionId(executionWaitingForSignal.getId()) .singleResult(); assertNotNull(signalSubscription); assertEquals(signalSubscription, subscription); try { runtimeService.createEventSubscriptionQuery().executionId(null).list(); fail("Expected ProcessEngineException"); } catch (ProcessEngineException e) { } cleanDb(); }
Example #30
Source File: EventSubscriptionRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
private List<EventSubscription> executePaginatedQuery(EventSubscriptionQuery query, Integer firstResult, Integer maxResults) { if (firstResult == null) { firstResult = 0; } if (maxResults == null) { maxResults = Integer.MAX_VALUE; } return query.listPage(firstResult, maxResults); }