RuleBase ruleBase = new RuleBaseImpl( new Rete( ) );
WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory( );
final Scheduler scheduler = Scheduler.getInstance( );
final Rule rule = new Rule( "test-rule" );
rule.addParameterDeclaration( "paramVar",
new MockObjectType( true ) );
// add consequence
rule.setConsequence( new org.drools.spi.Consequence( )
{
public void invoke(org.drools.spi.Tuple tuple) throws ConsequenceException
{
throw new ConsequenceException( "not enough cheese",
rule );
}
} );
// add condition
rule.addCondition( new org.drools.spi.InstrumentedCondition( ) );
rule.setDuration( new FixedDuration( 1 ) );
ReteTuple tuple = new ReteTuple( workingMemory );
AgendaItem item = new AgendaItem( tuple,
rule );