use of org.drools.compiler.lang.descr.FunctionDescr in project drools by kiegroup.
the class RuleParserTest method testFunctions.
@Test
public void testFunctions() throws Exception {
final PackageDescr pkg = (PackageDescr) parseResource("compilationUnit", "functions.drl");
assertEquals(2, pkg.getRules().size());
final List<FunctionDescr> functions = pkg.getFunctions();
assertEquals(2, functions.size());
FunctionDescr func = functions.get(0);
assertEquals("functionA", func.getName());
assertEquals("String", func.getReturnType());
assertEquals(2, func.getParameterNames().size());
assertEquals(2, func.getParameterTypes().size());
assertEquals(19, func.getLine());
assertEquals(0, func.getColumn());
assertEquals("String", func.getParameterTypes().get(0));
assertEquals("s", func.getParameterNames().get(0));
assertEquals("Integer", func.getParameterTypes().get(1));
assertEquals("i", func.getParameterNames().get(1));
assertEqualsIgnoreWhitespace("foo();", func.getBody());
func = functions.get(1);
assertEquals("functionB", func.getName());
assertEqualsIgnoreWhitespace("bar();", func.getText());
}
Aggregations