Search in sources :

Example 1 with IterationContextNode

use of org.kie.dmn.feel.lang.ast.IterationContextNode in project drools by kiegroup.

the class FEELParserTest method testForExpression.

@Test
public void testForExpression() {
    String inputExpression = "for item in order.items return item.price * item.quantity";
    BaseNode forbase = parse(inputExpression);
    assertThat(forbase, is(instanceOf(ForExpressionNode.class)));
    assertThat(forbase.getText(), is(inputExpression));
    assertThat(forbase.getResultType(), is(BuiltInType.LIST));
    ForExpressionNode forExpr = (ForExpressionNode) forbase;
    assertThat(forExpr.getIterationContexts().size(), is(1));
    assertThat(forExpr.getExpression(), is(instanceOf(InfixOpNode.class)));
    assertThat(forExpr.getExpression().getText(), is("item.price * item.quantity"));
    IterationContextNode ic = forExpr.getIterationContexts().get(0);
    assertThat(ic.getName().getText(), is("item"));
    assertThat(ic.getExpression(), is(instanceOf(QualifiedNameNode.class)));
    assertThat(ic.getExpression().getText(), is("order.items"));
}
Also used : ForExpressionNode(org.kie.dmn.feel.lang.ast.ForExpressionNode) IterationContextNode(org.kie.dmn.feel.lang.ast.IterationContextNode) BaseNode(org.kie.dmn.feel.lang.ast.BaseNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 BaseNode (org.kie.dmn.feel.lang.ast.BaseNode)1 ForExpressionNode (org.kie.dmn.feel.lang.ast.ForExpressionNode)1 IterationContextNode (org.kie.dmn.feel.lang.ast.IterationContextNode)1