use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class QueryPruningVisitorTest method NRTest.
@Test
public void NRTest() throws ParseException {
String query = "FIELD !~ 'x'";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals(QueryPruningVisitor.TruthState.UNKNOWN, 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 notFalseTest.
@Test
public void notFalseTest() throws ParseException {
String query = "!false";
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 NRNoFieldTest.
@Test
public void NRNoFieldTest() throws ParseException {
String query = "_NOFIELD_ !~ 'x'";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals(QueryPruningVisitor.TruthState.FALSE, 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 falseDoubleAndRewriteTest.
@Test
public void falseDoubleAndRewriteTest() throws ParseException {
String query = "FIELD1 == 'x' && _NOFIELD_ == 'y' && FIELD2 == 'y'";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
JexlNode reduced = QueryPruningVisitor.reduce(script, true);
JexlEvaluation jexlEvaluation = new JexlEvaluation(JexlStringBuildingVisitor.buildQuery(reduced), new DefaultArithmetic());
boolean jexlState = jexlEvaluation.apply(new Tuple3<>(new Key(), new Document(), new DatawaveJexlContext()));
Assert.assertFalse(jexlState);
Assert.assertEquals("false", JexlStringBuildingVisitor.buildQuery(reduced));
Assert.assertEquals("false", JexlStringBuildingVisitor.buildQuery(QueryPruningVisitor.reduce(script, false)));
Assert.assertTrue(logAppender.getMessages().size() == 2);
Assert.assertEquals("Pruning FIELD1 == 'x' && _NOFIELD_ == 'y' && FIELD2 == 'y' to false", logAppender.getMessages().get(0));
Assert.assertEquals("Query before prune: FIELD1 == 'x' && _NOFIELD_ == 'y' && FIELD2 == 'y'\nQuery after prune: false", logAppender.getMessages().get(1));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class QueryPruningVisitorTest method branchedTest.
@Test
public void branchedTest() throws ParseException {
String query = "FIELD1 == 'x' || (_NOFIELD_ == 'y' && FIELD2 == 'z')";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(query);
Assert.assertEquals(QueryPruningVisitor.TruthState.UNKNOWN, QueryPruningVisitor.getState(script));
Assert.assertEquals(0, logAppender.getMessages().size(), logAppender.getMessages().size());
}
Aggregations