From 267dfc6ba0eddd78d5913663496c65eaa1aa3c0b Mon Sep 17 00:00:00 2001 From: Srinivasulu Punuru Date: Wed, 10 Jan 2018 17:14:03 -0800 Subject: [PATCH] Fix for the TestSamzaSqlApplicationConfig.testConfigInit Currently testConfigInit checks for a hardcoded number for udfs. Whenever a new UDF is added, This test is going to fail if it is not updated. Changed the test to validate the number of udfs based on the config that is passed. Author: Srinivasulu Punuru Reviewers: Prateek Maheshwari Closes #403 from srinipunuru/testfix.1 --- .../org/apache/samza/sql/TestSamzaSqlApplicationConfig.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/samza-sql/src/test/java/org/apache/samza/sql/TestSamzaSqlApplicationConfig.java b/samza-sql/src/test/java/org/apache/samza/sql/TestSamzaSqlApplicationConfig.java index 0b85339928..1c5fc41f62 100644 --- a/samza-sql/src/test/java/org/apache/samza/sql/TestSamzaSqlApplicationConfig.java +++ b/samza-sql/src/test/java/org/apache/samza/sql/TestSamzaSqlApplicationConfig.java @@ -24,6 +24,7 @@ import junit.framework.Assert; import org.apache.samza.SamzaException; import org.apache.samza.config.MapConfig; +import org.apache.samza.sql.impl.ConfigBasedUdfResolver; import org.apache.samza.sql.interfaces.SqlSystemStreamConfig; import org.apache.samza.sql.runner.SamzaSqlApplicationConfig; import org.apache.samza.sql.testutil.SamzaSqlTestConfig; @@ -36,9 +37,11 @@ public class TestSamzaSqlApplicationConfig { public void testConfigInit() { Map config = SamzaSqlTestConfig.fetchStaticConfigsWithFactories(10); config.put(SamzaSqlApplicationConfig.CFG_SQL_STMT, "Insert into testavro.COMPLEX1 select * from testavro.SIMPLE1"); + String configUdfResolverDomain = String.format(SamzaSqlApplicationConfig.CFG_FMT_UDF_RESOLVER_DOMAIN, "config"); + int numUdfs = config.get(configUdfResolverDomain + ConfigBasedUdfResolver.CFG_UDF_CLASSES).split(",").length; SamzaSqlApplicationConfig samzaSqlApplicationConfig = new SamzaSqlApplicationConfig(new MapConfig(config)); Assert.assertEquals(1, samzaSqlApplicationConfig.getQueryInfo().size()); - Assert.assertEquals(3, samzaSqlApplicationConfig.getUdfMetadata().size()); + Assert.assertEquals(numUdfs, samzaSqlApplicationConfig.getUdfMetadata().size()); Assert.assertEquals(1, samzaSqlApplicationConfig.getInputSystemStreamConfigBySource().size()); Assert.assertEquals(1, samzaSqlApplicationConfig.getOutputSystemStreamConfigsBySource().size()); }