use of org.drools.mvel.compiler.Cheesery in project drools by kiegroup.
the class MVELTest method testMVELRewrite.
@Test
public void testMVELRewrite() throws Exception {
// read in the source
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_MVELrewrite.drl");
KieSession ksession = kbase.newKieSession();
ksession = SerializationHelper.getSerialisedStatefulKnowledgeSession(ksession, true);
final List results = new ArrayList();
ksession.setGlobal("results", results);
final Cheese brie = new Cheese("brie", 2);
final Cheese stilton = new Cheese("stilton", 2);
final Cheesery cheesery = new Cheesery();
cheesery.addCheese(brie);
cheesery.addCheese(stilton);
ksession.insert(cheesery);
ksession.fireAllRules();
assertEquals(1, results.size());
assertEquals(cheesery, results.get(0));
}
use of org.drools.mvel.compiler.Cheesery in project drools by kiegroup.
the class FirstOrderLogicTest method testFromInsideNotAndExists.
@Test
public void testFromInsideNotAndExists() throws Exception {
KieBase kbase = KieBaseUtil.getKieBaseFromClasspathResources(getClass(), kieBaseTestConfiguration, "test_FromInsideNotAndExists.drl");
KieSession workingMemory = kbase.newKieSession();
final List list = new ArrayList();
workingMemory.setGlobal("results", list);
final Cheese cheddar = new Cheese("cheddar", 7);
final Cheese provolone = new Cheese("provolone", 5);
final Cheesery cheesery = new Cheesery();
cheesery.addCheese(cheddar);
cheesery.addCheese(provolone);
FactHandle handle = (FactHandle) workingMemory.insert(cheesery);
workingMemory.fireAllRules();
assertEquals(0, list.size());
cheesery.addCheese(new Cheese("stilton", 10));
cheesery.removeCheese(cheddar);
workingMemory.update(handle, cheesery);
workingMemory.fireAllRules();
assertEquals(2, list.size());
}
Aggregations