diff --git a/src/test/java/com/snowflake/kafka/connector/UtilsTest.java b/src/test/java/com/snowflake/kafka/connector/UtilsTest.java index 422007086..96d4458d1 100644 --- a/src/test/java/com/snowflake/kafka/connector/UtilsTest.java +++ b/src/test/java/com/snowflake/kafka/connector/UtilsTest.java @@ -117,21 +117,25 @@ public void testGenerateTableName() { Map 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