@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .exclusiveGateway(elementId()) .defaultFlow() .endEvent() .done(); } },
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .exclusiveGateway(elementId()) .defaultFlow() .endEvent() .done(); } },
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(); } } }
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 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 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 shouldNotCompleteInstanceAfterIncidentIsRaisedOnExclusiveGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .exclusiveGateway("gateway") .defaultFlow() .endEvent("end-2") .moveToNode("gateway") .sequenceFlowId("to-end-3") .condition("$.x < 21") .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'x':123}"); testClient.resolveIncident(incident.getKey()); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldNotCompleteInstanceAfterIncidentIsRaisedOnExclusiveGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .exclusiveGateway("gateway") .defaultFlow() .endEvent("end-2") .moveToNode("gateway") .sequenceFlowId("to-end-3") .condition("$.x < 21") .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'x':123}"); testClient.resolveIncident(incident.getKey()); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }