Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
hantmac committed Dec 14, 2023
1 parent c7e8b26 commit 74cfa12
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}

Expand Down

0 comments on commit 74cfa12

Please sign in to comment.