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)); }
@Override protected void setUp() { BpmnModelInstance process = Bpmn.createExecutableProcess("testProcess") .startEvent() .message("start") .userTask() .endEvent() .done(); deployment(process); deploymentForTenant(TENANT_ONE, process); deploymentForTenant(TENANT_TWO, process); // the deployed process definition contains a message start event // - so a message event subscription is created on deployment. }
@Override public MigratingBpmnEventTrigger addEventSubProcess(ProcessEngine engine, BpmnModelInstance modelInstance, String parentId, String subProcessId, String startEventId) { ModifiableBpmnModelInstance.wrap(modelInstance) .addSubProcessTo(parentId) .id(subProcessId) .triggerByEvent() .embeddedSubProcess() .startEvent(startEventId).message(MESSAGE_NAME) .subProcessDone() .done(); MessageTrigger trigger = new MessageTrigger(); trigger.engine = engine; trigger.messageName = MESSAGE_NAME; trigger.activityId = startEventId; return trigger; }
@Test public void testStartMessageCorrelationWithTransientVariable() { // given BpmnModelInstance instance = Bpmn.createExecutableProcess("process") .startEvent() .message("message") .scriptTask("scriptTask") .scriptFormat("javascript") .camundaResultVariable("abc") .scriptText("execution.setVariable('abc', foo);") .endEvent() .done(); testRule.deploy(instance); // when runtimeService.createMessageCorrelation("message") .setVariable("foo", Variables.stringValue("bar", true)) .correlate(); // then List<VariableInstance> variableInstances = runtimeService.createVariableInstanceQuery().list(); assertEquals(0, variableInstances.size()); List<HistoricVariableInstance> historicInstances = historyService.createHistoricVariableInstanceQuery().list(); assertEquals(1, historicInstances.size()); assertEquals("abc", historicInstances.get(0).getName()); assertEquals("bar", historicInstances.get(0).getValue()); }
@Test public void testFailCorrelateMessageStartEventWithWrongProcessDefinitionId() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("a") .userTask() .endEvent() .done()); testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("b") .userTask() .endEvent() .done()); ProcessDefinition latestProcessDefinition = repositoryService.createProcessDefinitionQuery().latestVersion().singleResult(); try { runtimeService.createMessageCorrelation("a") .processDefinitionId(latestProcessDefinition.getId()) .correlateStartMessage(); fail("expected exception"); } catch (MismatchingMessageCorrelationException e){ testRule.assertTextPresent("Cannot correlate message 'a'", e.getMessage()); } }
.message("sophisticated message") .userTask() .endEvent()
@Test public void testMapProcessDefinitionWithEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.ONE_TASK_PROCESS) .addSubProcessTo(ProcessModels.PROCESS_KEY) .triggerByEvent() .embeddedSubProcess() .startEvent().message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = runtimeService .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); assertThat(migrationPlan) .hasSourceProcessDefinition(sourceProcessDefinition) .hasTargetProcessDefinition(targetProcessDefinition) .hasInstructions( migrate("userTask").to("userTask") ); }
@Test public void testCorrelateMessageStartEventWithProcessDefinitionId() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("a") .userTask() .endEvent() .done()); testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("b") .userTask() .endEvent() .done()); ProcessDefinition firstProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(1).singleResult(); ProcessDefinition secondProcessDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionVersion(2).singleResult(); runtimeService.createMessageCorrelation("a") .processDefinitionId(firstProcessDefinition.getId()) .processInstanceBusinessKey("first") .correlateStartMessage(); runtimeService.createMessageCorrelation("b") .processDefinitionId(secondProcessDefinition.getId()) .processInstanceBusinessKey("second") .correlateStartMessage(); assertEquals(1, runtimeService.createProcessInstanceQuery() .processInstanceBusinessKey("first").processDefinitionId(firstProcessDefinition.getId()).count()); assertEquals(1, runtimeService.createProcessInstanceQuery() .processInstanceBusinessKey("second").processDefinitionId(secondProcessDefinition.getId()).count()); }
@Test public void testMapActivityWithUnmappedParentWhichHasAEventSubProcessChild() { BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS) .addSubProcessTo("subProcess") .triggerByEvent() .embeddedSubProcess() .startEvent().message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = runtimeService .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); assertThat(migrationPlan) .hasSourceProcessDefinition(sourceProcessDefinition) .hasTargetProcessDefinition(targetProcessDefinition) .hasInstructions( migrate("userTask").to("userTask") ); }
@Test public void testMigrateProcessInstanceWithEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.ONE_TASK_PROCESS) .addSubProcessTo(ProcessModels.PROCESS_KEY) .id("eventSubProcess") .triggerByEvent() .embeddedSubProcess() .startEvent("eventSubProcessStart").message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); assertGeneratedMigrationPlan(testProcess, testProcess) .hasInstructions( migrate("eventSubProcess").to("eventSubProcess"), migrate("eventSubProcessStart").to("eventSubProcessStart"), migrate("userTask").to("userTask") ); assertGeneratedMigrationPlan(testProcess, ProcessModels.ONE_TASK_PROCESS) .hasInstructions( migrate("userTask").to("userTask") ); assertGeneratedMigrationPlan(ProcessModels.ONE_TASK_PROCESS, testProcess) .hasInstructions( migrate("userTask").to("userTask") ); }
@Test public void testMapUserTaskInEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS) .addSubProcessTo("subProcess") .triggerByEvent() .embeddedSubProcess() .startEvent().message(MESSAGE_NAME) .userTask("innerTask") .endEvent() .subProcessDone() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = runtimeService .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .mapActivities("innerTask", "innerTask") .build(); assertThat(migrationPlan) .hasSourceProcessDefinition(sourceProcessDefinition) .hasTargetProcessDefinition(targetProcessDefinition) .hasInstructions( migrate("userTask").to("userTask"), migrate("innerTask").to("innerTask") ); }
@Test public void testMigrateBoundaryEventAndEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS) .addSubProcessTo("subProcess") .triggerByEvent() .embeddedSubProcess() .startEvent("eventStart").message(MESSAGE_NAME) .endEvent() .subProcessDone() .moveToActivity(USER_TASK_ID) .boundaryEvent(BOUNDARY_ID).signal(SIGNAL_NAME) .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = rule.getRuntimeService() .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities(BOUNDARY_ID, BOUNDARY_ID) .mapActivities(USER_TASK_ID, USER_TASK_ID) .build(); // when testHelper.createProcessInstanceAndMigrate(migrationPlan); // then testHelper.assertEventSubscriptionRemoved("eventStart", MESSAGE_NAME); testHelper.assertEventSubscriptionMigrated(BOUNDARY_ID, BOUNDARY_ID, SIGNAL_NAME); testHelper.assertEventSubscriptionCreated("eventStart", MESSAGE_NAME); // and it is possible to successfully complete the migrated instance testHelper.completeTask(USER_TASK_ID); testHelper.assertProcessEnded(testHelper.snapshotBeforeMigration.getProcessInstanceId()); }
@Test public void testMigrateSubProcessWithEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS) .addSubProcessTo("subProcess") .id("eventSubProcess") .triggerByEvent() .embeddedSubProcess() .startEvent("eventSubProcessStart").message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); assertGeneratedMigrationPlan(testProcess, testProcess) .hasInstructions( migrate("eventSubProcess").to("eventSubProcess"), migrate("eventSubProcessStart").to("eventSubProcessStart"), migrate("subProcess").to("subProcess"), migrate("userTask").to("userTask") ); assertGeneratedMigrationPlan(testProcess, ProcessModels.SUBPROCESS_PROCESS) .hasInstructions( migrate("subProcess").to("subProcess"), migrate("userTask").to("userTask") ); assertGeneratedMigrationPlan(ProcessModels.SUBPROCESS_PROCESS, testProcess) .hasInstructions( migrate("subProcess").to("subProcess"), migrate("userTask").to("userTask") ); }
.triggerByEvent() .embeddedSubProcess() .startEvent("eventSubProcessStart").message(MESSAGE_NAME) .userTask("innerTask") .endEvent()
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)); }
@Override protected void setUp() { BpmnModelInstance process = Bpmn.createExecutableProcess("testProcess") .startEvent() .message("start") .userTask() .endEvent() .done(); deployment(process); deploymentForTenant(TENANT_ONE, process); deploymentForTenant(TENANT_TWO, process); // the deployed process definition contains a message start event // - so a message event subscription is created on deployment. }
@Override public MigratingBpmnEventTrigger addEventSubProcess(ProcessEngine engine, BpmnModelInstance modelInstance, String parentId, String subProcessId, String startEventId) { ModifiableBpmnModelInstance.wrap(modelInstance) .addSubProcessTo(parentId) .id(subProcessId) .triggerByEvent() .embeddedSubProcess() .startEvent(startEventId).message(MESSAGE_NAME) .subProcessDone() .done(); MessageTrigger trigger = new MessageTrigger(); trigger.engine = engine; trigger.messageName = MESSAGE_NAME; trigger.activityId = startEventId; return trigger; }
@Test public void testFailCorrelateMessageStartEventWithWrongProcessDefinitionId() { testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("a") .userTask() .endEvent() .done()); testRule.deploy(Bpmn.createExecutableProcess("process") .startEvent() .message("b") .userTask() .endEvent() .done()); ProcessDefinition latestProcessDefinition = repositoryService.createProcessDefinitionQuery().latestVersion().singleResult(); try { runtimeService.createMessageCorrelation("a") .processDefinitionId(latestProcessDefinition.getId()) .correlateStartMessage(); fail("expected exception"); } catch (MismatchingMessageCorrelationException e){ testRule.assertTextPresent("Cannot correlate message 'a'", e.getMessage()); } }
@Test public void testMapProcessDefinitionWithEventSubProcess() { BpmnModelInstance testProcess = modify(ProcessModels.ONE_TASK_PROCESS) .addSubProcessTo(ProcessModels.PROCESS_KEY) .triggerByEvent() .embeddedSubProcess() .startEvent().message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = runtimeService .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); assertThat(migrationPlan) .hasSourceProcessDefinition(sourceProcessDefinition) .hasTargetProcessDefinition(targetProcessDefinition) .hasInstructions( migrate("userTask").to("userTask") ); }
@Test public void testMapActivityWithUnmappedParentWhichHasAEventSubProcessChild() { BpmnModelInstance testProcess = modify(ProcessModels.SUBPROCESS_PROCESS) .addSubProcessTo("subProcess") .triggerByEvent() .embeddedSubProcess() .startEvent().message(MESSAGE_NAME) .endEvent() .subProcessDone() .done(); ProcessDefinition sourceProcessDefinition = testHelper.deployAndGetDefinition(testProcess); ProcessDefinition targetProcessDefinition = testHelper.deployAndGetDefinition(testProcess); MigrationPlan migrationPlan = runtimeService .createMigrationPlan(sourceProcessDefinition.getId(), targetProcessDefinition.getId()) .mapActivities("userTask", "userTask") .build(); assertThat(migrationPlan) .hasSourceProcessDefinition(sourceProcessDefinition) .hasTargetProcessDefinition(targetProcessDefinition) .hasInstructions( migrate("userTask").to("userTask") ); }