public IncidentRecord initFromWorkflowInstanceFailure( long key, WorkflowInstanceRecord workflowInstanceEvent) { setElementInstanceKey(key); setBpmnProcessId(workflowInstanceEvent.getBpmnProcessId()); setWorkflowInstanceKey(workflowInstanceEvent.getWorkflowInstanceKey()); setElementId(workflowInstanceEvent.getElementId()); return this; } }
@Test public void shouldRemoveIncidentFromStateOnResolved() { // given final IncidentState incidentState = streamProcessorRule.getZeebeState().getIncidentState(); final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); incidentState.createIncident(1, incidentRecord); // when envRule.writeCommand(1, IncidentIntent.RESOLVE, incidentRecord); // then streamProcessorRule.awaitIncidentInState(IncidentIntent.RESOLVED); final IncidentRecord persistedIncident = incidentState.getIncidentRecord(1); assertThat(persistedIncident).isNull(); } }
@Test public void shouldRemoveIncidentFromStateOnResolved() { // given final IncidentState incidentState = streamProcessorRule.getZeebeState().getIncidentState(); final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); incidentState.createIncident(1, incidentRecord); // when envRule.writeCommand(1, IncidentIntent.RESOLVE, incidentRecord); // then streamProcessorRule.awaitIncidentInState(IncidentIntent.RESOLVED); final IncidentRecord persistedIncident = incidentState.getIncidentRecord(1); assertThat(persistedIncident).isNull(); } }
public IncidentRecord createWorkflowInstanceIncident() { final IncidentRecord expectedRecord = new IncidentRecord(); expectedRecord.setElementInstanceKey(1234); expectedRecord.setBpmnProcessId(wrapString("process")); expectedRecord.setElementId(wrapString("process")); expectedRecord.setWorkflowInstanceKey(4321); expectedRecord.setErrorMessage("Error because of error"); expectedRecord.setErrorType(ErrorType.EXTRACT_VALUE_ERROR); return expectedRecord; }
public IncidentRecord createWorkflowInstanceIncident() { final IncidentRecord expectedRecord = new IncidentRecord(); expectedRecord.setElementInstanceKey(1234); expectedRecord.setBpmnProcessId(wrapString("process")); expectedRecord.setElementId(wrapString("process")); expectedRecord.setWorkflowInstanceKey(4321); expectedRecord.setErrorMessage("Error because of error"); expectedRecord.setErrorType(ErrorType.EXTRACT_VALUE_ERROR); return expectedRecord; }
@Test public void shouldNotCreateIncidentIfNoFailedToken() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); // when envRule.writeCommand(IncidentIntent.CREATE, incidentRecord); // trigger incident creation // then streamProcessorRule.awaitIncidentRejection(IncidentIntent.CREATE); final List<TypedRecord<IncidentRecord>> incidentEvents = envRule.events().onlyIncidentRecords().collect(Collectors.toList()); assertThat(incidentEvents) .extracting(r -> r.getMetadata()) .extracting(m -> m.getRecordType(), m -> m.getIntent()) .containsExactly( tuple(RecordType.COMMAND, IncidentIntent.CREATE), tuple(RecordType.COMMAND_REJECTION, IncidentIntent.CREATE)); }
@Test public void shouldNotResolveIfNoIncident() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); // when envRule.writeCommand(IncidentIntent.RESOLVE, incidentRecord); // then streamProcessorRule.awaitIncidentRejection(IncidentIntent.RESOLVE); final List<TypedRecord<IncidentRecord>> incidentEvents = envRule.events().onlyIncidentRecords().collect(Collectors.toList()); assertThat(incidentEvents) .extracting(r -> r.getMetadata()) .extracting(m -> m.getRecordType(), m -> m.getIntent()) .containsExactly( tuple(RecordType.COMMAND, IncidentIntent.RESOLVE), tuple(RecordType.COMMAND_REJECTION, IncidentIntent.RESOLVE)); }
@Test public void shouldNotCreateIncidentIfNoFailedToken() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); // when envRule.writeCommand(IncidentIntent.CREATE, incidentRecord); // trigger incident creation // then streamProcessorRule.awaitIncidentRejection(IncidentIntent.CREATE); final List<TypedRecord<IncidentRecord>> incidentEvents = envRule.events().onlyIncidentRecords().collect(Collectors.toList()); assertThat(incidentEvents) .extracting(r -> r.getMetadata()) .extracting(m -> m.getRecordType(), m -> m.getIntent()) .containsExactly( tuple(RecordType.COMMAND, IncidentIntent.CREATE), tuple(RecordType.COMMAND_REJECTION, IncidentIntent.CREATE)); }
@Test public void shouldNotResolveIfNoIncident() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setElementInstanceKey(2); // when envRule.writeCommand(IncidentIntent.RESOLVE, incidentRecord); // then streamProcessorRule.awaitIncidentRejection(IncidentIntent.RESOLVE); final List<TypedRecord<IncidentRecord>> incidentEvents = envRule.events().onlyIncidentRecords().collect(Collectors.toList()); assertThat(incidentEvents) .extracting(r -> r.getMetadata()) .extracting(m -> m.getRecordType(), m -> m.getIntent()) .containsExactly( tuple(RecordType.COMMAND, IncidentIntent.RESOLVE), tuple(RecordType.COMMAND_REJECTION, IncidentIntent.RESOLVE)); }
@Override public void processRecord( TypedRecord<JobRecord> event, TypedResponseWriter responseWriter, TypedStreamWriter streamWriter) { final JobRecord value = event.getValue(); if (value.getRetries() <= 0) { final JobHeaders jobHeaders = value.getHeaders(); final DirectBuffer jobErrorMessage = value.getErrorMessage(); DirectBuffer incidentErrorMessage = DEFAULT_ERROR_MESSAGE; if (jobErrorMessage.capacity() > 0) { incidentErrorMessage = jobErrorMessage; } incidentEvent.reset(); incidentEvent .setErrorType(ErrorType.JOB_NO_RETRIES) .setErrorMessage(incidentErrorMessage) .setBpmnProcessId(jobHeaders.getBpmnProcessId()) .setWorkflowInstanceKey(jobHeaders.getWorkflowInstanceKey()) .setElementId(jobHeaders.getElementId()) .setElementInstanceKey(jobHeaders.getElementInstanceKey()) .setJobKey(event.getKey()); streamWriter.appendNewCommand(IncidentIntent.CREATE, incidentEvent); } } }
.setWorkflowInstanceKey(jobHeaders.getWorkflowInstanceKey()) .setElementId(jobHeaders.getElementId()) .setElementInstanceKey(jobHeaders.getElementInstanceKey()) .setJobKey(event.getKey()) .setVariableScopeKey(jobHeaders.getElementInstanceKey());
.setElementInstanceKey(elementInstanceKey) .setWorkflowInstanceKey(workflowInstanceKey) .setElementId(wrapString(elementId))
.setElementInstanceKey(elementInstanceKey) .setWorkflowInstanceKey(workflowInstanceKey) .setElementId(wrapString(elementId))