public long createJob(final String type, Consumer<ServiceTaskBuilder> consumer, String payload) { deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "task", b -> { b.zeebeTaskType(type).zeebeTaskRetries(3); consumer.accept(b); }) .done()); final long workflowInstance = createWorkflowInstance("process", payload); return RecordingExporter.jobRecords(JobIntent.CREATED) .withType(type) .filter(j -> j.getValue().getHeaders().getWorkflowInstanceKey() == workflowInstance) .getFirst() .getKey(); }
public long createJob(final String type, Consumer<ServiceTaskBuilder> consumer, String payload) { deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "task", b -> { b.zeebeTaskType(type).zeebeTaskRetries(3); consumer.accept(b); }) .done()); final long workflowInstance = createWorkflowInstance("process", payload); return RecordingExporter.jobRecords(JobIntent.CREATED) .withType(type) .filter(j -> j.getValue().getHeaders().getWorkflowInstanceKey() == workflowInstance) .getFirst() .getKey(); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask(elementId(), b -> b.zeebeTaskType(taskType())) .done(); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask(elementId(), b -> b.zeebeTaskType(taskType())) .done(); }
@Test public void shouldSplitWithUncontrolledFlow() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent("start") .serviceTask("task1", b -> b.zeebeTaskType("type1")) .moveToNode("start") .serviceTask("task2", b -> b.zeebeTaskType("type2")) .done(); testClient.deploy(process); // when testClient.createWorkflowInstance(PROCESS_ID); // then final List<Record<WorkflowInstanceRecordValue>> taskEvents = testClient .receiveWorkflowInstances() .withIntent(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .filter(e -> isServiceTaskInProcess(e.getValue().getElementId(), process)) .limit(2) .collect(Collectors.toList()); assertThat(taskEvents).hasSize(2); assertThat(taskEvents) .extracting(e -> e.getValue().getElementId()) .containsExactlyInAnyOrder("task1", "task2"); assertThat(taskEvents.get(0).getKey()).isNotEqualTo(taskEvents.get(1).getKey()); }
@Test public void shouldCompleteInstanceAfterActivityWithoutOutgoingSequenceFlows() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task"); // then assertThatWorkflowInstanceCompletedAfter("task", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldCreateIncidentForInvalidResultOnInputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external").zeebeInput("$.string", "$")) .done()); // when testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // then incident is created final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent); }
@Test public void shouldSplitWithUncontrolledFlow() { // given final BpmnModelInstance process = Bpmn.createExecutableProcess(PROCESS_ID) .startEvent("start") .serviceTask("task1", b -> b.zeebeTaskType("type1")) .moveToNode("start") .serviceTask("task2", b -> b.zeebeTaskType("type2")) .done(); testClient.deploy(process); // when testClient.createWorkflowInstance(PROCESS_ID); // then final List<Record<WorkflowInstanceRecordValue>> taskEvents = testClient .receiveWorkflowInstances() .withIntent(WorkflowInstanceIntent.ELEMENT_ACTIVATED) .filter(e -> isServiceTaskInProcess(e.getValue().getElementId(), process)) .limit(2) .collect(Collectors.toList()); assertThat(taskEvents).hasSize(2); assertThat(taskEvents) .extracting(e -> e.getValue().getElementId()) .containsExactlyInAnyOrder("task1", "task2"); assertThat(taskEvents.get(0).getKey()).isNotEqualTo(taskEvents.get(1).getKey()); }
@Test public void shouldCompleteInstanceAfterActivityWithoutOutgoingSequenceFlows() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("task")) .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task"); // then assertThatWorkflowInstanceCompletedAfter("task", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldCreateIncidentForInvalidResultOnInputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external").zeebeInput("$.string", "$")) .done()); // when testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // then incident is created final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent); }
@Test public void shouldCreateIncidentForOutputMappingAndNoTaskCompletePayload() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external").zeebeOutput("$.testAttr", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType("external"); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent, "No data found for query $.testAttr."); }
@Test public void shouldCreateIncidentForOutputMappingAndNoTaskCompletePayload() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external").zeebeOutput("$.testAttr", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType("external"); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent, "No data found for query $.testAttr."); }
@Test public void shouldCreateIncidentForInAndOutputMappingAndNoTaskCompletePayload() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external") .zeebeInput("$.jsonObject", "$") .zeebeOutput("$.foo", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType("external"); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent, "No data found for query $.foo."); }
@Test public void shouldCreateIncidentForInAndOutputMappingAndNoTaskCompletePayload() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external") .zeebeInput("$.jsonObject", "$") .zeebeOutput("$.foo", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType("external"); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent, "No data found for query $.foo."); }
@Test public void shouldCreateIncidentForInvalidResultOnOutputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external") .zeebeInput("$.jsonObject", "$") .zeebeOutput("$.testAttr", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType( "external", MsgPackUtil.asMsgPackReturnArray("{'testAttr':'test'}")); testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.ELEMENT_ACTIVATED); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent); }
@Test public void shouldCreateIncidentForInvalidResultOnOutputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "failingTask", t -> t.zeebeTaskType("external") .zeebeInput("$.jsonObject", "$") .zeebeOutput("$.testAttr", "$")) .done()); testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); // when testClient.completeJobOfType( "external", MsgPackUtil.asMsgPackReturnArray("{'testAttr':'test'}")); testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.ELEMENT_ACTIVATED); // then incident is created final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentContainErrorDetails(incidentEvent); }
.startEvent() .serviceTask("service", t -> t.zeebeTaskType("external").zeebeOutput("$.testAttr", "$")) .done());
.zeebeInput("$.jsonObject", "$") .zeebeOutput("$.foo", "$")) .done());
@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"); }
.moveToLastGateway() .serviceTask("task2", b -> b.zeebeTaskType("type2")) .done();