use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method jexlNodeInequality.
@Test
public void jexlNodeInequality() throws Exception {
ASTJexlScript one = JexlASTHelper.parseJexlQuery("FOO == '1'");
ASTJexlScript two = JexlASTHelper.parseJexlQuery("'1' == '1'");
Assert.assertFalse(JexlASTHelper.equals(one, two));
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method test1.
@Test
public void test1() throws Exception {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == '1' and (FOO == '2' and (FOO == '3' or FOO == '4'))");
List<ASTEQNode> eqNodes = JexlASTHelper.getEQNodes(query);
Map<String, Boolean> expectations = Maps.newHashMap();
expectations.put("1", false);
expectations.put("2", false);
expectations.put("3", true);
expectations.put("4", true);
for (JexlNode eqNode : eqNodes) {
String value = JexlASTHelper.getLiteralValue(eqNode).toString();
Assert.assertTrue(expectations.containsKey(value));
Assert.assertEquals(expectations.get(value), JexlASTHelper.isWithinOr(eqNode));
}
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method test3.
@Test
public void test3() throws Exception {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == '1'");
List<ASTEQNode> eqNodes = JexlASTHelper.getEQNodes(query);
Map<String, Boolean> expectations = Maps.newHashMap();
expectations.put("1", false);
for (JexlNode eqNode : eqNodes) {
String value = JexlASTHelper.getLiteralValue(eqNode).toString();
Assert.assertTrue(expectations.containsKey(value));
Assert.assertEquals(expectations.get(value), JexlASTHelper.isWithinOr(eqNode));
}
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method testFindRange.
@Test
public void testFindRange() throws Exception {
ASTJexlScript script = JexlASTHelper.parseJexlQuery("((_Bounded_ = true) && (A < 'b' && A > 'a')) && !(FOO == 'bar')");
LiteralRange range = JexlASTHelper.findRange().getRange(script.jjtGetChild(0));
Assert.assertNull(range);
script = JexlASTHelper.parseJexlQuery("(A < 5 && A > 1)");
range = JexlASTHelper.findRange().getRange(script.jjtGetChild(0));
Assert.assertNull(range);
script = JexlASTHelper.parseJexlQuery("((_Bounded_ = true) && (A < 5 && A > 1))");
range = JexlASTHelper.findRange().getRange(script.jjtGetChild(0));
Assert.assertNotNull(range);
Assert.assertNotNull(range.getLowerNode());
Assert.assertNotNull(range.getUpperNode());
Assert.assertEquals(1, range.getLower());
Assert.assertEquals(5, range.getUpper());
Assert.assertFalse(range.isLowerInclusive());
Assert.assertFalse(range.isUpperInclusive());
script = JexlASTHelper.parseJexlQuery("((_Bounded_ = true) && (A <= 5 && A >= 1))");
range = JexlASTHelper.findRange().getRange(script.jjtGetChild(0));
Assert.assertNotNull(range);
Assert.assertNotNull(range.getLowerNode());
Assert.assertNotNull(range.getUpperNode());
Assert.assertEquals(1, range.getLower());
Assert.assertEquals(5, range.getUpper());
Assert.assertTrue(range.isLowerInclusive());
Assert.assertTrue(range.isUpperInclusive());
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class JexlASTHelperTest method sameJexlNodeEquality.
@Test
public void sameJexlNodeEquality() throws Exception {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("FOO == '1'");
Assert.assertTrue(JexlASTHelper.equals(query, query));
}
Aggregations