// create the agendaGroup
//final AgendaGroupImpl agendaGroup = new AgendaGroupImpl( "agendaGroup" );
//agenda.addAgendaGroup( agendaGroup );
final RuleFlowGroupImpl ruleFlowGroup = (RuleFlowGroupImpl) agenda.getRuleFlowGroup( "rule-flow-group-0" );
final LeftTupleImpl tuple = new LeftTupleImpl( new DefaultFactHandle( 1,
"cheese" ),
null,
true );
// create a rule for the agendaGroup
final Rule rule = new Rule( "test-rule" );
rule.setRuleFlowGroup( "rule-flow-group-0" );
final RuleTerminalNode node = new RuleTerminalNode( 2,
new MockTupleSource( 2 ),
rule,
rule.getLhs(),
0,
buildContext );
final PropagationContext context = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
rule,
null,
null );
// When both the rule is lock-on-active and the agenda group is active, activations should be ignored
rule.setLockOnActive( true );
ruleFlowGroup.setAutoDeactivate( false );
ruleFlowGroup.setActive( true );
node.assertLeftTuple( tuple,
context,
workingMemory );
// activation should be ignored
assertEquals( 0,
ruleFlowGroup.size() );
// lock-on-active is now false so activation should propagate
rule.setLockOnActive( false );
node.assertLeftTuple( tuple,
context,
workingMemory );
agenda.unstageActivations();
assertEquals( 1,
ruleFlowGroup.size() );
// even if lock-on-active is true, unless the agenda group is active the activation will still propagate
rule.setLockOnActive( true );
ruleFlowGroup.setActive( false );
node.assertLeftTuple( tuple,
context,
workingMemory );
agenda.unstageActivations();
assertEquals( 2,
ruleFlowGroup.size() );
}