@Override public ParallelGatewayBuilder builder() { return new ParallelGatewayBuilder((BpmnModelInstance) modelInstance, this); }
.startEvent() .parallelGateway("fork") .sequenceFlowId("flowToJoin") .parallelGateway("join") // process should deadlock here .endEvent() .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type"))
@Test public void shouldCompleteInstanceAfterTimerIntermediateCatchEvent() { // given brokerRule.getClock().pinCurrentTime(); testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent("catch", e -> e.timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task"); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldCompleteInstanceAfterParallelJoin() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway("fork") .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .parallelGateway("join") .endEvent("end") .moveToNode("fork") .serviceTask("task-2", t -> t.zeebeTaskType("task-2")) .connectTo("join") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-1"); testClient.completeJobOfType("task-2"); // then assertThatWorkflowInstanceCompletedAfter("end", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldMergeAndSplitInOneGateway() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway("fork") .parallelGateway("join-fork") .moveToNode("fork") .connectTo("join-fork") .serviceTask("task1", b -> b.zeebeTaskType("type1")) .moveToLastGateway() .serviceTask("task2", b -> b.zeebeTaskType("type2")) .done(); testClient.deploy(process); // when testClient.createWorkflowInstance(PROCESS_ID); // then final List<Record<WorkflowInstanceRecordValue>> elementInstances = testClient .receiveWorkflowInstances() .filter(r -> r.getMetadata().getIntent() == WorkflowInstanceIntent.ELEMENT_ACTIVATED) .limit(3) .collect(Collectors.toList()); assertThat(elementInstances) .extracting(e -> e.getValue().getElementId()) .contains(PROCESS_ID, "task1", "task2"); }
@Test public void shouldPassThroughParallelGateway() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent("start") .sequenceFlowId("flow1") .parallelGateway("fork") .sequenceFlowId("flow2") .endEvent("end") .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()) .containsSequence( tuple("fork", WorkflowInstanceIntent.GATEWAY_ACTIVATED), tuple("flow2", WorkflowInstanceIntent.SEQUENCE_FLOW_TAKEN), tuple("end", WorkflowInstanceIntent.EVENT_ACTIVATING), tuple("end", WorkflowInstanceIntent.EVENT_ACTIVATED), tuple(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETING)); }
.startEvent() .parallelGateway("fork") .exclusiveGateway("exclusiveJoin") .moveToLastGateway() .connectTo("exclusiveJoin") .sequenceFlowId("joinFlow1") .parallelGateway("join") .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type")) .sequenceFlowId("joinFlow2")
@Test public void shouldCancelTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .intermediateCatchEvent("timer1", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<TimerRecordValue> canceledEvent = RecordingExporter.timerRecords(TimerIntent.CANCELED).getFirst(); assertThat(canceledEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(canceledEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(canceledEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .parallelGateway(elementId()) .endEvent() .done(); } },
@Test public void shouldCompleteScopeOnParallelGateway() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent("start") .sequenceFlowId("flow1") .parallelGateway("fork") .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()) .containsSequence( tuple("fork", WorkflowInstanceIntent.ELEMENT_COMPLETED), tuple(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETING)); }
@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)); }
.startEvent() .parallelGateway("fork") .sequenceFlowId("flowToJoin") .parallelGateway("join") // process should deadlock here .endEvent() .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type"))
@Test public void shouldCompleteInstanceAfterTimerIntermediateCatchEvent() { // given brokerRule.getClock().pinCurrentTime(); testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent("catch", e -> e.timerWithDuration("PT0.1S")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task"); brokerRule.getClock().addTime(Duration.ofSeconds(1)); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldCompleteInstanceAfterParallelJoin() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway("fork") .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .parallelGateway("join") .endEvent("end") .moveToNode("fork") .serviceTask("task-2", t -> t.zeebeTaskType("task-2")) .connectTo("join") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-1"); testClient.completeJobOfType("task-2"); // then assertThatWorkflowInstanceCompletedAfter("end", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
.startEvent("start") .parallelGateway("fork") .parallelGateway("join-fork") .moveToNode("fork") .connectTo("join-fork") .serviceTask("task1", b -> b.zeebeTaskType("type1"))
.sequenceFlowId("flow1") .parallelGateway("fork") .sequenceFlowId("flow2") .endEvent("end") .done();
.startEvent() .parallelGateway("fork") .exclusiveGateway("exclusiveJoin") .moveToLastGateway() .connectTo("exclusiveJoin") .sequenceFlowId("joinFlow1") .parallelGateway("join") .moveToNode("fork") .serviceTask("waitState", b -> b.zeebeTaskType("type")) .sequenceFlowId("joinFlow2")
@Test public void shouldCancelTimer() { // given final BpmnModelInstance workflow = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .intermediateCatchEvent("timer1", c -> c.timerWithDuration("PT10S")) .endEvent() .done(); testClient.deploy(workflow); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when final Record<TimerRecordValue> createdEvent = RecordingExporter.timerRecords(TimerIntent.CREATED).getFirst(); testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<TimerRecordValue> canceledEvent = RecordingExporter.timerRecords(TimerIntent.CANCELED).getFirst(); assertThat(canceledEvent.getKey()).isEqualTo(createdEvent.getKey()); assertThat(canceledEvent.getValue()).isEqualTo(createdEvent.getValue()); assertThat(canceledEvent.getValue().getDueDate()) .isGreaterThan(brokerRule.getClock().getCurrentTimeInMillis()); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .parallelGateway(elementId()) .endEvent() .done(); } },
@Test public void shouldCompleteScopeOnParallelGateway() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent("start") .sequenceFlowId("flow1") .parallelGateway("fork") .done(); testClient.deploy(process); // when testClient.createWorkflowInstance(PROCESS_ID); // then final Record<WorkflowInstanceRecordValue> completedEvent = testClient.receiveElementInState(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETED); final List<Record<WorkflowInstanceRecordValue>> workflowInstanceEvents = testClient .receiveWorkflowInstances() .limit(r -> r.getPosition() == completedEvent.getPosition()) .collect(Collectors.toList()); assertThat(workflowInstanceEvents) .extracting(e -> e.getValue().getElementId(), e -> e.getMetadata().getIntent()) .containsSequence( tuple("fork", WorkflowInstanceIntent.GATEWAY_ACTIVATED), tuple(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETING)); }