@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .intermediateCatchEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .done(); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .intermediateCatchEvent(elementId()) .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .done(); }
@Test public void shouldCancelIntermediateCatchEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .intermediateCatchEvent("catch-event") .message(b -> b.name("msg").zeebeCorrelationKey("$.id")) .done()); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("id", "123")); testClient.receiveElementInState("catch-event", WorkflowInstanceIntent.EVENT_ACTIVATED); final ExecuteCommandResponse response = cancelWorkflowInstance(workflowInstanceKey); // then assertThat(response.getIntent()).isEqualTo(WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record<WorkflowInstanceRecordValue> terminatedEvent = testClient.receiveElementInState(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_TERMINATED); assertWorkflowInstanceRecord(workflowInstanceKey, PROCESS_ID, terminatedEvent); }
@Test public void shouldCancelIntermediateCatchEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .intermediateCatchEvent("catch-event") .message(b -> b.name("msg").zeebeCorrelationKey("$.id")) .done()); final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, asMsgPack("id", "123")); testClient.receiveElementInState("catch-event", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final ExecuteCommandResponse response = cancelWorkflowInstance(workflowInstanceKey); // then assertThat(response.getIntent()).isEqualTo(WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record<WorkflowInstanceRecordValue> terminatedEvent = testClient.receiveElementInState(PROCESS_ID, WorkflowInstanceIntent.ELEMENT_TERMINATED); assertWorkflowInstanceRecord(workflowInstanceKey, PROCESS_ID, terminatedEvent); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .eventBasedGateway(elementId()) .intermediateCatchEvent() .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .moveToLastGateway() .intermediateCatchEvent() .timerWithDuration("PT0.01S") .done(); }
@Override BpmnModelInstance modelInstance() { return Bpmn.createExecutableProcess(processId()) .startEvent() .eventBasedGateway(elementId()) .intermediateCatchEvent() .message(b -> b.name(messageName()).zeebeCorrelationKey("$.id")) .moveToLastGateway() .intermediateCatchEvent() .timerWithDuration("PT0.01S") .done(); }
@Test public void shouldCompleteInstanceAfterEventBasedGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .eventBasedGateway("gateway") .intermediateCatchEvent( "catch-1", e -> e.message(m -> m.name("msg-1").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .moveToNode("gateway") .intermediateCatchEvent( "catch-2", e -> e.message(m -> m.name("msg-2").zeebeCorrelationKey("$.key"))) .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg-1", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldCompleteInstanceAfterEventBasedGateway() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .eventBasedGateway("gateway") .intermediateCatchEvent( "catch-1", e -> e.message(m -> m.name("msg-1").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .moveToNode("gateway") .intermediateCatchEvent( "catch-2", e -> e.message(m -> m.name("msg-2").zeebeCorrelationKey("$.key"))) .endEvent("end-3") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg-1", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
"catch-event", b -> { b.message(m -> m.name("msg").zeebeCorrelationKey("$.key"));
"catch-event", b -> { b.message(m -> m.name("msg").zeebeCorrelationKey("$.key"));
@Test public void shouldCompleteInstanceAfterMessageIntermediateCatchEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent( "catch", e -> e.message(m -> m.name("msg").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldCompleteInstanceAfterMessageIntermediateCatchEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent( "catch", e -> e.message(m -> m.name("msg").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID, "{'key':'123'}"); // when testClient.completeJobOfType("task"); testClient.publishMessage("msg", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldUpdatePayloadWhenCatchEventIsEntered() { // given testClient.deploy( Bpmn.createExecutableProcess("wf") .startEvent() .intermediateCatchEvent("catch-event") .message(b -> b.name("msg").zeebeCorrelationKey("$.id")) .done()); testClient.createWorkflowInstance("wf", asMsgPack("id", "123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.ELEMENT_ACTIVATED); // when updatePayload( catchEventEntered.getKey(), MsgPackUtil.asMsgPackReturnArray("{'id':'123', 'x': 1}")); testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.PAYLOAD_UPDATED); testClient.publishMessage("msg", "123", asMsgPack("y", 2)); // then final Record<WorkflowInstanceRecordValue> catchEventOccurred = testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.ELEMENT_COMPLETED); assertWorkflowInstancePayload(catchEventOccurred, "{'id':'123', 'x': 1, 'y': 2}"); }
@Test public void shouldUpdatePayloadWhenCatchEventIsEntered() { // given testClient.deploy( Bpmn.createExecutableProcess("wf") .startEvent() .intermediateCatchEvent("catch-event") .message(b -> b.name("msg").zeebeCorrelationKey("$.id")) .done()); testClient.createWorkflowInstance("wf", asMsgPack("id", "123")); final Record<WorkflowInstanceRecordValue> catchEventEntered = testClient.receiveFirstWorkflowInstanceEvent( WorkflowInstanceIntent.ELEMENT_ACTIVATED, BpmnElementType.INTERMEDIATE_CATCH_EVENT); // when updatePayload( catchEventEntered.getKey(), MsgPackUtil.asMsgPackReturnArray("{'id':'123', 'x': 1}")); testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.PAYLOAD_UPDATED); testClient.publishMessage("msg", "123", asMsgPack("y", 2)); // then final Record<WorkflowInstanceRecordValue> catchEventOccurred = testClient.receiveFirstWorkflowInstanceEvent( WorkflowInstanceIntent.ELEMENT_COMPLETED, BpmnElementType.INTERMEDIATE_CATCH_EVENT); assertWorkflowInstancePayload(catchEventOccurred, "{'id':'123', 'x': 1, 'y': 2}"); }
.startEvent() .intermediateCatchEvent("catch") .message(b -> b.name("message").zeebeCorrelationKey("foo")) .endEvent() .done(),
.startEvent() .intermediateCatchEvent("catch") .message(b -> b.name("message").zeebeCorrelationKey("foo")) .endEvent() .done(),
@Test public void shouldNotCompleteInstanceAfterIncidentIsRaisedOnEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent( "catch", e -> e.message(m -> m.name("msg").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'key':'123'}"); testClient.resolveIncident(incident.getKey()); testClient.publishMessage("msg", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.EVENT_ACTIVATED); }
@Test public void shouldNotCompleteInstanceAfterIncidentIsRaisedOnEvent() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task", t -> t.zeebeTaskType("task")) .endEvent("end-1") .moveToLastGateway() .intermediateCatchEvent( "catch", e -> e.message(m -> m.name("msg").zeebeCorrelationKey("$.key"))) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'key':'123'}"); testClient.resolveIncident(incident.getKey()); testClient.publishMessage("msg", "123"); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }