final Declaration[] previousDeclarations = new Declaration[]{a, b};
final Declaration[] localDeclarations = new Declaration[]{};
final String[] requiredGlobals = new String[]{};
final ReturnValueRestriction returnValue = new ReturnValueRestriction( extractor,
previousDeclarations,
localDeclarations,
requiredGlobals,
ValueType.PINTEGER_TYPE.getEvaluator( Operator.EQUAL ) );
builder.build( context,
usedIdentifiers,
previousDeclarations,
localDeclarations,
returnValue,
returnValueDescr );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final InternalWorkingMemory wm = (InternalWorkingMemory) ruleBase.newStatefulSession();
final Cheese stilton = new Cheese( "stilton",
10 );
final Cheese cheddar = new Cheese( "cheddar",
10 );
final InternalFactHandle f0 = (InternalFactHandle) wm.insert( cheddar );
ReteTuple tuple = new ReteTuple( f0 );
final InternalFactHandle f1 = (InternalFactHandle) wm.insert( stilton );
tuple = new ReteTuple( tuple,
f1 );
final Cheese brie = new Cheese( "brie",
20 );
assertTrue( returnValue.isAllowed( extractor,
brie,
tuple,
wm ) );
brie.setPrice( 18 );
assertFalse( returnValue.isAllowed( extractor,
brie,
tuple,
wm ) );
}