Search in sources :

Example 66 with ASTJexlScript

use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.

the class RewriteNegationsVisitorTest method testSingleLE.

@Test
public void testSingleLE() throws ParseException {
    String queryString = "FOO <= BAR";
    String expectedQuery = "FOO <= BAR";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
    String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
    assertEquals(expectedQuery, negatedQuery);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 67 with ASTJexlScript

use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.

the class RewriteNegationsVisitorTest method testSingleGE.

@Test
public void testSingleGE() throws ParseException {
    String queryString = "FOO >= BAR";
    String expectedQuery = "FOO >= BAR";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
    String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
    assertEquals(expectedQuery, negatedQuery);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 68 with ASTJexlScript

use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.

the class RewriteNegationsVisitorTest method testSingleNR.

// Test a Negated Regex node
@Test
public void testSingleNR() throws ParseException {
    String queryString = "FOO !~ BAR";
    String expectedQuery = "!(FOO =~ BAR)";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
    String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
    assertEquals(expectedQuery, negatedQuery);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 69 with ASTJexlScript

use of org.apache.commons.jexl3.parser.ASTJexlScript in project datawave by NationalSecurityAgency.

the class RewriteNegationsVisitorTest method testConjunctionOfSingleNEAndEQ.

// Test AST such that (!A & B)
@Test
public void testConjunctionOfSingleNEAndEQ() throws ParseException {
    String queryString = "FOO != BAR && BAR == FOO";
    String expectedQuery = "!(FOO == BAR) && BAR == FOO";
    ASTJexlScript script = JexlASTHelper.parseJexlQuery(queryString);
    ASTJexlScript negatedScript = RewriteNegationsVisitor.rewrite(script);
    String negatedQuery = JexlStringBuildingVisitor.buildQuery(negatedScript);
    assertEquals(expectedQuery, negatedQuery);
}
Also used : ASTJexlScript(org.apache.commons.jexl2.parser.ASTJexlScript) Test(org.junit.Test)

Example 70 with ASTJexlScript

use of org.apache.commons.jexl3.parser.ASTJexlScript 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)

Aggregations

ASTJexlScript (org.apache.commons.jexl2.parser.ASTJexlScript)457 Test (org.junit.Test)385 Key (org.apache.accumulo.core.data.Key)69 JexlNode (org.apache.commons.jexl2.parser.JexlNode)61 HashSet (java.util.HashSet)50 ShardQueryConfiguration (datawave.query.config.ShardQueryConfiguration)48 MockMetadataHelper (datawave.query.util.MockMetadataHelper)40 Type (datawave.data.type.Type)38 LcNoDiacriticsType (datawave.data.type.LcNoDiacriticsType)37 ArrayList (java.util.ArrayList)37 ExpressionFilter (datawave.query.jexl.visitors.EventDataQueryExpressionVisitor.ExpressionFilter)36 ScannerFactory (datawave.query.tables.ScannerFactory)35 Date (java.util.Date)35 NoOpType (datawave.data.type.NoOpType)34 NumberType (datawave.data.type.NumberType)34 AbstractMap (java.util.AbstractMap)32 Range (org.apache.accumulo.core.data.Range)30 Value (org.apache.accumulo.core.data.Value)29 RangeFactoryForTests.makeTestRange (datawave.common.test.utils.query.RangeFactoryForTests.makeTestRange)26 QueryPlan (datawave.query.planner.QueryPlan)26