public Record<IncidentRecordValue> receiveFirstIncidentEvent(final IncidentIntent intent) { return receiveIncidents().withIntent(intent).getFirst(); }
public Record<IncidentRecordValue> receiveFirstIncidentEvent(final IncidentIntent intent) { return receiveIncidents().withIntent(intent).getFirst(); }
public Record<IncidentRecordValue> receiveFirstIncidentEvent( final long wfInstanceKey, final Intent intent) { return receiveIncidents().withIntent(intent).withWorkflowInstanceKey(wfInstanceKey).getFirst(); }
public Record<IncidentRecordValue> receiveFirstIncidentEvent( final long wfInstanceKey, final Intent intent) { return receiveIncidents().withIntent(intent).withWorkflowInstanceKey(wfInstanceKey).getFirst(); }
public Record<IncidentRecordValue> receiveFirstIncidentCommand(final IncidentIntent intent) { return receiveIncidents().withIntent(intent).onlyCommands().getFirst(); }
public Record<IncidentRecordValue> receiveFirstIncidentCommand(final IncidentIntent intent) { return receiveIncidents().withIntent(intent).onlyCommands().getFirst(); }
@Test public void shouldResolveIncidentIfCorrelationKeyNotFound() { // given final long workflowInstance = testClient.createWorkflowInstance(PROCESS_ID); final Record<IncidentRecordValue> incidentCreatedRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.updatePayload( incidentCreatedRecord.getValue().getElementInstanceKey(), "{\"orderId\":\"order123\"}"); // when testClient.resolveIncident(incidentCreatedRecord.getKey()); // then assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .exists()) .isTrue(); final Record<IncidentRecordValue> incidentResolvedEvent = testClient.receiveFirstIncidentEvent(workflowInstance, RESOLVED); assertThat(incidentResolvedEvent.getKey()).isEqualTo(incidentCreatedRecord.getKey()); } }
@Test public void shouldResolveIncidentIfCorrelationKeyNotFound() { // given final long workflowInstance = testClient.createWorkflowInstance(PROCESS_ID); final Record<IncidentRecordValue> incidentCreatedRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.updatePayload( incidentCreatedRecord.getValue().getElementInstanceKey(), "{\"orderId\":\"order123\"}"); // when testClient.resolveIncident(incidentCreatedRecord.getKey()); // then assertThat( RecordingExporter.workflowInstanceSubscriptionRecords( WorkflowInstanceSubscriptionIntent.OPENED) .exists()); final Record<IncidentRecordValue> incidentResolvedEvent = testClient.receiveFirstIncidentEvent(workflowInstance, RESOLVED); assertThat(incidentResolvedEvent.getKey()).isEqualTo(incidentCreatedRecord.getKey()); } }
@Test public void shouldCreateIncidentIfCorrelationKeyNotFound() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.EVENT_ACTIVATED) .withElementId("catch") .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage("Failed to extract the correlation-key by '$.orderId': no value found") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId("catch") .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfCorrelationKeyOfInvalidType() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, MsgPackUtil.asMsgPack("orderId", true)); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.EVENT_ACTIVATED) .withElementId("catch") .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage( "Failed to extract the correlation-key by '$.orderId': the value must be either a string or a number") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId("catch") .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfCorrelationKeyNotFound() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATING) .withElementId("catch") .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage("Failed to extract the correlation-key by '$.orderId': no value found") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId("catch") .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L) .hasVariableScopeKey(failureEvent.getKey()); }
@Test public void shouldCreateIncidentIfMessageCorrelationKeyNotFound() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, MsgPackUtil.asMsgPack("key-1", "k1")); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(failureEventIntent) .withElementId(elementId) .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage("Failed to extract the correlation-key by '$.key-2': no value found") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId(failureEvent.getValue().getElementId()) .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfMessageCorrelationKeyHasInvalidType() { // when final long workflowInstanceKey = testClient.createWorkflowInstance( PROCESS_ID, MsgPackUtil.asMsgPack("{'key-1':'k1', 'key-2':[1,2,3]}")); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(failureEventIntent) .withElementId(elementId) .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage( "Failed to extract the correlation-key by '$.key-2': the value must be either a string or a number") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId(failureEvent.getValue().getElementId()) .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfMessageCorrelationKeyHasInvalidType() { // when final long workflowInstanceKey = testClient.createWorkflowInstance( PROCESS_ID, MsgPackUtil.asMsgPack("{'key-1':'k1', 'key-2':[1,2,3]}")); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(failureEventIntent) .withElementId(elementId) .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage( "Failed to extract the correlation-key by '$.key-2': the value must be either a string or a number") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId(failureEvent.getValue().getElementId()) .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfMessageCorrelationKeyNotFound() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, MsgPackUtil.asMsgPack("key-1", "k1")); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(failureEventIntent) .withElementId(elementId) .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage("Failed to extract the correlation-key by '$.key-2': no value found") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId(failureEvent.getValue().getElementId()) .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L); }
@Test public void shouldCreateIncidentIfCorrelationKeyOfInvalidType() { // when final long workflowInstanceKey = testClient.createWorkflowInstance(PROCESS_ID, MsgPackUtil.asMsgPack("orderId", true)); final Record<WorkflowInstanceRecordValue> failureEvent = RecordingExporter.workflowInstanceRecords(WorkflowInstanceIntent.ELEMENT_ACTIVATING) .withElementId("catch") .getFirst(); // then final Record<IncidentRecordValue> incidentRecord = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); Assertions.assertThat(incidentRecord.getValue()) .hasErrorType(ErrorType.EXTRACT_VALUE_ERROR.name()) .hasErrorMessage( "Failed to extract the correlation-key by '$.orderId': the value must be either a string or a number") .hasBpmnProcessId(PROCESS_ID) .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId("catch") .hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L) .hasVariableScopeKey(failureEvent.getKey()); }
@Test public void shouldNotCompleteInstanceAfterIncidentIsRaisedOnActivity() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .endEvent("end-1") .moveToLastGateway() .serviceTask("task-2", t -> t.zeebeTaskType("task-2").zeebeOutput("$.result", "$.r")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-2"); final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task-1"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'result':'123'}"); testClient.resolveIncident(incident.getKey()); // then assertThatWorkflowInstanceCompletedAfter("end-2", WorkflowInstanceIntent.ELEMENT_COMPLETED); }
@Test public void shouldNotCompleteInstanceAfterIncidentIsRaisedOnActivity() { // given testClient.deploy( Bpmn.createExecutableProcess(PROCESS_ID) .startEvent() .parallelGateway() .serviceTask("task-1", t -> t.zeebeTaskType("task-1")) .endEvent("end-1") .moveToLastGateway() .serviceTask("task-2", t -> t.zeebeTaskType("task-2").zeebeOutput("$.result", "$.r")) .endEvent("end-2") .done()); testClient.createWorkflowInstance(PROCESS_ID); // when testClient.completeJobOfType("task-2"); final Record<IncidentRecordValue> incident = RecordingExporter.incidentRecords(IncidentIntent.CREATED).getFirst(); testClient.completeJobOfType("task-1"); testClient.updatePayload(incident.getValue().getElementInstanceKey(), "{'result':'123'}"); testClient.resolveIncident(incident.getKey()); // 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.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.EVENT_ACTIVATED); }