public static void assertIncidentRecordValue( String errorType, String errorMsg, long workflowInstanceKey, String elementId, long elementInstanceKey, long jobKey, Record<IncidentRecordValue> incidentResolvedEvent) { final IncidentRecordValue incidentEventValue = incidentResolvedEvent.getValue(); Assertions.assertThat(incidentEventValue) .hasErrorType(errorType) .hasErrorMessage(errorMsg) .hasBpmnProcessId("process") .hasWorkflowInstanceKey(workflowInstanceKey) .hasElementId(elementId) .hasElementInstanceKey(elementInstanceKey) .hasJobKey(jobKey) .hasVariableScopeKey(elementInstanceKey); }
@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 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()); }
.hasElementInstanceKey(failureEvent.getKey()) .hasJobKey(-1L) .hasVariableScopeKey(workflowInstanceKey);