Search in sources :

Example 26 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testOr.

@Test
public void testOr() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1' || F2 == 'v2')");
    visitor.visit(query, null);
    Assert.assertEquals("((!(F1 == 'v1') && !(F2 == 'v2')))", JexlStringBuildingVisitor.buildQuery(query));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 27 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testNestedOrMixedCancels.

@Test
public void testNestedOrMixedCancels() 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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 28 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testBoundedRangeNoPropagation.

@Test
public void testBoundedRangeNoPropagation() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F1 <= 'v2'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("F3 == 'v3' || !((_Bounded_ = true) && (F1 >= 'v1' && F1 <= 'v2'))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 29 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testEvaluationOnlyPropertyMarkerPropagate.

@Test
public void testEvaluationOnlyPropertyMarkerPropagate() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!((_Eval_ = true) && (F1 == 'v1' || F2 == 'v2'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("((_Eval_ = true) && ((!(F1 == 'v1') && !(F2 == 'v2'))))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 30 with ParseException

use of org.apache.commons.jexl2.parser.ParseException in project datawave by NationalSecurityAgency.

the class PushdownNegationVisitorTest method testMixedBoundedRanges.

@Test
public void testMixedBoundedRanges() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("(F3 == 'v3' || !(((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2')) || !((_Bounded_ = true) && (F1 >= 'v1' && F1 <= 'v2'))))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("(F3 == 'v3' || ((!(((_Bounded_ = true) && (F1 >= 'v1' && F2 <= 'v2'))) && (((_Bounded_ = true) && (F1 >= 'v1' && F1 <= 'v2'))))))", JexlStringBuildingVisitor.buildQuery(result));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Aggregations

ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)258 Test (org.junit.Test)214 JexlNode (org.apache.commons.jexl2.parser.JexlNode)56 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)36 Date (java.util.Date)33 ParseException (org.apache.commons.jexl2.parser.ParseException)18 HashSet (java.util.HashSet)14 Key (org.apache.accumulo.core.data.Key)9 ArrayList (java.util.ArrayList)7 DatawaveFatalQueryException (datawave.query.exceptions.DatawaveFatalQueryException)6 IOException (java.io.IOException)5 ASTERNode (org.apache.commons.jexl2.parser.ASTERNode)5 MockMetadataHelper (datawave.query.util.MockMetadataHelper)4 PartialKey (org.apache.accumulo.core.data.PartialKey)4 Document (datawave.query.attributes.Document)3 JexlEvaluation (datawave.query.function.JexlEvaluation)3 DatawaveJexlContext (datawave.query.jexl.DatawaveJexlContext)3 DefaultArithmetic (datawave.query.jexl.DefaultArithmetic)3 StringReader (java.io.StringReader)3 AbstractMap (java.util.AbstractMap)3