63036304630563066307630863096310631163126313631463156316
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();
63576358635963606361636263636364636563666367
RuleRuntimeEventListener wml = Mockito.mock( RuleRuntimeEventListener.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 );
65006501650265036504650565066507650865096510
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));
61546155615661576158615961606161616261636164
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));
61926193619461956196619761986199620062016202
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();
62296230623162326233623462356236623762386239
63096310631163126313631463156316631763186319632063216322
63636364636563666367636863696370637163726373
RuleRuntimeEventListener wml = Mockito.mock( RuleRuntimeEventListener.class ); ksession.addEventListener( wml ); FactHandle personFH = ksession.insert( new Person( "Toni" ) ); FactHandle petFH = ksession.insert( new Pet( "Toni" ) ); int fired = ksession.fireAllRules(); assertEquals( 1, fired );
65066507650865096510651165126513651465156516
6384638563866387638863896390
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(); kbase.addKnowledgePackages( kbuilder.getKnowledgePackages() ); StatefulKnowledgeSession ksession = createKnowledgeSession( kbase ); ksession.insert( new Person( "Toni" ) ); ksession.insert( new Pet( "Toni" ) ); }