use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class QueryPruningVisitorTest method unchangedRewriteTest.
@Test
public void unchangedRewriteTest() throws ParseException {
String subtree = "FIELD1 == 'y' && FIELD2 == 'z'";
String query = "FIELD1 == 'x' || (" + subtree + ")";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
JexlNode reduced = QueryPruningVisitor.reduce(script, true);
Assert.assertEquals(query, JexlStringBuildingVisitor.buildQuery(reduced));
Assert.assertEquals(query, JexlStringBuildingVisitor.buildQuery(QueryPruningVisitor.reduce(script, false)));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class QueryPruningVisitorTest method trueOrTest.
@Test
public void trueOrTest() throws ParseException {
String query = "true || _NOFIELD_ == 'y'";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals(QueryPruningVisitor.TruthState.TRUE, QueryPruningVisitor.getState(script));
Assert.assertEquals(0, logAppender.getMessages().size(), logAppender.getMessages().size());
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class QueryPruningVisitorTest method nestedMarkerBoundedRangeTest.
@Test
public void nestedMarkerBoundedRangeTest() throws ParseException {
String query = "FIELD == 'b' || ((Assignment = true) && (FIELD > 'x' && FIELD < 'z'))";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals(QueryPruningVisitor.TruthState.UNKNOWN, QueryPruningVisitor.getState(script));
Assert.assertEquals(query, JexlStringBuildingVisitor.buildQuery(QueryPruningVisitor.reduce(script, false)));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class JexlStringBuildingVisitorTest method testNegativeNumber.
@Test
public void testNegativeNumber() throws ParseException {
String query = "BLAH == -2";
JexlNode node = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals("BLAH == -2", JexlStringBuildingVisitor.buildQuery(node));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testTripleNegationNEq.
@Test
public void testTripleNegationNEq() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("!!!(F1 != 'v1')");
visitor.visit(query, null);
Assert.assertEquals("(F1 == 'v1')", JexlStringBuildingVisitor.buildQuery(query));
}
Aggregations