use of org.drools.modelcompiler.domain.Result in project drools by kiegroup.
the class CompilerTest method testFunction3.
@Test
public void testFunction3() {
String str = "import " + Result.class.getCanonicalName() + ";" + "import " + Person.class.getCanonicalName() + ";" + "function Boolean isFortyYearsOld(Person p, Boolean booleanParameter) {\n" + " return p.getAge() == 40; \n" + "}" + "rule R when\n" + " $p : Person(isFortyYearsOld(this, true))\n" + "then\n" + " insert(new Result($p.getName()));\n" + "end";
KieSession ksession = getKieSession(str);
ksession.insert(new Person("Mario", 40));
ksession.insert(new Person("Mark", 37));
ksession.insert(new Person("Edson", 35));
ksession.fireAllRules();
Collection<Result> results = getObjectsIntoList(ksession, Result.class);
assertEquals(1, results.size());
assertEquals("Mario", results.iterator().next().getValue());
}
Aggregations