From c015b097021a541ff039eef34f6bae1aa2eeab97 Mon Sep 17 00:00:00 2001 From: martin Date: Mon, 25 Nov 2024 18:24:09 +0000 Subject: [PATCH] DBZ-8453 remove duplicate enum preventing processing of deletes --- .../As400StreamingChangeEventSource.java | 2 +- .../journal/retrieve/JournalEntryType.java | 5 ++--- .../retrieve/JournalEntryTypeTest.java | 21 +++++++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 journal-parsing/src/test/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryTypeTest.java diff --git a/debezium-connector-ibmi/src/main/java/io/debezium/connector/db2as400/As400StreamingChangeEventSource.java b/debezium-connector-ibmi/src/main/java/io/debezium/connector/db2as400/As400StreamingChangeEventSource.java index 0ed7bdb..2d56ff6 100644 --- a/debezium-connector-ibmi/src/main/java/io/debezium/connector/db2as400/As400StreamingChangeEventSource.java +++ b/debezium-connector-ibmi/src/main/java/io/debezium/connector/db2as400/As400StreamingChangeEventSource.java @@ -301,7 +301,7 @@ private BlockingReceiverConsumer processJournalEntries(As400Partition partition, offsetContext, Operation.CREATE, null, dataNext, clock, connectorConfig)); } break; - case DELETE_ROW1, DELETE_ROW2: { + case DELETE_ROW, ROLLBACK_DELETE_ROW: { // record deleted final Object[] dataBefore = r.decode(schema.getFileDecoder()); diff --git a/journal-parsing/src/main/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryType.java b/journal-parsing/src/main/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryType.java index 710815a..a86ee8b 100644 --- a/journal-parsing/src/main/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryType.java +++ b/journal-parsing/src/main/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryType.java @@ -10,14 +10,13 @@ public enum JournalEntryType { - ADD_ROW2("R.PT"), ADD_ROW1("R.PX"), + ADD_ROW2("R.PT"), AFTER_IMAGE("R.UP"), ROLLBACK_AFTER_IMAGE("R.UR"), BEFORE_IMAGE("R.UB"), ROLLBACK_BEFORE_IMAGE("R.BR"), - DELETE_ROW1("R.DR"), - DELETE_ROW2("R.DL"), + DELETE_ROW("R.DL"), ROLLBACK_DELETE_ROW("R.DR"), FILE_CREATED("D.CT"), FILE_CHANGE("D.CG"), diff --git a/journal-parsing/src/test/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryTypeTest.java b/journal-parsing/src/test/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryTypeTest.java new file mode 100644 index 0000000..f1b46cc --- /dev/null +++ b/journal-parsing/src/test/java/io/debezium/ibmi/db2/journal/retrieve/JournalEntryTypeTest.java @@ -0,0 +1,21 @@ +package io.debezium.ibmi.db2.journal.retrieve; + +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.HashMap; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +class JournalEntryTypeTest { + + @Test + public void checkNoDuplicateEnums() { + Map found = new HashMap<>(); + for (final JournalEntryType e : JournalEntryType.values()) { + assertFalse(found.containsKey(e.code), "map must not contain duplicate values found enums " + e + ", " + found.get(e.code)); + found.put(e.code, e); + } + } + +}