use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testPartialBoundedRangePropagation.
@Test
public void testPartialBoundedRangePropagation() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2'))");
JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
Assert.assertEquals("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2'))", JexlStringBuildingVisitor.buildQuery(result));
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testGuarantees.
/**
* Same as testNestedAnd but validate that the original is not modified
*
* @throws ParseException
*/
@Test
public void testGuarantees() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1' && F2 == 'v2' && (F3 == 'v3' || F4 == 'v4'))");
String orig = JexlStringBuildingVisitor.buildQuery(query);
JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
Assert.assertEquals("((!(F1 == 'v1') || !(F2 == 'v2') || (((!(F3 == 'v3') && !(F4 == 'v4'))))))", JexlStringBuildingVisitor.buildQuery(result));
Assert.assertNotEquals(orig, JexlStringBuildingVisitor.buildQuery(result));
Assert.assertEquals(orig, JexlStringBuildingVisitor.buildQuery(query));
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testAndNE.
@Test
public void testAndNE() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 != 'v1' && F2 != 'v2')");
visitor.visit(query, null);
Assert.assertEquals("(((F1 == 'v1') || (F2 == 'v2')))", JexlStringBuildingVisitor.buildQuery(query));
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testDoubleNegationEq.
@Test
public void testDoubleNegationEq() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("!!(F1 == 'v1')");
visitor.visit(query, null);
Assert.assertEquals("(F1 == 'v1')", JexlStringBuildingVisitor.buildQuery(query));
}
use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.
the class PushdownNegationVisitorTest method testNestedAnd.
@Test
public void testNestedAnd() throws ParseException {
ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1' && F2 == 'v2' && (F3 == 'v3' || F4 == 'v4'))");
JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
Assert.assertEquals("((!(F1 == 'v1') || !(F2 == 'v2') || (((!(F3 == 'v3') && !(F4 == 'v4'))))))", JexlStringBuildingVisitor.buildQuery(result));
}
Aggregations