Repository: metron Updated Branches: refs/heads/master ec959d20e -> 14bcc0389
METRON-1011 Stellar ENRICHMENT functions should enforce submission of 4 parameters (jasper-k via ottobackwards) closes apache/metron#628 Project: http://git-wip-us.apache.org/repos/asf/metron/repo Commit: http://git-wip-us.apache.org/repos/asf/metron/commit/14bcc038 Tree: http://git-wip-us.apache.org/repos/asf/metron/tree/14bcc038 Diff: http://git-wip-us.apache.org/repos/asf/metron/diff/14bcc038 Branch: refs/heads/master Commit: 14bcc0389431879b1d97ae53f8a8a6e7079bed46 Parents: ec959d2 Author: jasper-k <jknu...@hortonworks.com> Authored: Tue Aug 1 11:54:19 2017 -0400 Committer: otto <o...@apache.org> Committed: Tue Aug 1 11:54:19 2017 -0400 ---------------------------------------------------------------------- .../enrichment/stellar/SimpleHBaseEnrichmentFunctions.java | 8 ++++---- .../stellar/SimpleHBaseEnrichmentFunctionsTest.java | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/metron/blob/14bcc038/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java ---------------------------------------------------------------------- diff --git a/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java b/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java index 1368631..f8cdf36 100644 --- a/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java +++ b/metron-platform/metron-enrichment/src/main/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctions.java @@ -140,8 +140,8 @@ public class SimpleHBaseEnrichmentFunctions { if(!initialized) { return false; } - if(args.size() < 2) { - throw new IllegalStateException("Requires at least an enrichment type and indicator"); + if(args.size() != 4) { + throw new IllegalStateException("All parameters are mandatory, submit 'enrichment type', 'indicator', 'nosql_table' and 'column_family'"); } int i = 0; String enrichmentType = (String) args.get(i++); @@ -217,8 +217,8 @@ public class SimpleHBaseEnrichmentFunctions { if(!initialized) { return false; } - if(args.size() < 2) { - throw new IllegalStateException("Requires at least an enrichment type and indicator"); + if(args.size() != 4) { + throw new IllegalStateException("All parameters are mandatory, submit 'enrichment type', 'indicator', 'nosql_table' and 'column_family'"); } int i = 0; String enrichmentType = (String) args.get(i++); http://git-wip-us.apache.org/repos/asf/metron/blob/14bcc038/metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctionsTest.java ---------------------------------------------------------------------- diff --git a/metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctionsTest.java b/metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctionsTest.java index b7668f3..7ed0320 100644 --- a/metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctionsTest.java +++ b/metron-platform/metron-enrichment/src/test/java/org/apache/metron/enrichment/stellar/SimpleHBaseEnrichmentFunctionsTest.java @@ -22,8 +22,10 @@ import com.google.common.collect.ImmutableMap; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.client.HTableInterface; import org.apache.metron.stellar.dsl.Context; +import org.apache.metron.stellar.dsl.ParseException; import org.apache.metron.stellar.dsl.StellarFunctions; import org.apache.metron.stellar.common.StellarProcessor; + import org.apache.metron.enrichment.converter.EnrichmentHelper; import org.apache.metron.enrichment.converter.EnrichmentKey; import org.apache.metron.enrichment.converter.EnrichmentValue; @@ -125,4 +127,10 @@ public class SimpleHBaseEnrichmentFunctionsTest { Map<String, Object> out = (Map<String, Object>) result; Assert.assertTrue(out.isEmpty()); } + + @Test(expected = ParseException.class) + public void testProvidedParameters() throws Exception { + String stellar = "ENRICHMENT_GET('et', indicator)"; + Object result = run(stellar, ImmutableMap.of("indicator", "indicator7")); + } }