@Override public BoundaryEventBuilder builder() { return new BoundaryEventBuilder((BpmnModelInstance) modelInstance, this); }
@Test public void shouldCompleteInstanceAfterInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToActivity("task") .boundaryEvent("timeout", b -> b.cancelActivity(true).timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldUseScopePayloadWhenApplyingOutputMappings() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", b -> b.zeebeTaskType("type").zeebeInput("$.oof", "$.baz")) .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID, "{\"foo\": 1, \"oof\": 2}"); // when testClient.receiveTimerRecord("timer", TimerIntent.CREATED); brokerRule.getClock().addTime(Duration.ofMinutes(1)); awaitProcessCompleted(); // then final Record<WorkflowInstanceRecordValue> boundaryTriggered = testClient.receiveElementInState("timer", WorkflowInstanceIntent.EVENT_TRIGGERED); assertThat(boundaryTriggered.getValue().getPayloadAsMap()) .contains(entry("foo", 1), entry("oof", 2)); }
.serviceTask("task", b -> b.zeebeTaskType("type")) .boundaryEvent("event") .message(m -> m.name("message").zeebeCorrelationKey("$.key")) .zeebeOutput("$.foo", "$.bar") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent()
@Test public void shouldCompleteInstanceAfterNonInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .endEvent("end-1") .moveToActivity("task-1") .boundaryEvent("timeout", b -> b.cancelActivity(false).timerWithCycle("R1/PT0.1S")) .serviceTask("task-2", t -> t.zeebeTaskType("task-2")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-2"); testClient.completeJobOfType("task-1"); // then assertThatWorkflowInstanceCompletedAfter("end-1", WorkflowInstanceIntent.EVENT_ACTIVATED); assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
.serviceTask("task", b -> b.zeebeTaskType("type")) .boundaryEvent("msg1") .cancelActivity(false) .message(m -> m.name("msg1").zeebeCorrelationKey("$.key")) .endEvent("msg1End") .moveToActivity("task") .endEvent("taskEnd")
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
@Test public void shouldCompleteInstanceAfterInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToActivity("task") .boundaryEvent("timeout", b -> b.cancelActivity(true).timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldUseScopePayloadWhenApplyingOutputMappings() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", b -> b.zeebeTaskType("type").zeebeInput("$.oof", "$.baz")) .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID, "{\"foo\": 1, \"oof\": 2}"); // when testClient.receiveTimerRecord("timer", TimerIntent.CREATED); brokerRule.getClock().addTime(Duration.ofMinutes(1)); awaitProcessCompleted(); // then final Record<WorkflowInstanceRecordValue> boundaryTriggered = testClient.receiveElementInState("timer", WorkflowInstanceIntent.ELEMENT_COMPLETED); assertThat(boundaryTriggered.getValue().getPayloadAsMap()) .contains(entry("foo", 1), entry("oof", 2)); }
.serviceTask("task", b -> b.zeebeTaskType("type")) .boundaryEvent("event") .message(m -> m.name("message").zeebeCorrelationKey("$.key")) .zeebeOutput("$.foo", "$.bar") .zeebeOutputBehavior(ZeebeOutputBehavior.merge) .endEvent("endTimer") .moveToActivity("task") .endEvent()
@Test public void shouldCompleteInstanceAfterNonInterruptingBoundaryEventTriggered() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .endEvent("end-1") .moveToActivity("task-1") .boundaryEvent("timeout", b -> b.cancelActivity(false).timerWithCycle("R1/PT0.1S")) .serviceTask("task-2", t -> t.zeebeTaskType("task-2")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-2"); testClient.completeJobOfType("task-1"); // then assertThatWorkflowInstanceCompletedAfter("end-1", WorkflowInstanceIntent.ELEMENT_COMPLETED); assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
.serviceTask("task", b -> b.zeebeTaskType("type")) .boundaryEvent("msg1") .cancelActivity(false) .message(m -> m.name("msg1").zeebeCorrelationKey("$.key")) .endEvent("msg1End") .moveToActivity("task") .endEvent("taskEnd")
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
.subProcessDone() .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent()
@Test public void shouldUseScopeToExtractCorrelationKeys() { // given final String processId = "shouldHaveScopeKeyIfBoundaryEvent"; final BpmnModelInstance workflow = Bpmn.createExecutableProcess(processId) .startEvent() .serviceTask("task", c -> c.zeebeTaskType("type").zeebeInput("$.bar", "$.foo")) .boundaryEvent( "event", b -> b.message(m -> m.zeebeCorrelationKey("$.foo").name("message"))) .endEvent() .moveToActivity("task") .endEvent() .done(); testClient.deploy(workflow); // when testClient.createWorkflowInstance( processId, MsgPackUtil.asMsgPack(m -> m.put("foo", 1).put("bar", 2))); testClient.publishMessage("message", "1"); // then // if correlation key was extracted from the task, then foo in the task scope would be 2 and // no event occurred would be published assertThat(testClient.receiveElementInState("task", WorkflowInstanceIntent.EVENT_OCCURRED)) .isNotNull(); }
.serviceTask("task", b -> b.zeebeTaskType("type")) .boundaryEvent("timer1") .timerWithDuration("PT1S") .endEvent("timer1End") .moveToActivity("task") .boundaryEvent("timer2") .timerWithDuration("PT2S") .endEvent("timer2End") .done();
@Override public BoundaryEventBuilder builder() { return new BoundaryEventBuilder((BpmnModelInstance) modelInstance, this); }
.subProcessDone() .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent()