Search in sources :

Example 66 with ParseException

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

the class UniqueExpressionTermsVisitorTest method visitAndValidate.

private void visitAndValidate(String original, String expected) throws ParseException {
    ASTJexlScript originalScript = JexlASTHelper.parseJexlQuery(original);
    // Remove duplicate terms from within expressions.
    ASTJexlScript visitedScript = UniqueExpressionTermsVisitor.enforce(originalScript);
    // Verify the script is as expected, and has a valid lineage.
    JexlNodeAssert.assertThat(visitedScript).isEqualTo(expected).hasValidLineage();
    // Verify the original script was not modified, and still has a valid lineage.
    JexlNodeAssert.assertThat(originalScript).isEqualTo(original).hasValidLineage();
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript)

Example 67 with ParseException

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

the class ValidComparisonVisitorTest method testMethodNode.

@Test
public void testMethodNode() throws ParseException {
    String queryString = "AG.greaterThan(39).size() >= 1";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ValidComparisonVisitor.check(script);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 68 with ParseException

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

the class ValidComparisonVisitorTest method testMulNode.

@Test
public void testMulNode() throws ParseException {
    String queryString = "1*3*1 == 3";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ValidComparisonVisitor.check(script);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 69 with ParseException

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

the class ValidComparisonVisitorTest method testInvalidNR.

@Test(expected = DatawaveFatalQueryException.class)
public void testInvalidNR() throws ParseException {
    String queryString = "'BAR' !~ 'foo'";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ValidComparisonVisitor.check(script);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 70 with ParseException

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

the class ValidComparisonVisitorTest method testInvalidEQ.

@Test(expected = DatawaveFatalQueryException.class)
public void testInvalidEQ() throws ParseException {
    String queryString = "'BAR' == 1";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ValidComparisonVisitor.check(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