private ServiceTaskBuilder addServiceTask( final AbstractFlowNodeBuilder<?, ?> builder, YamlTask task) { final String id = task.getId(); final String taskType = task.getType(); final Integer taskRetries = task.getRetries(); final ServiceTaskBuilder serviceTaskBuilder = builder.serviceTask(id).zeebeTaskType(taskType).zeebeTaskRetries(taskRetries); for (Entry<String, String> header : task.getHeaders().entrySet()) { serviceTaskBuilder.zeebeTaskHeader(header.getKey(), header.getValue()); } addInputOutputMappingToTask(task, serviceTaskBuilder); return serviceTaskBuilder; }
private ServiceTaskBuilder addServiceTask( final AbstractFlowNodeBuilder<?, ?> builder, YamlTask task) { final String id = task.getId(); final String taskType = task.getType(); final Integer taskRetries = task.getRetries(); final ServiceTaskBuilder serviceTaskBuilder = builder.serviceTask(id).zeebeTaskType(taskType).zeebeTaskRetries(taskRetries); for (Entry<String, String> header : task.getHeaders().entrySet()) { serviceTaskBuilder.zeebeTaskHeader(header.getKey(), header.getValue()); } addInputOutputMappingToTask(task, serviceTaskBuilder); return serviceTaskBuilder; }
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 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); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
@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 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); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .timerWithDuration("PT0.01S") .endEvent() .done(); } },
@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."); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .endEvent() .done(); }
@Test public void shouldCreateJobWithWorkflowInstanceAndCustomHeaders() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask( "foo", t -> t.zeebeTaskType("bar").zeebeTaskHeader("a", "b").zeebeTaskHeader("c", "d")) .endEvent() .done()); // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // then final Record<JobRecordValue> event = testClient.receiveFirstJobCommand(JobIntent.CREATE); assertJobHeaders(workflowInstanceKey, "foo", event); final Map<String, Object> customHeaders = event.getValue().getCustomHeaders(); assertThat(customHeaders).containsEntry("a", "b").containsEntry("c", "d"); }
@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); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .serviceTask("task", b -> b.zeebeTaskType(taskType())) .boundaryEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .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.ELEMENT_COMPLETED); }
@Test public void shouldCreateVariableByOutputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .serviceTask("task", t -> t.zeebeTaskType("test").zeebeOutput("$.x", "$.y")) .endEvent() .done()); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("test", "{'x':1}"); // then final Record<VariableRecordValue> variableRecord = RecordingExporter.variableRecords(VariableIntent.CREATED).withName("y").getFirst(); Assertions.assertThat(variableRecord.getValue()) .hasScopeInstanceKey(workflowInstanceKey) .hasName("y") .hasValue("1"); }