Skip to content

Instantly share code, notes, and snippets.

@lucamolteni
Created June 21, 2019 15:51
Show Gist options
  • Save lucamolteni/0036d6a754bdeb503e050eb1ffb00a9d to your computer and use it in GitHub Desktop.
Save lucamolteni/0036d6a754bdeb503e050eb1ffb00a9d to your computer and use it in GitHub Desktop.
@Test
@Ignore("why does this fail in both drl and exec model?")
public void testIntegerShort() {
String str =
"import " + Result.class.getCanonicalName() + ";" +
"import " + Person.class.getCanonicalName() + ";" +
"rule R when\n" +
" $r : Result()\n" +
" $markV : Person(name == \"Mark\")\n" +
" $olderV : Person(name != \"Mark\", ageAsShort == $markV.age)\n" +
"then\n" +
" $r.setValue($olderV.getName() + \" is same age as \" + $markV.getName());\n" +
"end";
KieSession ksession = getKieSession( str );
Result result = new Result();
ksession.insert( result );
ksession.insert(new Person("Mark", 40));
ksession.insert(new Person("Edson", 35));
ksession.insert(new Person("Mario", 40));
ksession.fireAllRules();
assertEquals("Mario is same age as Mark", result.getValue());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment