Created
September 17, 2020 13:19
-
-
Save lucamolteni/5fcabc8f2016849f5ccf3b2ef9643497 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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