From b90987bbeca346301a18aea2a7913a072fde4a3a Mon Sep 17 00:00:00 2001 From: Otto Fowler Date: Fri, 17 Feb 2017 12:06:58 -0500 Subject: [PATCH] METRON-724 add [IN] to the documented keywords that require escaping add in unit test --- metron-platform/metron-common/README.md | 4 ++-- .../metron/common/stellar/StellarTest.java | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/metron-platform/metron-common/README.md b/metron-platform/metron-common/README.md index 872b320656..067bf8d3d2 100644 --- a/metron-platform/metron-common/README.md +++ b/metron-platform/metron-common/README.md @@ -35,9 +35,9 @@ The following keywords need to be single quote escaped in order to be used in St | | | | | | | :-----------: | :-----------: | :---------: | :---------: | :---------: | | not | else | exists | if | then | -| and | or | == | != | \< | +| and | or | in | == | != | | \<= | \> | \>= | \+ | \- | -| ? | \* | / | , | | +| \< | ? | \* | / | , | Using parens such as: "foo" : "\" requires escaping; "foo": "\'\\'" diff --git a/metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/StellarTest.java b/metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/StellarTest.java index dabf2938ac..6ff3d8a8e8 100644 --- a/metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/StellarTest.java +++ b/metron-platform/metron-common/src/test/java/org/apache/metron/common/stellar/StellarTest.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import org.apache.commons.lang3.StringUtils; +import org.apache.metron.common.dsl.ParseException; import org.apache.metron.common.dsl.Stellar; import org.apache.metron.common.dsl.StellarFunction; import org.junit.Assert; @@ -287,6 +288,26 @@ public void testIfThenElse() { } } + @Test + public void testInNotIN(){ + HashMap variables = new HashMap<>(); + boolean thrown = false; + try{ + run("in in ['','in']" ,variables ); + }catch(ParseException pe) { + thrown = true; + } + Assert.assertTrue(thrown); + thrown = false; + + try{ + Assert.assertEquals(true,run("'in' in ['','in']" ,variables )); + }catch(ParseException pe) { + thrown = true; + } + Assert.assertFalse(thrown); + } + @Test public void testHappyPath() { String query = "TO_UPPER(TRIM(foo))";