rule0,
null,
new DefaultFactHandle());
// Create an activation for this rule
final RuleTerminalNodeLeftTuple tuple0 = new RuleTerminalNodeLeftTuple(new DefaultFactHandle(1,
"cheese"),
node0,
true);
node0.assertLeftTuple(tuple0,
context0,
workingMemory);
workingMemory.fireAllRules();
// RuleFlowGroup should be populated, but the agenda shouldn't be
assertEquals(1,
ruleFlowGroup0.size());
// Activate the RuleFlowGroup
agenda.activateRuleFlowGroup("rule-flow-group-0");
assertEquals(1,
ruleFlowGroup0.size());
// Execute activation
agenda.fireNextItem(null, 0, -1);
assertEquals(0,
ruleFlowGroup0.size());
assertTrue(ruleFlowGroup0.isActive());
// Set auto-deactivation status to true
ruleFlowGroup0.setAutoDeactivate(true);
assertTrue(ruleFlowGroup0.isAutoDeactivate());
agenda.fireNextItem(null, 0, -1);
assertFalse(ruleFlowGroup0.isActive());
// Add another activation and activate RuleFlowGroup again
final RuleTerminalNodeLeftTuple tuple1 = new RuleTerminalNodeLeftTuple(new DefaultFactHandle(1,
"cheese"),
node0,
true);
node0.assertLeftTuple(tuple1,
context0,
workingMemory);
agenda.unstageActivations();
agenda.activateRuleFlowGroup("rule-flow-group-0");
assertEquals(1,
ruleFlowGroup0.size());
assertTrue(ruleFlowGroup0.isActive());
// Execute the activation, the RuleFlowGroup should automatically deactivate
agenda.fireNextItem(null, 0, -1);
assertEquals(0,
ruleFlowGroup0.size());
workingMemory.executeQueuedActions();
assertEquals(0, ruleFlowGroup0.size());
agenda.fireNextItem(null, 0, -1);
assertFalse(ruleFlowGroup0.isActive());
// A new activation should now be added to the RuleFlowGroup but not to the agenda
final RuleTerminalNodeLeftTuple tuple2 = new RuleTerminalNodeLeftTuple(new DefaultFactHandle(1,
"cheese"),
node0,
true);
node0.assertLeftTuple(tuple2,
context0,