diff --git a/src/main/java/io/zeebe/exporter/proto/RecordTransformer.java b/src/main/java/io/zeebe/exporter/proto/RecordTransformer.java index af225aa..6bf33cc 100644 --- a/src/main/java/io/zeebe/exporter/proto/RecordTransformer.java +++ b/src/main/java/io/zeebe/exporter/proto/RecordTransformer.java @@ -104,6 +104,7 @@ public final class RecordTransformer { TRANSFORMERS.put(ValueType.RESOURCE_DELETION, RecordTransformer::toResourceDeletionRecord); TRANSFORMERS.put(ValueType.USER_TASK, RecordTransformer::toUserTaskRecord); TRANSFORMERS.put(ValueType.COMPENSATION_SUBSCRIPTION, RecordTransformer::toCompensationSubscriptionRecord); + TRANSFORMERS.put(ValueType.ESCALATION, RecordTransformer::toEscalationRecord); VALUE_TYPE_MAPPING.put(ValueType.DEPLOYMENT, RecordMetadata.ValueType.DEPLOYMENT); VALUE_TYPE_MAPPING.put( @@ -842,6 +843,18 @@ private static Schema.CompensationSubscriptionRecord toCompensationSubscriptionR .build(); } + private static Schema.EscalationRecord toEscalationRecord(Record record) { + final var value = record.getValue(); + + return Schema.EscalationRecord.newBuilder() + .setMetadata(toMetadata(record)) + .setProcessInstanceKey(value.getProcessInstanceKey()) + .setEscalationCode(value.getEscalationCode()) + .setThrowElementId(value.getThrowElementId()) + .setCatchElementId(value.getCatchElementId()) + .build(); + } + private static Struct toStruct(Map map) { final Struct.Builder builder = Struct.newBuilder(); diff --git a/src/main/proto/schema.proto b/src/main/proto/schema.proto index 6681c67..8400672 100644 --- a/src/main/proto/schema.proto +++ b/src/main/proto/schema.proto @@ -531,4 +531,12 @@ message CompensationSubscriptionRecord { int64 compensableActivityScopeKey = 10; int64 compensableActivityInstanceKey = 11; google.protobuf.Struct variables = 12; +} + +message EscalationRecord { + RecordMetadata metadata = 1; + int64 processInstanceKey = 2; + string escalationCode = 3; + string throwElementId = 4; + string catchElementId = 5; } \ No newline at end of file diff --git a/src/test/java/io/zeebe/exporter/proto/RecordTransformTest.java b/src/test/java/io/zeebe/exporter/proto/RecordTransformTest.java index dc0f2cd..8cfe97f 100644 --- a/src/test/java/io/zeebe/exporter/proto/RecordTransformTest.java +++ b/src/test/java/io/zeebe/exporter/proto/RecordTransformTest.java @@ -1005,6 +1005,27 @@ public void shouldTransformCompensationSubscriptionRecord() { assertStruct(transformedRecord.getVariables(), recordValue.getVariables()); } + @Test + public void shouldTransformEscalationRecord() { + // given + final var recordValue = mockEscalationRecordValue(); + final Record mockedRecord = + mockRecord(recordValue, ValueType.ESCALATION, EscalationIntent.ESCALATED); + + // when + final var transformedRecord = + (Schema.EscalationRecord) RecordTransformer.toProtobufMessage(mockedRecord); + + // then + assertMetadata(transformedRecord.getMetadata(), "ESCALATION", "ESCALATED"); + + assertThat(transformedRecord.getProcessInstanceKey()) + .isEqualTo(recordValue.getProcessInstanceKey()); + assertThat(transformedRecord.getEscalationCode()).isEqualTo(recordValue.getEscalationCode()); + assertThat(transformedRecord.getThrowElementId()).isEqualTo(recordValue.getThrowElementId()); + assertThat(transformedRecord.getCatchElementId()).isEqualTo(recordValue.getCatchElementId()); + } + private void assertEvaluatedDecision( final Schema.DecisionEvaluationRecord.EvaluatedDecision transformedRecord, final EvaluatedDecisionValue recordValue) { @@ -1495,6 +1516,16 @@ private CompensationSubscriptionRecordValue mockCompensationSubscriptionRecordVa return value; } + private EscalationRecordValue mockEscalationRecordValue() { + final var value = mock(EscalationRecordValue.class); + when(value.getTenantId()).thenReturn(TENANT_ID); + when(value.getProcessInstanceKey()).thenReturn(1L); + when(value.getEscalationCode()).thenReturn("escalation-code"); + when(value.getThrowElementId()).thenReturn("throw-element-id"); + when(value.getCatchElementId()).thenReturn("catch-element-id"); + return value; + } + private void assertVariables(final Struct variables) { assertStruct(variables, VARIABLES); }