Search in sources :

Example 11 with PointFreeExpr

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

the class DroolsMvelParserTest method testDotFreeExprWithTemporalArgs.

@Test
public void testDotFreeExprWithTemporalArgs() {
    String expr = "this after[5ms,8d] $a";
    Expression expression = parseExpression(parser, expr).getExpr();
    assertTrue(expression instanceof PointFreeExpr);
    assertEquals(expr, printNode(expression));
}
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) HalfPointFreeExpr(org.drools.mvel.parser.ast.expr.HalfPointFreeExpr) PointFreeExpr(org.drools.mvel.parser.ast.expr.PointFreeExpr) Test(org.junit.Test)

Example 12 with PointFreeExpr

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

the class DroolsMvelParserTest method testDotFreeExprWithThreeArgsInfinite.

@Test
public void testDotFreeExprWithThreeArgsInfinite() {
    String expr = "this after[*,*,*,2s] $a";
    Expression expression = parseExpression(parser, expr).getExpr();
    assertTrue(expression instanceof PointFreeExpr);
    assertFalse(((PointFreeExpr) expression).isNegated());
    // please note the parsed expression once normalized would take the time unit for milliseconds.
    assertEquals("this after[*,*,*,2s] $a", printNode(expression));
}
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) HalfPointFreeExpr(org.drools.mvel.parser.ast.expr.HalfPointFreeExpr) PointFreeExpr(org.drools.mvel.parser.ast.expr.PointFreeExpr) Test(org.junit.Test)

Example 13 with PointFreeExpr

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

the class DroolsMvelParserTest method testDotFreeExprWithArgsInfinite.

@Test
public void testDotFreeExprWithArgsInfinite() {
    String expr = "this after[5s,*] $a";
    Expression expression = parseExpression(parser, expr).getExpr();
    assertTrue(expression instanceof PointFreeExpr);
    assertFalse(((PointFreeExpr) expression).isNegated());
    // please note the parsed expression once normalized would take the time unit for milliseconds.
    assertEquals("this after[5s,*] $a", printNode(expression));
}
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) HalfPointFreeExpr(org.drools.mvel.parser.ast.expr.HalfPointFreeExpr) PointFreeExpr(org.drools.mvel.parser.ast.expr.PointFreeExpr) Test(org.junit.Test)

Example 14 with PointFreeExpr

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

the class DroolsMvelParserTest method testDotFreeExprWithFourTemporalArgs.

@Test
public void testDotFreeExprWithFourTemporalArgs() {
    String expr = "this includes[1s,1m,1h,1d] $a";
    Expression expression = parseExpression(parser, expr).getExpr();
    assertTrue(expression instanceof PointFreeExpr);
    assertEquals(expr, printNode(expression));
}
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) HalfPointFreeExpr(org.drools.mvel.parser.ast.expr.HalfPointFreeExpr) PointFreeExpr(org.drools.mvel.parser.ast.expr.PointFreeExpr) Test(org.junit.Test)

Aggregations

PointFreeExpr (org.drools.mvel.parser.ast.expr.PointFreeExpr)14 Expression (com.github.javaparser.ast.expr.Expression)13 HalfPointFreeExpr (org.drools.mvel.parser.ast.expr.HalfPointFreeExpr)13 DrlxExpression (org.drools.mvel.parser.ast.expr.DrlxExpression)12 DrlxParser.parseExpression (org.drools.mvel.parser.DrlxParser.parseExpression)10 Test (org.junit.Test)10 NameExpr (com.github.javaparser.ast.expr.NameExpr)4 BinaryExpr (com.github.javaparser.ast.expr.BinaryExpr)3 EnclosedExpr (com.github.javaparser.ast.expr.EnclosedExpr)3 SimpleName (com.github.javaparser.ast.expr.SimpleName)3 StringLiteralExpr (com.github.javaparser.ast.expr.StringLiteralExpr)3 ArrayList (java.util.ArrayList)3 ParseExpressionErrorResult (org.drools.modelcompiler.builder.errors.ParseExpressionErrorResult)3 TypedExpression (org.drools.modelcompiler.builder.generator.TypedExpression)3 ExpressionTyper (org.drools.modelcompiler.builder.generator.expressiontyper.ExpressionTyper)3 TypedExpressionResult (org.drools.modelcompiler.builder.generator.expressiontyper.TypedExpressionResult)3 DrlNameExpr (org.drools.mvel.parser.ast.expr.DrlNameExpr)3 NodeList (com.github.javaparser.ast.NodeList)2 CastExpr (com.github.javaparser.ast.expr.CastExpr)2 FieldAccessExpr (com.github.javaparser.ast.expr.FieldAccessExpr)2