use of org.kie.soup.project.datamodel.oracle.MethodInfo in project drools by kiegroup.
the class RuleModelDRLPersistenceUnmarshallingTest method testFunctionCalls4_MultiParameterSetter.
@Test
public void testFunctionCalls4_MultiParameterSetter() {
String drl = "package org.mortgages;\n" + "import org.mortgages.classes.MyClass;\n" + "rule \"rule1\"\n" + "dialect \"mvel\"\n" + "when\n" + " $c : MyClass()\n" + "then\n" + " $c.setSomething(0, 1);\n" + "end\n";
Map<String, List<MethodInfo>> methodInformation = new HashMap<>();
List<MethodInfo> mapMethodInformation = new ArrayList<>();
mapMethodInformation.add(new MethodInfo("setSomething", Arrays.asList(DataType.TYPE_NUMERIC_INTEGER, DataType.TYPE_NUMERIC_INTEGER), "void", null, DataType.TYPE_STRING));
methodInformation.put("org.mortgages.classes.MyClass", mapMethodInformation);
when(dmo.getModuleMethodInformation()).thenReturn(methodInformation);
final RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal(drl, Collections.emptyList(), dmo);
assertNotNull(m);
assertEquals(1, m.rhs.length);
assertTrue(m.rhs[0] instanceof ActionCallMethod);
ActionCallMethod actionCallMethod1 = (ActionCallMethod) m.rhs[0];
assertEquals(1, actionCallMethod1.getState());
assertEquals("setSomething", actionCallMethod1.getMethodName());
assertEquals("$c", actionCallMethod1.getVariable());
assertEquals(2, actionCallMethod1.getFieldValues().length);
assertEquals("setSomething", actionCallMethod1.getFieldValues()[0].getField());
assertEquals("0", actionCallMethod1.getFieldValues()[0].getValue());
assertEquals(FieldNatureType.TYPE_LITERAL, actionCallMethod1.getFieldValues()[0].getNature());
assertEquals(DataType.TYPE_NUMERIC_INTEGER, actionCallMethod1.getFieldValues()[0].getType());
assertEquals("setSomething", actionCallMethod1.getFieldValues()[1].getField());
assertEquals("1", actionCallMethod1.getFieldValues()[1].getValue());
assertEquals(FieldNatureType.TYPE_LITERAL, actionCallMethod1.getFieldValues()[1].getNature());
assertEquals(DataType.TYPE_NUMERIC_INTEGER, actionCallMethod1.getFieldValues()[1].getType());
assertEqualsIgnoreWhitespace(drl, RuleModelDRLPersistenceImpl.getInstance().marshal(m));
}
Aggregations