use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class RewriteNegationsVisitorTest method testSingleLE.
@Test
public void testSingleLE() throws ParseException {
String queryString = "FOO <= BAR";
String expectedQuery = "FOO <= BAR";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
assertEquals(expectedQuery, negatedQuery);
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class RewriteNegationsVisitorTest method testSingleGE.
@Test
public void testSingleGE() throws ParseException {
String queryString = "FOO >= BAR";
String expectedQuery = "FOO >= BAR";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
assertEquals(expectedQuery, negatedQuery);
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class RewriteNegationsVisitorTest method testSingleNR.
// Test a Negated Regex node
@Test
public void testSingleNR() throws ParseException {
String queryString = "FOO !~ BAR";
String expectedQuery = "!(FOO =~ BAR)";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
assertEquals(expectedQuery, negatedQuery);
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class RewriteNegationsVisitorTest method testConjunctionOfSingleNEAndEQ.
// Test AST such that (!A & B)
@Test
public void testConjunctionOfSingleNEAndEQ() throws ParseException {
String queryString = "FOO != BAR && BAR == FOO";
String expectedQuery = "!(FOO == BAR) && BAR == FOO";
ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
assertEquals(expectedQuery, negatedQuery);
}
use of org.apache.commons.jexl3.parser.ASTJexlScript 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);
}
Aggregations