public static void assertIncidentContainErrorDetails( Record<IncidentRecordValue> incidentEvent, String errorMsg) { assertIncidentContainErrorDetails(incidentEvent, ErrorType.IO_MAPPING_ERROR.name(), errorMsg); }
public static void assertIncidentContainErrorDetails( Record<IncidentRecordValue> incidentEvent, String errorMsg) { assertIncidentContainErrorDetails(incidentEvent, ErrorType.IO_MAPPING_ERROR.name(), errorMsg); }
public static void assertIOMappingIncidentWithNoData( long workflowInstanceKey, String activityId, Record<WorkflowInstanceRecordValue> followUpEvent, Record<IncidentRecordValue> incidentRecord) { assertIncidentRecordValue( ErrorType.IO_MAPPING_ERROR.name(), "No data found for query $.foo.", workflowInstanceKey, activityId, followUpEvent, incidentRecord); }
public static void assertIOMappingIncidentWithNoData( long workflowInstanceKey, String activityId, Record<WorkflowInstanceRecordValue> followUpEvent, Record<IncidentRecordValue> incidentRecord) { assertIncidentRecordValue( ErrorType.IO_MAPPING_ERROR.name(), "No data found for query $.foo.", workflowInstanceKey, activityId, followUpEvent, incidentRecord); }
@Test public void shouldCreateIncidentIfConditionFailsToEvaluate() { // given // when testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar")); // then incident is created final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "Cannot compare values of different types: STRING and INTEGER", "xor", incidentEvent); }
@Test public void shouldCreateIncidentIfConditionFailsToEvaluate() { // given // when testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar")); // then incident is created final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "Cannot compare values of different types: STRING and INTEGER", "xor", incidentEvent); }
private IncidentRecordValue ofIncidentRecord(final LoggedEvent event) { final IncidentRecord record = new IncidentRecord(); event.readValue(record); return new IncidentRecordValueImpl( objectMapper, record.getErrorType().name(), asString(record.getErrorMessage()), asString(record.getBpmnProcessId()), asString(record.getElementId()), record.getWorkflowInstanceKey(), record.getElementInstanceKey(), record.getJobKey()); }
@Test public void shouldCreateIncidentIfExclusiveGatewayHasNoMatchingCondition() { // given // when testClient.createWorkflowInstance("workflow", asMsgPack("foo", 12)); // then incident is created final Record<WorkflowInstanceRecordValue> failingEvent = testClient.receiveFirstWorkflowInstanceEvent(WorkflowInstanceIntent.GATEWAY_ACTIVATED); final Record<IncidentRecordValue> incidentCommand = testClient.receiveFirstIncidentCommand(IncidentIntent.CREATE); final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentCommand.getSourceRecordPosition()).isEqualTo(failingEvent.getPosition()); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "All conditions evaluated to false and no default flow is set.", "xor", incidentEvent); }
@Test public void shouldCreateIncidentIfExclusiveGatewayHasNoMatchingCondition() { // given // when testClient.createWorkflowInstance("workflow", asMsgPack("foo", 12)); // then incident is created final Record<WorkflowInstanceRecordValue> failingEvent = testClient.receiveFirstWorkflowInstanceEvent( WorkflowInstanceIntent.ELEMENT_ACTIVATING, BpmnElementType.EXCLUSIVE_GATEWAY); final Record<IncidentRecordValue> incidentCommand = testClient.receiveFirstIncidentCommand(IncidentIntent.CREATE); final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentCommand.getSourceRecordPosition()).isEqualTo(failingEvent.getPosition()); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "Expected at least one condition to evaluate to true, or to have a default flow", "xor", incidentEvent); }
private IncidentRecordValue ofIncidentRecord(final LoggedEvent event) { final IncidentRecord record = new IncidentRecord(); event.readValue(record); return new IncidentRecordValueImpl( objectMapper, record.getErrorType().name(), asString(record.getErrorMessage()), asString(record.getBpmnProcessId()), asString(record.getElementId()), record.getWorkflowInstanceKey(), record.getElementInstanceKey(), record.getJobKey(), record.getVariableScopeKey()); }
@Test public void shouldResolveIncidentIfInstanceCanceled() { // given final long workflowInstance = testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar")); // when testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); testClient.cancelWorkflowInstance(workflowInstance); // then incident is resolved final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.RESOLVED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "Cannot compare values of different types: STRING and INTEGER", "xor", incidentEvent); } }
@Test public void shouldResolveIncidentIfInstanceCanceled() { // given final long workflowInstance = testClient.createWorkflowInstance("workflow", asMsgPack("foo", "bar")); // when testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); testClient.cancelWorkflowInstance(workflowInstance); // then incident is resolved final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.RESOLVED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentRecordValue( ErrorType.CONDITION_ERROR.name(), "Cannot compare values of different types: STRING and INTEGER", "xor", incidentEvent); } }
@Test public void shouldCreateIncidentWithJobErrorMessage() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); // when createIncidentWithJobWitMessage("failed job"); // then final Record activityEvent = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final Record failedEvent = testClient.receiveFirstJobEvent(JobIntent.FAILED); final Record incidentCommand = testClient.receiveFirstIncidentCommand(IncidentIntent.CREATE); final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentCommand.getSourceRecordPosition()).isEqualTo(failedEvent.getPosition()); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertIncidentRecordValue( ErrorType.JOB_NO_RETRIES.name(), "failed job", workflowInstanceKey, "failingTask", activityEvent.getKey(), failedEvent.getKey(), incidentEvent); }
@Test public void shouldIncidentContainLastFailedJobErrorMessage() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); // when failJobWithMessage(1, "first message"); failJobWithMessage(0, "second message"); // then final Record activityEvent = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final Record failedEvent = testClient.receiveFirstJobEvent(JobIntent.FAILED); final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertIncidentRecordValue( ErrorType.JOB_NO_RETRIES.name(), "second message", workflowInstanceKey, "failingTask", activityEvent.getKey(), failedEvent.getKey(), incidentEvent); }
@Test public void shouldIncidentContainLastFailedJobErrorMessage() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); // when failJobWithMessage(1, "first message"); failJobWithMessage(0, "second message"); // then final Record activityEvent = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_ACTIVATED); final Record failedEvent = testClient.receiveFirstJobEvent(JobIntent.FAILED); final Record incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertIncidentRecordValue( ErrorType.JOB_NO_RETRIES.name(), "second message", workflowInstanceKey, "failingTask", activityEvent.getKey(), failedEvent.getKey(), incidentEvent); }
@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 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); }