@Override public EndEventBuilder builder() { return new EndEventBuilder((BpmnModelInstance) modelInstance, this); } }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .eventBasedGateway() .intermediateCatchEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .moveToLastGateway() .intermediateCatchEvent() .timerWithDuration("PT1H") .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.EVENT_ACTIVATED); }
@Test public void shouldCreateDeploymentWithMessageStartEvent() throws IOException { // given final ProcessBuilder processBuilder = Bpmn.createExecutableProcess(); final BpmnModelInstance process = processBuilder.startEvent().message(m -> m.name("startMessage")).endEvent().done(); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(process); // then assertThat(resp.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATED); }
@Test public void shouldCompleteInstanceAfterEventBasedGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .eventBasedGateway("gateway") .intermediateCatchEvent( "catch-1", e -> e.message(m -> m.name("msg-1").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .moveToNode("gateway") .intermediateCatchEvent( "catch-2", e -> e.message(m -> m.name("msg-2").zeebeCorrelationKey("$.key"))) .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg-1", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
.condition("$.foo < 5") .endEvent("a") .moveToLastGateway() .sequenceFlowId("s2") .condition("$.foo >= 5 && $.foo < 10") .endEvent("b") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s3") .endEvent("c") .done();
.serviceTask("task", t -> t.zeebeTaskType("type")) .endEvent() .subProcessDone() .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID);
@Test public void shouldSplitIfDefaultFlowIsDeclaredFirst() { final BpmnModelInstance workflowDefinition = Bpmn.createExecutableProcess("workflow") .startEvent() .exclusiveGateway() .defaultFlow() .endEvent("a") .moveToLastExclusiveGateway() .condition("$.foo < 5") .endEvent("b") .done(); testClient.deploy(workflowDefinition); // when testClient.createWorkflowInstance("workflow", MsgPackUtil.asMsgPack("foo", 10)); // then final List<Record<WorkflowInstanceRecordValue>> completedEvents = RecordingExporter.workflowInstanceRecords() .limitToWorkflowInstanceCompleted() .withIntent(WorkflowInstanceIntent.EVENT_ACTIVATED) .collect(Collectors.toList()); assertThat(completedEvents).extracting(r -> r.getValue().getElementId()).containsExactly("a"); }
@Test public void shouldRunServiceTaskAfterEmbeddedSubProcess() { // given final BpmnModelInstance model = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .subProcess() .embeddedSubProcess() .startEvent() .endEvent() .subProcessDone() .serviceTask("task", b -> b.zeebeTaskType("type")) .endEvent() .done(); testClient.deploy(model); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<JobRecordValue> jobCreatedEvent = testClient.receiveFirstJobEvent(JobIntent.CREATED); final Headers headers = jobCreatedEvent.getValue().getHeaders(); Assertions.assertThat(headers).hasElementId("task"); }
.parallelGateway("join") // process should deadlock here .endEvent() .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type")) .sequenceFlowId("flowToEnd") .endEvent() .done();
@Test public void shouldCompleteScopeWithMultipleTokensOnSamePath() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway("fork") .exclusiveGateway("join") .endEvent("end") .moveToNode("fork") .connectTo("join") .done(); testClient.deploy(process); // when testClient.createWorkflowInstance(PROCESS_ID); // then final List<Record<WorkflowInstanceRecordValue>> workflowInstanceEvents = testClient .receiveWorkflowInstances() .limitToWorkflowInstanceCompleted() .collect(Collectors.toList()); assertThat(workflowInstanceEvents) .extracting(e -> e.getValue().getElementId(), e -> e.getMetadata().getIntent()) .containsSubsequence( tuple("end", WorkflowInstanceIntent.EVENT_ACTIVATED), tuple("end", WorkflowInstanceIntent.EVENT_ACTIVATED), tuple(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETED)); }
.serviceTask("task1", b -> b.zeebeTaskType("type1").zeebeTaskHeader("key", testValue)) .endEvent("end") .moveToActivity("task1") .serviceTask("task2", b -> b.zeebeTaskType("type2").zeebeTaskHeader(testValue, "value")) .connectTo("end")
@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 shouldCreateDeploymentWithMessageStartEvent() throws IOException { // given final ProcessBuilder processBuilder = Bpmn.createExecutableProcess(); final BpmnModelInstance process = processBuilder.startEvent().message(m -> m.name("startMessage")).endEvent().done(); // when final ExecuteCommandResponse resp = apiRule.partitionClient().deployWithResponse(process); // then assertThat(resp.getRecordType()).isEqualTo(RecordType.EVENT); assertThat(resp.getIntent()).isEqualTo(DeploymentIntent.CREATED); }
@Test public void shouldCompleteInstanceAfterEventBasedGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .eventBasedGateway("gateway") .intermediateCatchEvent( "catch-1", e -> e.message(m -> m.name("msg-1").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .moveToNode("gateway") .intermediateCatchEvent( "catch-2", e -> e.message(m -> m.name("msg-2").zeebeCorrelationKey("$.key"))) .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg-1", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
.condition("$.foo < 5") .endEvent("a") .moveToLastGateway() .sequenceFlowId("s2") .condition("$.foo >= 5 && $.foo < 10") .endEvent("b") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s3") .endEvent("c") .done();
.serviceTask("task", t -> t.zeebeTaskType("type")) .endEvent() .subProcessDone() .boundaryEvent("timer") .cancelActivity(true) .timerWithDuration("PT1S") .endEvent("endTimer") .moveToActivity("sub") .endEvent() .done(); testClient.deploy(workflow); testClient.createWorkflowInstance(PROCESS_ID);
@Test public void shouldSplitIfDefaultFlowIsDeclaredFirst() { final BpmnModelInstance workflowDefinition = Bpmn.createExecutableProcess("workflow") .startEvent() .exclusiveGateway() .defaultFlow() .endEvent("a") .moveToLastExclusiveGateway() .condition("$.foo < 5") .endEvent("b") .done(); testClient.deploy(workflowDefinition); // when testClient.createWorkflowInstance("workflow", MsgPackUtil.asMsgPack("foo", 10)); // then final List<Record<WorkflowInstanceRecordValue>> completedEvents = RecordingExporter.workflowInstanceRecords() .limitToWorkflowInstanceCompleted() .withIntent(WorkflowInstanceIntent.ELEMENT_COMPLETED) .withElementType(BpmnElementType.END_EVENT) .collect(Collectors.toList()); assertThat(completedEvents).extracting(r -> r.getValue().getElementId()).containsExactly("a"); }
@Test public void shouldRunServiceTaskAfterEmbeddedSubProcess() { // given final BpmnModelInstance model = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .subProcess() .embeddedSubProcess() .startEvent() .endEvent() .subProcessDone() .serviceTask("task", b -> b.zeebeTaskType("type")) .endEvent() .done(); testClient.deploy(model); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<JobRecordValue> jobCreatedEvent = testClient.receiveFirstJobEvent(JobIntent.CREATED); final Headers headers = jobCreatedEvent.getValue().getHeaders(); Assertions.assertThat(headers).hasElementId("task"); }
.parallelGateway("join") // process should deadlock here .endEvent() .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type")) .sequenceFlowId("flowToEnd") .endEvent() .done();