Search in sources :

Example 1 with ErrorRecord

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);
}
Also used : RecordStream(io.camunda.zeebe.engine.util.RecordStream) ErrorRecord(io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord) Test(org.junit.Test)

Example 2 with ErrorRecord

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);
}
Also used : RecordStream(io.camunda.zeebe.engine.util.RecordStream) UnifiedRecordValue(io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue) TypedStreamWriter(io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedStreamWriter) TypedResponseWriter(io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedResponseWriter) ErrorRecord(io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord) Test(org.junit.Test)

Example 3 with ErrorRecord

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;
}
Also used : ErrorRecord(io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord)

Example 4 with ErrorRecord

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;
}
Also used : ErrorRecord(io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord)

Example 5 with ErrorRecord

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);
}
Also used : RecordStream(io.camunda.zeebe.engine.util.RecordStream) ErrorRecord(io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord) Test(org.junit.Test)

Aggregations

ErrorRecord (io.camunda.zeebe.protocol.impl.record.value.error.ErrorRecord)9 RecordStream (io.camunda.zeebe.engine.util.RecordStream)6 Test (org.junit.Test)6 TypedResponseWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedResponseWriter)3 TypedStreamWriter (io.camunda.zeebe.engine.processing.streamprocessor.writers.TypedStreamWriter)3 UnifiedRecordValue (io.camunda.zeebe.protocol.impl.record.UnifiedRecordValue)3