public IncidentRecordStream withJobKey(final long jobKey) { return valueFilter(v -> v.getJobKey() == jobKey); } }
public IncidentRecordStream withBpmnProcessId(final String bpmnProcessId) { return valueFilter(v -> bpmnProcessId.equals(v.getBpmnProcessId())); }
/** * Verifies that the actual IncidentRecordValue's elementInstanceKey is equal to the given one. * @param elementInstanceKey the given elementInstanceKey to compare the actual IncidentRecordValue's elementInstanceKey to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's elementInstanceKey is not equal to the given one. */ public S hasElementInstanceKey(long elementInstanceKey) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting elementInstanceKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualElementInstanceKey = actual.getElementInstanceKey(); if (actualElementInstanceKey != elementInstanceKey) { failWithMessage(assertjErrorMessage, actual, elementInstanceKey, actualElementInstanceKey); } // return the current assertion for method chaining return myself; }
public IncidentRecordStream withErrorMessage(final String errorMessage) { return valueFilter(v -> errorMessage.equals(v.getErrorMessage())); }
public IncidentRecordStream withErrorType(final String errorType) { return valueFilter(v -> errorType.equals(v.getErrorType())); }
public IncidentRecordStream withWorkflowInstanceKey(final long workflowInstanceKey) { return valueFilter(v -> v.getWorkflowInstanceKey() == workflowInstanceKey); }
@Test public void shouldCreateIncidentForInputMappingFailure() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); // when final long workflowInstanceKey = testClient.createWorkflowInstance("process"); // then final Record failureEvent = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_ACTIVATING); final Record createIncidentEvent = testClient.receiveFirstIncidentCommand(IncidentIntent.CREATE); final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); assertThat(incidentEvent.getKey()).isGreaterThan(0); assertThat(createIncidentEvent.getSourceRecordPosition()).isEqualTo(failureEvent.getPosition()); assertThat(incidentEvent.getSourceRecordPosition()) .isEqualTo(createIncidentEvent.getPosition()); assertThat(incidentEvent.getValue().getVariableScopeKey()).isEqualTo(failureEvent.getKey()); assertIOMappingIncidentWithNoData(workflowInstanceKey, failureEvent, incidentEvent); }
/** * Verifies that the actual IncidentRecordValue's elementId is equal to the given one. * @param elementId the given elementId to compare the actual IncidentRecordValue's elementId to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's elementId is not equal to the given one. */ public S hasElementId(String elementId) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting elementId of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualElementId = actual.getElementId(); if (!Objects.areEqual(actualElementId, elementId)) { failWithMessage(assertjErrorMessage, actual, elementId, actualElementId); } // return the current assertion for method chaining return myself; }
public IncidentRecordStream withErrorMessage(final String errorMessage) { return valueFilter(v -> errorMessage.equals(v.getErrorMessage())); }
public IncidentRecordStream withErrorType(final String errorType) { return valueFilter(v -> errorType.equals(v.getErrorType())); }
public IncidentRecordStream withWorkflowInstanceKey(final long workflowInstanceKey) { return valueFilter(v -> v.getWorkflowInstanceKey() == workflowInstanceKey); }
@Test public void shouldCreateIncidentForNonMatchingAndMatchingValueOnInputMapping() { // given testClient.deploy( Bpmn.createExecutableProcess("process") .startEvent() .serviceTask( "service", t -> t.zeebeTaskType("external") .zeebeInput("$.notExisting", "$.nullVal") .zeebeInput(NODE_STRING_PATH, "$.existing")) .endEvent() .done()); // when testClient.createWorkflowInstance("process", MSGPACK_PAYLOAD); final Record<WorkflowInstanceRecordValue> failureEvent = testClient.receiveElementInState("service", WorkflowInstanceIntent.ELEMENT_ACTIVATING); final Record<IncidentRecordValue> incidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); // then incident is created assertThat(incidentEvent.getKey()).isGreaterThan(0); assertThat(incidentEvent.getValue().getVariableScopeKey()).isEqualTo(failureEvent.getKey()); assertIncidentRecordValue( ErrorType.IO_MAPPING_ERROR.name(), "No data found for query $.notExisting.", "service", incidentEvent); }
@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()); } }
public IncidentRecordStream withJobKey(final long jobKey) { return valueFilter(v -> v.getJobKey() == jobKey); } }
/** * Verifies that the actual IncidentRecordValue's errorMessage is equal to the given one. * @param errorMessage the given errorMessage to compare the actual IncidentRecordValue's errorMessage to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's errorMessage is not equal to the given one. */ public S hasErrorMessage(String errorMessage) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting errorMessage of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualErrorMessage = actual.getErrorMessage(); if (!Objects.areEqual(actualErrorMessage, errorMessage)) { failWithMessage(assertjErrorMessage, actual, errorMessage, actualErrorMessage); } // return the current assertion for method chaining return myself; }
public IncidentRecordStream withBpmnProcessId(final String bpmnProcessId) { return valueFilter(v -> bpmnProcessId.equals(v.getBpmnProcessId())); }
/** * Verifies that the actual IncidentRecordValue's errorType is equal to the given one. * @param errorType the given errorType to compare the actual IncidentRecordValue's errorType to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's errorType is not equal to the given one. */ public S hasErrorType(String errorType) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting errorType of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualErrorType = actual.getErrorType(); if (!Objects.areEqual(actualErrorType, errorType)) { failWithMessage(assertjErrorMessage, actual, errorType, actualErrorType); } // return the current assertion for method chaining return myself; }
/** * Verifies that the actual IncidentRecordValue's workflowInstanceKey is equal to the given one. * @param workflowInstanceKey the given workflowInstanceKey to compare the actual IncidentRecordValue's workflowInstanceKey to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's workflowInstanceKey is not equal to the given one. */ public S hasWorkflowInstanceKey(long workflowInstanceKey) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting workflowInstanceKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualWorkflowInstanceKey = actual.getWorkflowInstanceKey(); if (actualWorkflowInstanceKey != workflowInstanceKey) { failWithMessage(assertjErrorMessage, actual, workflowInstanceKey, actualWorkflowInstanceKey); } // return the current assertion for method chaining return myself; }
@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()); } }
/** * Verifies that the actual IncidentRecordValue's jobKey is equal to the given one. * @param jobKey the given jobKey to compare the actual IncidentRecordValue's jobKey to. * @return this assertion object. * @throws AssertionError - if the actual IncidentRecordValue's jobKey is not equal to the given one. */ public S hasJobKey(long jobKey) { // check that actual IncidentRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting jobKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualJobKey = actual.getJobKey(); if (actualJobKey != jobKey) { failWithMessage(assertjErrorMessage, actual, jobKey, actualJobKey); } // return the current assertion for method chaining return myself; }