From 74cfa12028d2a4d1bd62358bf34ad22a9086e39b Mon Sep 17 00:00:00 2001 From: hantmac Date: Thu, 14 Dec 2023 22:49:28 +0800 Subject: [PATCH] fix test --- .../server/databend/DatabendChangeConsumer.java | 5 ++--- .../databend/DatabendChangeConsumerDeleteTest.java | 12 ++++++------ .../databend/DatabendChangeConsumerSimpleTest.java | 2 +- .../databend/DatabendChangeConsumerTest.java | 2 +- .../databend/DatabendChangeConsumerUpsertTest.java | 12 ++++++------ 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/debezium-server-databend-sink/src/main/java/io/debezium/server/databend/DatabendChangeConsumer.java b/debezium-server-databend-sink/src/main/java/io/debezium/server/databend/DatabendChangeConsumer.java index fd73989..791b24c 100644 --- a/debezium-server-databend-sink/src/main/java/io/debezium/server/databend/DatabendChangeConsumer.java +++ b/debezium-server-databend-sink/src/main/java/io/debezium/server/databend/DatabendChangeConsumer.java @@ -236,9 +236,8 @@ public String mapDestination(String destination) { return tablePrefix.orElse("") + tableName.orElse(""); } final String getTableName = destination - .replaceAll(destinationRegexp.orElse(""), destinationRegexpReplace.orElse("")) - .replace(".", "_"); - String[] parts = getTableName.split("_"); + .replaceAll(destinationRegexp.orElse(""), destinationRegexpReplace.orElse("")); + String[] parts = getTableName.split("."); String tableName = parts[parts.length - 1]; return tablePrefix.orElse("") + tableName; } diff --git a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerDeleteTest.java b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerDeleteTest.java index 4104f46..2e69702 100644 --- a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerDeleteTest.java +++ b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerDeleteTest.java @@ -60,9 +60,9 @@ public void testSimpleUpload() throws Exception { records.add(TestChangeEvent.of(dest, 3, "c")); consumer.handleBatch(records, TestUtil.getCommitter()); // check that its consumed! - ResultSet rs = getDatabendTableData("select * from public.debeziumcdc_customers_delete"); + ResultSet rs = getDatabendTableData("select * from public.customers_delete"); Assertions.assertEquals(getResultSetRowCount(rs), 3); - ResultSet rs1 = getDatabendTableData("select * from public.debeziumcdc_customers_delete where id =3"); + ResultSet rs1 = getDatabendTableData("select * from public.customers_delete where id =3"); if (rs1.next()) { int id = rs1.getInt("id"); Assertions.assertEquals(3, id); @@ -77,13 +77,13 @@ public void testSimpleUpload() throws Exception { records.add(TestChangeEvent.of(dest, 3, "u", "UpdatednameV1")); records.add(TestChangeEvent.of(dest, 4, "c")); consumer.handleBatch(records, TestUtil.getCommitter()); - ResultSet rsR = getDatabendTableData("select * from public.debeziumcdc_customers_delete where id = 1 AND __op= 'r'"); + ResultSet rsR = getDatabendTableData("select * from public.customers_delete where id = 1 AND __op= 'r'"); Assertions.assertEquals(getResultSetRowCount(rsR), 1); - ResultSet rsD = getDatabendTableData("select * from public.debeziumcdc_customers_delete where id = 2 AND __op= 'd'"); + ResultSet rsD = getDatabendTableData("select * from public.customers_delete where id = 2 AND __op= 'd'"); Assertions.assertEquals(getResultSetRowCount(rsD), 1); - ResultSet rsU = getDatabendTableData("select * from public.debeziumcdc_customers_delete where id = 3 AND __op= 'u'"); + ResultSet rsU = getDatabendTableData("select * from public.customers_delete where id = 3 AND __op= 'u'"); Assertions.assertEquals(getResultSetRowCount(rsU), 1); - ResultSet rsUName = getDatabendTableData("select * from public.debeziumcdc_customers_delete where id = 3 AND first_name= 'UpdatednameV1'"); + ResultSet rsUName = getDatabendTableData("select * from public.customers_delete where id = 3 AND first_name= 'UpdatednameV1'"); Assertions.assertEquals(getResultSetRowCount(rsUName), 1); } diff --git a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerSimpleTest.java b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerSimpleTest.java index 2187b59..44dae34 100644 --- a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerSimpleTest.java +++ b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerSimpleTest.java @@ -69,7 +69,7 @@ public void testSimpleUpload() throws Exception { @AfterEach public void clearData() throws SQLException, ClassNotFoundException { - ResultSet rs = select("delete from public.debeziumcdc_customers_append"); + ResultSet rs = select("delete from public.customers_append"); } } diff --git a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerTest.java b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerTest.java index f43e650..55f7f0e 100644 --- a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerTest.java +++ b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerTest.java @@ -133,7 +133,7 @@ public void testConsumingVariousDataTypes() throws Exception { @Test public void testTargetTableName() throws Exception { - String destination = "server_name_databaseName_realTableName"; + String destination = "server_name.databaseName.realTableName"; String realTableName = consumer.mapDestination(destination); Assertions.assertEquals("realTableName", realTableName); } diff --git a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerUpsertTest.java b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerUpsertTest.java index 6b9ba9b..6f6dbc8 100644 --- a/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerUpsertTest.java +++ b/debezium-server-databend-sink/src/test/java/io/debezium/databend/DatabendChangeConsumerUpsertTest.java @@ -51,9 +51,9 @@ public void testSimpleUpload() throws Exception { records.add(TestChangeEvent.of(dest, 3, "c")); consumer.handleBatch(records, TestUtil.getCommitter()); // check that its consumed! - ResultSet rs = getDatabendTableData("select * from public.debeziumcdc_customers_upsert"); + ResultSet rs = getDatabendTableData("select * from public.customers_upsert"); Assertions.assertEquals(getResultSetRowCount(rs), 3); - ResultSet rs1 = getDatabendTableData("select * from public.debeziumcdc_customers_upsert where id =3"); + ResultSet rs1 = getDatabendTableData("select * from public.customers_upsert where id =3"); if (rs1.next()) { int id = rs1.getInt("id"); Assertions.assertEquals(3, id); @@ -68,13 +68,13 @@ public void testSimpleUpload() throws Exception { records.add(TestChangeEvent.of(dest, 3, "u", "UpdatednameV1")); records.add(TestChangeEvent.of(dest, 4, "c")); consumer.handleBatch(records, TestUtil.getCommitter()); - ResultSet rsR = getDatabendTableData("select * from public.debeziumcdc_customers_upsert where id = 1 AND __op= 'r'"); + ResultSet rsR = getDatabendTableData("select * from public.customers_upsert where id = 1 AND __op= 'r'"); Assertions.assertEquals(getResultSetRowCount(rsR), 1); - ResultSet rsD = getDatabendTableData("select * from public.debeziumcdc_customers_upsert where id = 2 AND __op= 'd'"); + ResultSet rsD = getDatabendTableData("select * from public.customers_upsert where id = 2 AND __op= 'd'"); Assertions.assertEquals(getResultSetRowCount(rsD), 1); - ResultSet rsU = getDatabendTableData("select * from public.debeziumcdc_customers_upsert where id = 3 AND __op= 'u'"); + ResultSet rsU = getDatabendTableData("select * from public.customers_upsert where id = 3 AND __op= 'u'"); Assertions.assertEquals(getResultSetRowCount(rsU), 1); - ResultSet rsUName = getDatabendTableData("select * from public.debeziumcdc_customers_upsert where id = 3 AND first_name= 'UpdatednameV1'"); + ResultSet rsUName = getDatabendTableData("select * from public.customers_upsert where id = 3 AND first_name= 'UpdatednameV1'"); Assertions.assertEquals(getResultSetRowCount(rsUName), 1); }