Search in sources :

Example 56 with ParseException

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

Example 57 with ParseException

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

Example 58 with ParseException

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

Example 59 with ParseException

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

Example 60 with ParseException

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));
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) 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