Search in sources :

Example 31 with ParseException

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

the class PushdownNegationVisitorTest method testER.

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

Example 32 with ParseException

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

Example 33 with ParseException

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

Example 34 with ParseException

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

Example 35 with ParseException

use of org.apache.commons.jexl2.parser.ParseException 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));
}
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