Search in sources :

Example 16 with Cheesery

use of org.drools.compiler.Cheesery in project drools by kiegroup.

the class FromTest method testMultipleFroms.

@Test
public void testMultipleFroms() throws Exception {
    final KieBase kbase = SerializationHelper.serializeObject(loadKnowledgeBase("test_multipleFroms.drl"));
    final KieSession ksession = createKnowledgeSession(kbase);
    final List results = new ArrayList();
    ksession.setGlobal("results", results);
    final Cheesery cheesery = new Cheesery();
    cheesery.addCheese(new Cheese("stilton", 15));
    cheesery.addCheese(new Cheese("brie", 10));
    ksession.setGlobal("cheesery", cheesery);
    ksession.fireAllRules();
    assertEquals(2, results.size());
    assertEquals(2, ((List) results.get(0)).size());
    assertEquals(2, ((List) results.get(1)).size());
}
Also used : KieBase(org.kie.api.KieBase) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) List(java.util.List) ArrayList(java.util.ArrayList) Cheese(org.drools.compiler.Cheese) Cheesery(org.drools.compiler.Cheesery) Test(org.junit.Test)

Aggregations

Cheesery (org.drools.compiler.Cheesery)16 Test (org.junit.Test)16 KieSession (org.kie.api.runtime.KieSession)16 Cheese (org.drools.compiler.Cheese)14 ArrayList (java.util.ArrayList)13 KieBase (org.kie.api.KieBase)12 List (java.util.List)11 Person (org.drools.compiler.Person)6 FactHandle (org.kie.api.runtime.rule.FactHandle)6 InternalKnowledgeBase (org.drools.core.impl.InternalKnowledgeBase)3 Dimension (java.awt.Dimension)2 Worker (org.drools.compiler.Worker)2 SessionInspector (org.drools.core.util.debug.SessionInspector)2 StatefulKnowledgeSessionInfo (org.drools.core.util.debug.StatefulKnowledgeSessionInfo)2 KnowledgeBuilder (org.kie.internal.builder.KnowledgeBuilder)2 KiePackage (org.kie.api.definition.KiePackage)1 StatelessKieSession (org.kie.api.runtime.StatelessKieSession)1 KieHelper (org.kie.internal.utils.KieHelper)1