use of org.kie.dmn.feel.lang.ast.FunctionInvocationNode in project drools by kiegroup.
the class FEELParserTest method testFunctionInvocationNamedParams.
@Test
public void testFunctionInvocationNamedParams() {
String inputExpression = "my.test.Function( named parameter 1 : x+10, named parameter 2 : \"foo\" )";
BaseNode functionBase = parse(inputExpression);
assertThat(functionBase, is(instanceOf(FunctionInvocationNode.class)));
assertThat(functionBase.getText(), is(inputExpression));
FunctionInvocationNode function = (FunctionInvocationNode) functionBase;
assertThat(function.getName(), is(instanceOf(QualifiedNameNode.class)));
assertThat(function.getName().getText(), is("my.test.Function"));
assertThat(function.getParams(), is(instanceOf(ListNode.class)));
assertThat(function.getParams().getElements().size(), is(2));
assertThat(function.getParams().getElements().get(0), is(instanceOf(NamedParameterNode.class)));
assertThat(function.getParams().getElements().get(1), is(instanceOf(NamedParameterNode.class)));
NamedParameterNode named = (NamedParameterNode) function.getParams().getElements().get(0);
assertThat(named.getText(), is("named parameter 1 : x+10"));
assertThat(named.getName().getText(), is("named parameter 1"));
assertThat(named.getExpression(), is(instanceOf(InfixOpNode.class)));
assertThat(named.getExpression().getText(), is("x+10"));
named = (NamedParameterNode) function.getParams().getElements().get(1);
assertThat(named.getText(), is("named parameter 2 : \"foo\""));
assertThat(named.getName().getText(), is("named parameter 2"));
assertThat(named.getExpression(), is(instanceOf(StringNode.class)));
assertThat(named.getExpression().getText(), is("\"foo\""));
}
Aggregations