Skip to content

Instantly share code, notes, and snippets.

@lucamolteni
Created September 17, 2020 13:19
Show Gist options
  • Select an option

  • Save lucamolteni/5fcabc8f2016849f5ccf3b2ef9643497 to your computer and use it in GitHub Desktop.

Select an option

Save lucamolteni/5fcabc8f2016849f5ccf3b2ef9643497 to your computer and use it in GitHub Desktop.
@Test
public void testNamedConsequenceWithFloat() throws Exception {
// DROOLS-xxxx
String drl =
"import " + FactWithInteger.class.getCanonicalName() + ";\n" +
"global java.util.List list;\n" +
"\n" +
"rule init salience 10 when\n" +
" $f : FactWithInteger()\n" +
"then\n" +
" $f.intValue=4;\n" +
" update($f)\n" +
" list.add(\"init\");\n" +
"end\n" +
"rule test salience 1 lock-on-active when\n" +
" $f : FactWithInteger(getIntValue() == 4)\n" +
"then\n" +
" list.add(\"ok\");\n" +
"end\n";
KieSession ksession = new KieHelper().addContent( drl, ResourceType.DRL )
.build()
.newKieSession();
ksession.addEventListener(new DebugAgendaEventListener());
ReteDumper.dumpRete(ksession);
List<String> list = new ArrayList<String>();
ksession.setGlobal( "list", list );
ksession.insert( new FactWithInteger(0) );
ksession.fireAllRules();
assertEquals( 2, list.size() );
assertEquals( "init", list.get(0) );
assertEquals( "ok", list.get(1) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment