RuleBase ruleBase = new RuleBaseImpl( new Rete( ) );
final WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory( );
final Agenda agenda = workingMemory.getAgenda( );
final Rule rule = new Rule( "test-rule" );
// add consequence
rule.setConsequence( new org.drools.spi.Consequence( )
{
public void invoke(org.drools.spi.Tuple tuple)
{
//throw in a different tuple, to check the agenda doesn't stop the rule/tuple combo
Declaration dec = new Declaration("paramVar", new MockObjectType(true), 1);
FactHandle fact = new FactHandleImpl(42);
ReteTuple different = new ReteTuple(workingMemory, dec, fact);
agenda.addToAgenda( different,
rule );
}
} );
ReteTuple tuple = new ReteTuple( workingMemory );
/*
* This is not recursive but different fact so should activate another rule
*/
rule.setNoLoop( true );
agenda.addToAgenda( tuple,
rule );
assertEquals( 1,
agenda.size( ) );
agenda.fireNextItem( null );