@Override protected IncidentRecord toResponseDto(DirectBuffer buffer) { final IncidentRecord responseDto = new IncidentRecord(); responseDto.wrap(buffer); return responseDto; } }
private void initEventTypeMap() { recordsByType.put(ValueType.DEPLOYMENT, new DeploymentRecord()); recordsByType.put(ValueType.JOB, new JobRecord()); recordsByType.put(ValueType.WORKFLOW_INSTANCE, new WorkflowInstanceRecord()); recordsByType.put(ValueType.MESSAGE, new MessageRecord()); recordsByType.put(ValueType.JOB_BATCH, new JobBatchRecord()); recordsByType.put(ValueType.INCIDENT, new IncidentRecord()); }
private void initEventTypeMap() { recordsByType.put(ValueType.DEPLOYMENT, new DeploymentRecord()); recordsByType.put(ValueType.JOB, new JobRecord()); recordsByType.put(ValueType.WORKFLOW_INSTANCE, new WorkflowInstanceRecord()); recordsByType.put(ValueType.MESSAGE, new MessageRecord()); recordsByType.put(ValueType.JOB_BATCH, new JobBatchRecord()); recordsByType.put(ValueType.INCIDENT, new IncidentRecord()); }
public IncidentRecord createJobIncident() { final IncidentRecord expectedRecord = new IncidentRecord(); expectedRecord.setJobKey(1234); expectedRecord.setErrorMessage("Error because of error"); expectedRecord.setErrorType(ErrorType.EXTRACT_VALUE_ERROR); return expectedRecord; }
public IncidentRecord createJobIncident() { final IncidentRecord expectedRecord = new IncidentRecord(); expectedRecord.setJobKey(1234); expectedRecord.setErrorMessage("Error because of error"); expectedRecord.setErrorType(ErrorType.EXTRACT_VALUE_ERROR); return expectedRecord; }
public IncidentState(ZeebeDb<ZbColumnFamilies> zeebeDb) { this.zeebeDb = zeebeDb; incidentKey = new DbLong(); incidenRecordToRead = new UnpackedObjectValue(); incidenRecordToRead.wrapObject(new IncidentRecord()); incidentRecordToWrite = new UnpackedObjectValue(); incidentColumnFamily = zeebeDb.createColumnFamily(ZbColumnFamilies.INCIDENTS, incidentKey, incidenRecordToRead); elementInstanceKey = new DbLong(); workflowInstanceIncidentColumnFamily = zeebeDb.createColumnFamily( ZbColumnFamilies.INCIDENT_WORKFLOW_INSTANCES, elementInstanceKey, incidentKey); jobKey = new DbLong(); jobIncidentColumnFamily = zeebeDb.createColumnFamily(ZbColumnFamilies.INCIDENT_JOBS, jobKey, incidentKey); }
public IncidentState(ZeebeDb<ZbColumnFamilies> zeebeDb) { this.zeebeDb = zeebeDb; incidentKey = new DbLong(); incidenRecordToRead = new UnpackedObjectValue(); incidenRecordToRead.wrapObject(new IncidentRecord()); incidentRecordToWrite = new UnpackedObjectValue(); incidentColumnFamily = zeebeDb.createColumnFamily(ZbColumnFamilies.INCIDENTS, incidentKey, incidenRecordToRead); elementInstanceKey = new DbLong(); workflowInstanceIncidentColumnFamily = zeebeDb.createColumnFamily( ZbColumnFamilies.INCIDENT_WORKFLOW_INSTANCES, elementInstanceKey, incidentKey); jobKey = new DbLong(); jobIncidentColumnFamily = zeebeDb.createColumnFamily(ZbColumnFamilies.INCIDENT_JOBS, jobKey, incidentKey); }
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()); }
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 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 shouldNotCreateIncidentIfNoFailedJob() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setJobKey(1); // 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 shouldNotCreateIncidentIfNoFailedJob() { // given final IncidentRecord incidentRecord = new IncidentRecord(); incidentRecord.setJobKey(1); // 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 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)); }
new IncidentRecord() .setElementInstanceKey(elementInstanceKey) .setWorkflowInstanceKey(workflowInstanceKey)