//Test 2 levels of inheritance, and basic rule
List list = new ArrayList();
session.setGlobal( "list",
list );
final Cheese mycheese = new Cheese( "cheddar",
4 );
org.kie.api.runtime.rule.FactHandle handle = session.insert( mycheese );
session.fireAllRules();
assertEquals( 2,
list.size() );
assertTrue( list.contains( "rule 4" ) );
assertTrue( list.contains( "rule 2b" ) );
//Test 2nd level (parent) to make sure rule honors the extend rule
list = new ArrayList();
session.setGlobal( "list",
list );
session.retract( handle );
final Cheese mycheese2 = new Cheese( "notcheddar",
4 );
org.kie.api.runtime.rule.FactHandle handle2 = session.insert( mycheese2 );
session.fireAllRules();
assertEquals( "rule 4",
list.get( 0 ) );
assertEquals( 1,
list.size() );
//Test 3 levels of inheritance, all levels
list = new ArrayList();
session.setGlobal( "list",
list );
session.retract( handle2 );
final Cheese mycheese3 = new Cheese( "stilton",
6 );
org.kie.api.runtime.rule.FactHandle handle3 = session.insert( mycheese3 );
session.fireAllRules();
//System.out.println(list.toString());
assertEquals( "rule 3",
list.get( 0 ) );
assertEquals( 1,
list.size() );
//Test 3 levels of inheritance, third only
list = new ArrayList();
session.setGlobal( "list",
list );
session.retract( handle3 );
final Cheese mycheese4 = new Cheese( "notstilton",
6 );
org.kie.api.runtime.rule.FactHandle handle4 = session.insert( mycheese4 );
session.fireAllRules();
//System.out.println(((List) session.getGlobal( "list" )).toString());
assertTrue( ((List) session.getGlobal( "list" )).size() == 0 );
//Test 3 levels of inheritance, 2nd only
list = new ArrayList();
session.setGlobal( "list",
list );
session.retract( handle4 );
final Cheese mycheese5 = new Cheese( "stilton",
7 );
org.kie.api.runtime.rule.FactHandle handle5 = session.insert( mycheese5 );
session.fireAllRules();
//System.out.println(((List) session.getGlobal( "list" )).toString());
assertEquals( 0,