Search in sources :

Example 1 with IfExpressionNode

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

the class FEELParserTest method testIfExpression.

@Test
public void testIfExpression() {
    String inputExpression = "if applicant.age < 18 then \"declined\" else \"accepted\"";
    BaseNode ifBase = parse(inputExpression);
    assertThat(ifBase, is(instanceOf(IfExpressionNode.class)));
    assertThat(ifBase.getText(), is(inputExpression));
    assertThat(ifBase.getResultType(), is(BuiltInType.STRING));
    IfExpressionNode ifExpr = (IfExpressionNode) ifBase;
    assertThat(ifExpr.getCondition().getText(), is("applicant.age < 18"));
    assertThat(ifExpr.getThenExpression().getText(), is("\"declined\""));
    assertThat(ifExpr.getElseExpression().getText(), is("\"accepted\""));
}
Also used : IfExpressionNode(org.kie.dmn.feel.lang.ast.IfExpressionNode) 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 IfExpressionNode (org.kie.dmn.feel.lang.ast.IfExpressionNode)1