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 shouldResolveIncidentIfActivityTerminated() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process"); final Record incidentCreatedEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record activityTerminating = testClient.receiveFirstWorkflowInstanceEvent( workflowInstanceKey, "failingTask", WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record<IncidentRecordValue> incidentResolvedEvent = testClient.receiveFirstIncidentEvent(RESOLVED); assertThat(incidentResolvedEvent.getKey()).isEqualTo(incidentCreatedEvent.getKey()); assertThat(activityTerminating.getPosition()) .isEqualTo(incidentResolvedEvent.getSourceRecordPosition()); assertIncidentRecordValue( ErrorType.IO_MAPPING_ERROR.name(), "No data found for query $.foo.", workflowInstanceKey, "failingTask", incidentResolvedEvent.getValue().getElementInstanceKey(), incidentResolvedEvent); }
@Test public void shouldResolveIncidentIfActivityTerminated() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process"); final Record incidentCreatedEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record activityTerminating = testClient.receiveFirstWorkflowInstanceEvent( workflowInstanceKey, "failingTask", WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record<IncidentRecordValue> incidentResolvedEvent = testClient.receiveFirstIncidentEvent(RESOLVED); assertThat(incidentResolvedEvent.getKey()).isEqualTo(incidentCreatedEvent.getKey()); assertThat(activityTerminating.getPosition()) .isEqualTo(incidentResolvedEvent.getSourceRecordPosition()); assertIncidentRecordValue( ErrorType.IO_MAPPING_ERROR.name(), "No data found for query $.foo.", workflowInstanceKey, "failingTask", incidentResolvedEvent.getValue().getElementInstanceKey(), incidentResolvedEvent); }
@Test public void shouldDeleteIncidentIfJobIsCanceled() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); failJobWithNoRetriesLeft(); final Record incidentCreatedEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<WorkflowInstanceRecordValue> terminatingTask = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record jobCancelCommand = testClient.receiveFirstJobCommand(JobIntent.CANCEL); final Record<IncidentRecordValue> resolvedIncidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.RESOLVED); assertThat(resolvedIncidentEvent.getKey()).isEqualTo(incidentCreatedEvent.getKey()); assertThat(resolvedIncidentEvent.getSourceRecordPosition()) .isEqualTo(terminatingTask.getPosition()); assertThat(jobCancelCommand.getSourceRecordPosition()).isEqualTo(terminatingTask.getPosition()); assertIncidentRecordValue( ErrorType.JOB_NO_RETRIES.name(), "No more retries left.", workflowInstanceKey, "failingTask", resolvedIncidentEvent.getValue().getElementInstanceKey(), jobCancelCommand.getKey(), resolvedIncidentEvent); }
@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 shouldDeleteIncidentIfJobIsCanceled() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); failJobWithNoRetriesLeft(); final Record incidentCreatedEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.CREATED); // when testClient.cancelWorkflowInstance(workflowInstanceKey); // then final Record<WorkflowInstanceRecordValue> terminatingTask = testClient.receiveElementInState("failingTask", WorkflowInstanceIntent.ELEMENT_TERMINATING); final Record jobCancelCommand = testClient.receiveFirstJobCommand(JobIntent.CANCEL); final Record<IncidentRecordValue> resolvedIncidentEvent = testClient.receiveFirstIncidentEvent(IncidentIntent.RESOLVED); assertThat(resolvedIncidentEvent.getKey()).isEqualTo(incidentCreatedEvent.getKey()); assertThat(resolvedIncidentEvent.getSourceRecordPosition()) .isEqualTo(terminatingTask.getPosition()); assertThat(jobCancelCommand.getSourceRecordPosition()).isEqualTo(terminatingTask.getPosition()); assertIncidentRecordValue( ErrorType.JOB_NO_RETRIES.name(), "No more retries left.", workflowInstanceKey, "failingTask", resolvedIncidentEvent.getValue().getElementInstanceKey(), jobCancelCommand.getKey(), resolvedIncidentEvent); }
@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 shouldCreateIncidentIfJobHasNoRetriesLeft() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); // when failJobWithNoRetriesLeft(); // 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(), "No more retries left.", workflowInstanceKey, "failingTask", activityEvent.getKey(), failedEvent.getKey(), 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 shouldCreateIncidentIfJobHasNoRetriesLeft() { // given testClient.deploy(WORKFLOW_INPUT_MAPPING); final long workflowInstanceKey = testClient.createWorkflowInstance("process", PAYLOAD); // when failJobWithNoRetriesLeft(); // 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(), "No more retries left.", workflowInstanceKey, "failingTask", activityEvent.getKey(), failedEvent.getKey(), incidentEvent); }