ModuleImpl main = (ModuleImpl) agenda.getFocus();
Activation[] activations = ( Activation[] ) main.getActivationQueue().toArray( new Activation[] {} );
/* Create the first justifieable relationship */
String logicalString1 = new String ( "logical" );
Activation activation1 = activations[0];
FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
false,
true,
activation1.getRule(),
activation1 );
/* Create the second justifieable relationship */
String logicalString2 = new String ( "logical" );
Activation activation2 = activations[1];
FactHandle logicalHandle2 = workingMemory.assertObject( logicalString2,
false,
true,
activation2.getRule(),
activation2 );
/* "logical" should only appear once */
assertLength( 1,
workingMemory.getJustified().values() );
/* but has two justifications */
assertLength( 2,
workingMemory.getJustifiers().values() );
/* Now lets cancel the first activation */
agenda.removeFromAgenda( ( (ReteTuple) activation2.getTuple() ).getKey(),
context2,
activation2.getRule() );
/* because this logical fact has two relationships it shouldn't retract yet */
assertLength( 0,
sink.getRetracted() );