use of io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord in project zeebe by camunda.
the class SkipFailingEventsTest method shouldWriteErrorEvent.
@Test
public void shouldWriteErrorEvent() {
// given
final ErrorProneProcessor errorProneProcessor = new ErrorProneProcessor();
streams.startStreamProcessor(STREAM_NAME, DefaultZeebeDbFactory.defaultFactory(), (processingContext) -> {
zeebeState = processingContext.getZeebeState();
return TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), processingContext.getWriters()).onCommand(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ACTIVATE_ELEMENT, errorProneProcessor);
});
final long failingEventPosition = streams.newRecord(STREAM_NAME).event(PROCESS_INSTANCE_RECORD).recordType(RecordType.COMMAND).intent(ProcessInstanceIntent.ACTIVATE_ELEMENT).key(keyGenerator.nextKey()).write();
// when
waitForRecordWhichSatisfies(e -> Records.isEvent(e, ValueType.ERROR, ErrorIntent.CREATED));
// then
assertThat(errorProneProcessor.getProcessCount()).isEqualTo(1);
final ErrorRecord errorRecord = new RecordStream(streams.events(STREAM_NAME)).onlyErrorRecords().getFirst().getValue();
assertThat(errorRecord.getErrorEventPosition()).isEqualTo(failingEventPosition);
assertThat(BufferUtil.bufferAsString(errorRecord.getExceptionMessageBuffer())).isEqualTo("expected");
assertThat(errorRecord.getProcessInstanceKey()).isEqualTo(1);
}
use of io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord in project zeebe by camunda.
the class SkipFailingEventsTest method shouldWriteErrorEventWithNoMessage.
@Test
public void shouldWriteErrorEventWithNoMessage() {
// given
streams.startStreamProcessor(STREAM_NAME, DefaultZeebeDbFactory.defaultFactory(), (processingContext) -> {
zeebeState = processingContext.getZeebeState();
return TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), processingContext.getWriters()).onCommand(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ACTIVATE_ELEMENT, new TypedRecordProcessor<>() {
@Override
public void processRecord(final TypedRecord<UnifiedRecordValue> record, final TypedResponseWriter responseWriter, final TypedStreamWriter streamWriter) {
throw new NullPointerException();
}
});
});
final long failingEventPosition = streams.newRecord(STREAM_NAME).event(PROCESS_INSTANCE_RECORD).recordType(RecordType.COMMAND).intent(ProcessInstanceIntent.ACTIVATE_ELEMENT).key(keyGenerator.nextKey()).write();
// when
waitForRecordWhichSatisfies(e -> Records.isEvent(e, ValueType.ERROR, ErrorIntent.CREATED));
// then
final ErrorRecord errorRecord = new RecordStream(streams.events(STREAM_NAME)).onlyErrorRecords().getFirst().getValue();
assertThat(errorRecord.getErrorEventPosition()).isEqualTo(failingEventPosition);
assertThat(BufferUtil.bufferAsString(errorRecord.getExceptionMessageBuffer())).isEqualTo("Without exception message.");
assertThat(errorRecord.getProcessInstanceKey()).isEqualTo(1);
}
use of io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord in project zeebe by camunda.
the class Records method error.
public static ErrorRecord error(final int instanceKey, final long pos) {
final ErrorRecord event = new ErrorRecord();
event.initErrorRecord(new Exception("expected"), pos);
event.setProcessInstanceKey(instanceKey);
return event;
}
use of io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord in project zeebe by zeebe-io.
the class Records method error.
public static ErrorRecord error(final int instanceKey, final long pos) {
final ErrorRecord event = new ErrorRecord();
event.initErrorRecord(new Exception("expected"), pos);
event.setProcessInstanceKey(instanceKey);
return event;
}
use of io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord in project zeebe by zeebe-io.
the class SkipFailingEventsTest method shouldWriteErrorEvent.
@Test
public void shouldWriteErrorEvent() {
// given
final ErrorProneProcessor errorProneProcessor = new ErrorProneProcessor();
streams.startStreamProcessor(STREAM_NAME, DefaultZeebeDbFactory.defaultFactory(), (processingContext) -> {
zeebeState = processingContext.getZeebeState();
return TypedRecordProcessors.processors(zeebeState.getKeyGenerator(), processingContext.getWriters()).onCommand(ValueType.PROCESS_INSTANCE, ProcessInstanceIntent.ACTIVATE_ELEMENT, errorProneProcessor);
});
final long failingEventPosition = streams.newRecord(STREAM_NAME).event(PROCESS_INSTANCE_RECORD).recordType(RecordType.COMMAND).intent(ProcessInstanceIntent.ACTIVATE_ELEMENT).key(keyGenerator.nextKey()).write();
// when
waitForRecordWhichSatisfies(e -> Records.isEvent(e, ValueType.ERROR, ErrorIntent.CREATED));
// then
assertThat(errorProneProcessor.getProcessCount()).isEqualTo(1);
final ErrorRecord errorRecord = new RecordStream(streams.events(STREAM_NAME)).onlyErrorRecords().getFirst().getValue();
assertThat(errorRecord.getErrorEventPosition()).isEqualTo(failingEventPosition);
assertThat(BufferUtil.bufferAsString(errorRecord.getExceptionMessageBuffer())).isEqualTo("expected");
assertThat(errorRecord.getProcessInstanceKey()).isEqualTo(1);
}
Aggregations