Search in sources :

Example 6 with OOPathExpr

use of org.drools.mvel.parser.ast.expr.OOPathExpr in project drools by kiegroup.

the class DroolsMvelParserTest method testOOPathExprWithMultipleCondition.

@Test
public void testOOPathExprWithMultipleCondition() {
    String expr = "$address : /address[street == \"Elm\",city == \"Big City\"]";
    DrlxExpression drlx = parseExpression(parser, expr);
    Expression expression = drlx.getExpr();
    assertTrue(expression instanceof OOPathExpr);
    assertEquals(expr, printNode(drlx));
}
Also used : DrlxParser.parseExpression(org.drools.mvel.parser.DrlxParser.parseExpression) Expression(com.github.javaparser.ast.expr.Expression) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) OOPathExpr(org.drools.mvel.parser.ast.expr.OOPathExpr) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) Test(org.junit.Test)

Example 7 with OOPathExpr

use of org.drools.mvel.parser.ast.expr.OOPathExpr in project drools by kiegroup.

the class DroolsMvelParserTest method testOOPathExpr.

@Test
public void testOOPathExpr() {
    String expr = "/wife/children[age > 10]/toys";
    DrlxExpression drlx = parseExpression(parser, expr);
    Expression expression = drlx.getExpr();
    assertTrue(expression instanceof OOPathExpr);
    assertEquals(expr, printNode(drlx));
}
Also used : DrlxParser.parseExpression(org.drools.mvel.parser.DrlxParser.parseExpression) Expression(com.github.javaparser.ast.expr.Expression) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) OOPathExpr(org.drools.mvel.parser.ast.expr.OOPathExpr) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) Test(org.junit.Test)

Example 8 with OOPathExpr

use of org.drools.mvel.parser.ast.expr.OOPathExpr in project drools by kiegroup.

the class DroolsMvelParserTest method testOOPathExprWithDeclaration.

@Test
public void testOOPathExprWithDeclaration() {
    String expr = "$toy : /wife/children[age > 10]/toys";
    DrlxExpression drlx = parseExpression(parser, expr);
    assertEquals("$toy", drlx.getBind().asString());
    Expression expression = drlx.getExpr();
    assertTrue(expression instanceof OOPathExpr);
    assertEquals(expr, printNode(drlx));
}
Also used : DrlxParser.parseExpression(org.drools.mvel.parser.DrlxParser.parseExpression) Expression(com.github.javaparser.ast.expr.Expression) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) OOPathExpr(org.drools.mvel.parser.ast.expr.OOPathExpr) DrlxExpression(org.drools.mvel.parser.ast.expr.DrlxExpression) Test(org.junit.Test)

Aggregations

Expression (com.github.javaparser.ast.expr.Expression)8 OOPathExpr (org.drools.mvel.parser.ast.expr.OOPathExpr)8 DrlxExpression (org.drools.mvel.parser.ast.expr.DrlxExpression)7 DrlxParser.parseExpression (org.drools.mvel.parser.DrlxParser.parseExpression)5 Test (org.junit.Test)5 BinaryExpr (com.github.javaparser.ast.expr.BinaryExpr)3 MethodCallExpr (com.github.javaparser.ast.expr.MethodCallExpr)3 NameExpr (com.github.javaparser.ast.expr.NameExpr)3 DrlNameExpr (org.drools.mvel.parser.ast.expr.DrlNameExpr)3 HalfBinaryExpr (org.drools.mvel.parser.ast.expr.HalfBinaryExpr)3 OOPathChunk (org.drools.mvel.parser.ast.expr.OOPathChunk)3 NodeList (com.github.javaparser.ast.NodeList)2 CastExpr (com.github.javaparser.ast.expr.CastExpr)2 EnclosedExpr (com.github.javaparser.ast.expr.EnclosedExpr)2 FieldAccessExpr (com.github.javaparser.ast.expr.FieldAccessExpr)2 LiteralExpr (com.github.javaparser.ast.expr.LiteralExpr)2 NullLiteralExpr (com.github.javaparser.ast.expr.NullLiteralExpr)2 ObjectCreationExpr (com.github.javaparser.ast.expr.ObjectCreationExpr)2 SimpleName (com.github.javaparser.ast.expr.SimpleName)2 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)2