@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .exclusiveGateway(elementId()) .defaultFlow() .endEvent() .done(); } },
@Override public ExclusiveGatewayBuilder builder() { return new ExclusiveGatewayBuilder((BpmnModelInstance) modelInstance, this); }
@Before public void init() { testClient = apiRule.partitionClient(); apiRule.waitForPartition(1); testClient.deploy( Bpmn.createExecutableProcess("workflow") .startEvent() .exclusiveGateway("xor") .sequenceFlowId("s1") .condition("$.foo < 5") .endEvent() .moveToLastGateway() .sequenceFlowId("s2") .condition("$.foo >= 5 && $.foo < 10") .endEvent() .done()); }
.startEvent() .exclusiveGateway("split") .sequenceFlowId("s1") .condition("$.foo < 5") .exclusiveGateway("joinRequest") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s2")
private void addFlowFromTask(final AbstractFlowNodeBuilder<?, ?> builder, final YamlTask task) { if (!task.getCases().isEmpty()) { final String gatewayId = "split-" + task.getId(); final ExclusiveGatewayBuilder gatewayBuilder = builder.exclusiveGateway(gatewayId); for (YamlCase flow : task.getCases()) { if (flow.getDefaultCase() != null) { gatewayBuilder.defaultFlow(); addTask(gatewayBuilder, flow.getDefaultCase()); } else { gatewayBuilder.condition(flow.getCondition()); addTask(gatewayBuilder, flow.getNext()); } } } else if (task.getNext() != null) { addTask(builder, task.getNext()); } else { final YamlTask nextTask = getNextTask(task); if (!task.isEnd() && nextTask != null) { addTask(builder, nextTask.getId()); } else { builder.endEvent(); } } }
@Test public void shouldEndScopeIfGatewayHasNoOutgoingFlows() { final BpmnModelInstance workflowDefinition = Bpmn.createExecutableProcess("workflow").startEvent().exclusiveGateway("xor").done(); testClient.deploy(workflowDefinition); // when testClient.createWorkflowInstance("workflow", MsgPackUtil.asMsgPack("foo", 10)); // then final List<Record<WorkflowInstanceRecordValue>> completedEvents = RecordingExporter.workflowInstanceRecords() .onlyEvents() .skipUntil(r -> r.getValue().getElementId().equals("xor")) .limitToWorkflowInstanceCompleted() .collect(Collectors.toList()); assertThat(completedEvents) .extracting(r -> r.getMetadata().getIntent()) .containsExactly( WorkflowInstanceIntent.GATEWAY_ACTIVATED, WorkflowInstanceIntent.ELEMENT_COMPLETING, WorkflowInstanceIntent.ELEMENT_COMPLETED); } }
@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)); }
.parallelGateway("fork") .exclusiveGateway("exclusiveJoin") .moveToLastGateway() .connectTo("exclusiveJoin") .sequenceFlowId("joinFlow1")
@Before public void init() { testClient = apiRule.partitionClient(); apiRule.waitForPartition(1); testClient.deploy( Bpmn.createExecutableProcess("workflow") .startEvent() .exclusiveGateway("xor") .sequenceFlowId("s1") .condition("$.foo < 5") .endEvent() .moveToLastGateway() .sequenceFlowId("s2") .condition("$.foo >= 5 && $.foo < 10") .endEvent() .done()); }
.startEvent() .exclusiveGateway("split") .sequenceFlowId("s1") .condition("$.foo < 5") .exclusiveGateway("joinRequest") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s2")
private void addFlowFromTask(final AbstractFlowNodeBuilder<?, ?> builder, final YamlTask task) { if (!task.getCases().isEmpty()) { final String gatewayId = "split-" + task.getId(); final ExclusiveGatewayBuilder gatewayBuilder = builder.exclusiveGateway(gatewayId); for (YamlCase flow : task.getCases()) { if (flow.getDefaultCase() != null) { gatewayBuilder.defaultFlow(); addTask(gatewayBuilder, flow.getDefaultCase()); } else { gatewayBuilder.condition(flow.getCondition()); addTask(gatewayBuilder, flow.getNext()); } } } else if (task.getNext() != null) { addTask(builder, task.getNext()); } else { final YamlTask nextTask = getNextTask(task); if (!task.isEnd() && nextTask != null) { addTask(builder, nextTask.getId()); } else { builder.endEvent(); } } }
@Test public void shouldEndScopeIfGatewayHasNoOutgoingFlows() { final BpmnModelInstance workflowDefinition = Bpmn.createExecutableProcess("workflow").startEvent().exclusiveGateway("xor").done(); testClient.deploy(workflowDefinition); // when testClient.createWorkflowInstance("workflow", MsgPackUtil.asMsgPack("foo", 10)); // then final List<Record<WorkflowInstanceRecordValue>> completedEvents = RecordingExporter.workflowInstanceRecords() .onlyEvents() .skipUntil(r -> r.getValue().getElementId().equals("xor")) .limitToWorkflowInstanceCompleted() .collect(Collectors.toList()); assertThat(completedEvents) .extracting(r -> r.getMetadata().getIntent()) .containsExactly( WorkflowInstanceIntent.ELEMENT_ACTIVATING, WorkflowInstanceIntent.ELEMENT_ACTIVATED, WorkflowInstanceIntent.ELEMENT_COMPLETING, WorkflowInstanceIntent.ELEMENT_COMPLETED, WorkflowInstanceIntent.ELEMENT_COMPLETING, WorkflowInstanceIntent.ELEMENT_COMPLETED); } }
@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.ELEMENT_COMPLETED), tuple("end", WorkflowInstanceIntent.ELEMENT_COMPLETED), tuple(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_COMPLETED)); }
.parallelGateway("fork") .exclusiveGateway("exclusiveJoin") .moveToLastGateway() .connectTo("exclusiveJoin") .sequenceFlowId("joinFlow1")
.startEvent() .exclusiveGateway("xor") .sequenceFlowId("s1") .condition("$.foo < 5") .endEvent("a") .moveToLastExclusiveGateway() .defaultFlow()
.startEvent() .exclusiveGateway("split") .sequenceFlowId("s1") .condition("$.foo < 5") .exclusiveGateway("joinRequest") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s2")
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .exclusiveGateway(elementId()) .defaultFlow() .endEvent() .done(); } },
@Override public ExclusiveGatewayBuilder builder() { return new ExclusiveGatewayBuilder((BpmnModelInstance) modelInstance, this); }
.startEvent() .exclusiveGateway("xor") .sequenceFlowId("s1") .condition("$.foo < 5") .endEvent("a") .moveToLastExclusiveGateway() .defaultFlow()
.startEvent() .exclusiveGateway("split") .sequenceFlowId("s1") .condition("$.foo < 5") .exclusiveGateway("joinRequest") .moveToLastExclusiveGateway() .defaultFlow() .sequenceFlowId("s2")