use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class RewriteNegationsVisitorTest method testSingleEQWithNestedConjunctionOfTwoNE.
// Test AST such that (A && (!B && !C))
@Test
public void testSingleEQWithNestedConjunctionOfTwoNE() throws ParseException {
String queryString = "FOO == BAR && (BAR != FOO && BAR != CAT)";
String expectedQuery = "FOO == BAR && (!(BAR == FOO) && !(BAR == CAT))";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
String errMsg = "Failed for query structure like (A && (!B && !C))";
assertEquals(errMsg, expectedQuery, negatedQuery);
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class RootNegationCheckVisitorTest method testWrappedNegatedMarker.
@Test
public void testWrappedNegatedMarker() throws ParseException {
ASTJexlScript script = JexlASTHelper.parseJexlQuery("!((_Delayed_ = true) && (FOO == 'bar' && FOO == 'baz'))");
Assert.assertTrue(RootNegationCheckVisitor.hasTopLevelNegation(script));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class RootNegationCheckVisitorTest method testNegatedMarkerOneLeaf.
@Test
public void testNegatedMarkerOneLeaf() throws ParseException {
ASTJexlScript script = JexlASTHelper.parseJexlQuery("((_Delayed_ = true) && !(FOO != 'bar' && FOO == 'baz'))");
Assert.assertFalse(RootNegationCheckVisitor.hasTopLevelNegation(script));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class RootNegationCheckVisitorTest method testWrappedNegation.
@Test
public void testWrappedNegation() throws ParseException {
ASTJexlScript script = JexlASTHelper.parseJexlQuery("!(FOO == 'bar')");
Assert.assertTrue(RootNegationCheckVisitor.hasTopLevelNegation(script));
}
use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.
the class RootNegationCheckVisitorTest method testNegatedOneLeafAnd.
@Test
public void testNegatedOneLeafAnd() throws ParseException {
ASTJexlScript script = JexlASTHelper.parseJexlQuery("!(FOO != 'bar' && FOO == 'baz')");
Assert.assertFalse(RootNegationCheckVisitor.hasTopLevelNegation(script));
}
Aggregations