64166417641864196420642164226423642464256426
KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBaseFromString( rule ) ); StatefulKnowledgeSession session = createKnowledgeSession( kbase ); Person toni = new Person( "Toni", 12 ); toni.setPet( new Pet( "Mittens" ) ); session.insert( new ArrayList() ); session.insert( toni ); session.fireAllRules();
64536454645564566457645864596460646164626463
65336534653565366537653865396540654165426543654465456546
KnowledgeBase kbase = SerializationHelper.serializeObject( loadKnowledgeBaseFromString( rule ) ); StatefulKnowledgeSession session = createKnowledgeSession( kbase ); assertNotNull( session ); Pet pet1 = new Pet( "Toni" ); pet1.getAttributes().put( "key", "value" ); Pet pet2 = new Pet( "Toni" ); session.insert( pet1 ); session.insert( pet2 ); session.fireAllRules();
65996600660166026603660466056606660766086609
org.kie.api.event.rule.WorkingMemoryEventListener wml = Mockito.mock( org.kie.api.event.rule.WorkingMemoryEventListener.class ); ksession.addEventListener( wml ); org.kie.api.runtime.rule.FactHandle personFH = ksession.insert( new Person( "Toni" ) ); org.kie.api.runtime.rule.FactHandle petFH = ksession.insert( new Pet( "Toni" ) ); int fired = ksession.fireAllRules(); assertEquals( 1, fired );
61496150615161526153615461556156615761586159
List list = new ArrayList(); ksession.setGlobal("list", list); Person p = new Person( "Toni" ); ksession.insert( p); ksession.insert( new Pet( "Toni" ) ); ksession.fireAllRules(); assertEquals( 1, list.size() ); assertSame(p, list.get(0));
61876188618961906191619261936194619561966197
62246225622662276228622962306231623262336234
63046305630663076308630963106311631263136314631563166317
63586359636063616362636363646365636663676368
65016502650365046505650665076508650965106511
List list = new ArrayList(); ksession.setGlobal( "list", list ); Person p = new Person(); p.setPet( new Pet() ); ksession.insert( p ); ksession.fireAllRules(); assertEquals( 1, list.size() ); assertSame(p, list.get(0));