public void testRuleFlowGroup5() {
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
final DefaultAgenda agenda = (DefaultAgenda) workingMemory.getAgenda();
// create rule0
final Consequence consequence0 = new Consequence() {
private static final long serialVersionUID = 510l;
public void evaluate(KnowledgeHelper knowledgeHelper,
WorkingMemory w) {
// do nothing
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
}
public void writeExternal(ObjectOutput out) throws IOException {
}
public String getName() {
return "default";
}
};
final Rule rule0 = new Rule( "test-rule0" );
rule0.setRuleFlowGroup( "rule-flow-group-0" );
rule0.setConsequence( consequence0 );
final RuleFlowGroup ruleFlowGroup0 = agenda.getRuleFlowGroup( "rule-flow-group-0" );
assertTrue( ruleFlowGroup0.isAutoDeactivate() );
// RuleFlowGroup should be empty, as well as the agenda
assertEquals( 0,
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( 0,
ruleFlowGroup0.size() );
assertEquals( 0,
agenda.agendaSize() );
workingMemory.executeQueuedActions();
assertFalse( ruleFlowGroup0.isActive() );
}