use of org.drools.mvel.compiler.FactB in project drools by kiegroup.
the class JBRULESTest method testJBRules2369.
@Test
public void testJBRules2369() {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(this.getClass(), kieBaseTestConfiguration, "test_JBRules2369.drl");
KieSession ksession = kbase.newKieSession();
final List<String> results = new ArrayList<String>();
ksession.setGlobal("results", results);
final FactA a = new FactA();
final FactB b = new FactB(Integer.valueOf(0));
final FactHandle aHandle = ksession.insert(a);
final FactHandle bHandle = ksession.insert(b);
ksession.fireAllRules();
assertEquals(1, results.size());
ksession.update(aHandle, a);
ksession.fireAllRules();
assertEquals(2, results.size());
}
use of org.drools.mvel.compiler.FactB in project drools by kiegroup.
the class FirstOrderLogicTest method testOrWithVariableResolution2.
// JBRULES-2526
@Test
public void testOrWithVariableResolution2() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrCEFollowedByMultipleEval2.drl");
KieSession ksession = kbase.newKieSession();
final AgendaEventListener al = mock(AgendaEventListener.class);
ksession.addEventListener(al);
ksession.insert(new FactA("a"));
ksession.insert(new FactB("b"));
ksession.insert(new FactC("c"));
ksession.fireAllRules();
verify(al, times(8)).afterMatchFired(any(AfterMatchFiredEvent.class));
}
use of org.drools.mvel.compiler.FactB in project drools by kiegroup.
the class FirstOrderLogicTest method testOrWithVariableResolution.
// JBRULES-2482
@Test
public void testOrWithVariableResolution() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_OrCEFollowedByMultipleEval.drl");
KieSession ksession = kbase.newKieSession();
final AgendaEventListener al = mock(AgendaEventListener.class);
ksession.addEventListener(al);
ksession.insert(new FactA("a"));
ksession.insert(new FactB("b"));
ksession.insert(new FactC("c"));
ksession.fireAllRules();
verify(al, times(6)).afterMatchFired(any(AfterMatchFiredEvent.class));
}
use of org.drools.mvel.compiler.FactB in project drools by kiegroup.
the class SessionsPoolTest method testSegmentMemoriesResetWithNotNodeInTheMiddle.
@Test
public void testSegmentMemoriesResetWithNotNodeInTheMiddle() {
String drl = "import " + FactA.class.getCanonicalName() + ";\n" + "import " + FactB.class.getCanonicalName() + ";\n" + "import " + FactC.class.getCanonicalName() + ";\n" + "rule R1\n" + "when\n" + " $factA : FactA( field1 == \"code1\")\n" + " not FactC( f2 == 1 && f1 == \"code1\")\n" + " $factB : FactB( f2 == 1 )\n" + "then\n" + "end\n" + "rule R2\n" + "when\n" + " $factA : FactA( field1 == \"code1\")\n" + " not FactC( f2 == 1 && f1 == \"code1\")\n" + " $factB : FactB( f2 == 3 )\n" + "then\n" + "end\n" + "rule R3\n" + "when\n" + " $factA: FactA( field1 == \"code1\")\n" + " $factC: FactC( f1 == \"code1\")\n" + "then\n" + "end";
final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", kieBaseTestConfiguration, drl);
KieContainer kcontainer = KieServices.get().newKieContainer(kieModule.getReleaseId());
KieSessionsPool pool = kcontainer.newKieSessionsPool(1);
KieSession ksession = pool.newKieSession();
try {
createFactAndInsert(ksession);
// R1 is fired
assertEquals(1, ksession.fireAllRules());
} finally {
ksession.dispose();
}
ksession = pool.newKieSession();
try {
createFactAndInsert(ksession);
assertEquals(1, ksession.fireAllRules());
} finally {
ksession.dispose();
}
pool.shutdown();
}
use of org.drools.mvel.compiler.FactB in project drools by kiegroup.
the class SessionsPoolTest method testSegmentMemoriesResetWithNotNodeInTheMiddle2.
@Test
public void testSegmentMemoriesResetWithNotNodeInTheMiddle2() {
// FactB constrains in R1 and R2 are different from testSegmentMemoriesResetWithNotNodeInTheMiddle()
String drl = "import " + FactA.class.getCanonicalName() + ";\n" + "import " + FactB.class.getCanonicalName() + ";\n" + "import " + FactC.class.getCanonicalName() + ";\n" + "rule R1\n" + "when\n" + " $factA : FactA( field1 == \"code1\")\n" + " not FactC( f2 == 1 && f1 == \"code1\")\n" + " $factB : FactB( f2 == 3 )\n" + "then\n" + "end\n" + "rule R2\n" + "when\n" + " $factA : FactA( field1 == \"code1\")\n" + " not FactC( f2 == 1 && f1 == \"code1\")\n" + " $factB : FactB( f2 == 1 )\n" + "then\n" + "end\n" + "rule R3\n" + "when\n" + " $factA: FactA( field1 == \"code1\")\n" + " $factC: FactC( f1 == \"code1\")\n" + "then\n" + "end";
final KieModule kieModule = KieUtil.getKieModuleFromDrls("test", kieBaseTestConfiguration, drl);
KieContainer kcontainer = KieServices.get().newKieContainer(kieModule.getReleaseId());
KieSessionsPool pool = kcontainer.newKieSessionsPool(1);
KieSession ksession = pool.newKieSession();
try {
createFactAndInsert(ksession);
// R2 is fired
assertEquals(1, ksession.fireAllRules());
} finally {
ksession.dispose();
}
ksession = pool.newKieSession();
try {
createFactAndInsert(ksession);
assertEquals(1, ksession.fireAllRules());
} finally {
ksession.dispose();
}
pool.shutdown();
}
Aggregations