Search in sources :

Example 36 with ParseException

use of org.apache.commons.jexl2.parser.ParseException 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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) JexlNode(org.apache.commons.jexl2.parser.JexlNode) Test(org.junit.Test)

Example 37 with ParseException

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

the class PushdownNegationVisitorTest method testNestedAndMixedCancels.

@Test
public void testNestedAndMixedCancels() 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 38 with ParseException

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

the class PushdownNegationVisitorTest method testAnd.

@Test
public void testAnd() 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 39 with ParseException

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

the class PushdownNegationVisitorTest method testExceededTermPropertyMarkerPropagate.

@Test
public void testExceededTermPropertyMarkerPropagate() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!((_Term_ = true) && (F1 == 'v1' || F2 == 'v2'))");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("!((_Term_ = 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 40 with ParseException

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

the class PushdownNegationVisitorTest method testNENotNegated.

@Test
public void testNENotNegated() throws ParseException {
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("!(F1 == 'v1') && F2 != 'v2'");
    JexlNode result = PushdownNegationVisitor.pushdownNegations(query);
    Assert.assertEquals("!(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)

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