Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dseweryn committed Dec 19, 2024
1 parent 82ab2f1 commit 9fb6116
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/test/java/com/snowflake/kafka/connector/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,25 @@ public void testGenerateTableName() {
Map<String, String> topic2table = Utils.parseTopicToTableMap("ab@cd:abcd, 1234:_1234");

Utils.GeneratedName generatedTableName1 = Utils.generateTableName("ab@cd", topic2table);
Assert.assertEquals("ab@cd", generatedTableName1.name);
Assert.assertEquals("abcd", generatedTableName1.name);
Assert.assertTrue(generatedTableName1.isNameFromMap);

Utils.GeneratedName generatedTableName2 = Utils.generateTableName("1234", topic2table);
Assert.assertEquals("_1234", generatedTableName2.name);
Assert.assertTrue(generatedTableName2.isNameFromMap);

TestUtils.assertError(SnowflakeErrors.ERROR_0020, () -> Utils.generateTableName("", topic2table));
TestUtils.assertError(SnowflakeErrors.ERROR_0020, () -> Utils.generateTableName(null, topic2table));

String topic = "bc*def";
Utils.GeneratedName generatedTableName2 = Utils.generateTableName(topic, topic2table);
Assert.assertEquals("bc_def_" + Math.abs(topic.hashCode()), generatedTableName2.name);
Assert.assertFalse(generatedTableName2.isNameFromMap);

topic = "12345";
Utils.GeneratedName generatedTableName3 = Utils.generateTableName(topic, topic2table);
Assert.assertEquals("_12345_" + Math.abs(topic.hashCode()), generatedTableName3.name);
Assert.assertEquals("bc_def_" + Math.abs(topic.hashCode()), generatedTableName3.name);
Assert.assertFalse(generatedTableName3.isNameFromMap);

topic = "12345";
Utils.GeneratedName generatedTableName4 = Utils.generateTableName(topic, topic2table);
Assert.assertEquals("_12345_" + Math.abs(topic.hashCode()), generatedTableName4.name);
Assert.assertFalse(generatedTableName4.isNameFromMap);
}

@Test
Expand Down

0 comments on commit 9fb6116

Please sign in to comment.