new MockTupleSource( idGenerator.getNextId() ),
rule0,
rule0.getLhs(),
buildContext );
final RuleFlowGroup ruleFlowGroup0 = agenda.getRuleFlowGroup( "rule-flow-group-0" );
assertTrue( ruleFlowGroup0.isAutoDeactivate() );
ruleFlowGroup0.setAutoDeactivate( false );
assertFalse( ruleFlowGroup0.isAutoDeactivate() );
// create context
final PropagationContext context0 = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
rule0,
null );
// Create an activation for this rule
final ReteTuple tuple0 = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
node0.assertTuple( tuple0,
context0,
workingMemory );
// RuleFlowGroup should be populated, but the agenda shouldn't be
assertEquals( 1,
ruleFlowGroup0.size() );
assertEquals( 0,
agenda.agendaSize() );
// Activate the RuleFlowGroup, the activations stay in the group, but
// should now also be in the Agenda
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 1,
ruleFlowGroup0.size() );
assertEquals( 1,
agenda.agendaSize() );
// Execute activation
agenda.fireNextItem( null );
assertEquals( 0,
ruleFlowGroup0.size() );
assertEquals( 0,
agenda.agendaSize() );
assertTrue( ruleFlowGroup0.isActive() );
// Set auto-deactivation status to true
ruleFlowGroup0.setAutoDeactivate( true );
assertTrue( ruleFlowGroup0.isAutoDeactivate() );
assertFalse( ruleFlowGroup0.isActive() );
// Add another activation and activate RuleFlowGroup again
final ReteTuple tuple1 = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
node0.assertTuple( tuple1,
context0,
workingMemory );
agenda.activateRuleFlowGroup( "rule-flow-group-0" );
assertEquals( 1,
ruleFlowGroup0.size() );
assertEquals( 1,
agenda.agendaSize() );
assertTrue( ruleFlowGroup0.isActive() );
// Execute the activation, the RuleFlowGroup should automatically deactivate
agenda.fireNextItem( null );
assertEquals( 0,
ruleFlowGroup0.size() );
assertEquals( 0,
agenda.agendaSize() );
workingMemory.executeQueuedActions();
assertFalse( ruleFlowGroup0.isActive() );
// A new activation should now be added to the RuleFlowGroup but not to the agenda
final ReteTuple tuple2 = new ReteTuple( new DefaultFactHandle( 1,
"cheese" ) );
node0.assertTuple( tuple2,
context0,
workingMemory );
assertEquals( 1,
ruleFlowGroup0.size() );
assertEquals( 0,
agenda.agendaSize() );
}