};
rule1.setConsequence( consequence );
final DefaultFactHandle handle1 = new DefaultFactHandle( 1,
"cheese" );
final RuleTerminalNodeLeftTuple tuple1 = new RuleTerminalNodeLeftTuple( handle1,
node,
true );
final PropagationContext context1 = pctxFactory.createPropagationContext(0, PropagationContext.INSERTION, null, null, new DefaultFactHandle());
// Test that a STATED assertion overrides a logical assertion
node.assertLeftTuple( tuple1,
context1,
ksession );
String logicalString1 = new String( "logical" );
FactHandle logicalHandle1 = ksession.insert( logicalString1,
null,
false,
true,
rule1,
(Activation) tuple1.getObject() );
// This assertion is stated and should override any previous justified
// "equals" objects.
String logicalString2 = new String( "logical" );
FactHandle logicalHandle2 = ksession.insert( logicalString2 );
node.retractLeftTuple( tuple1,
context1,
ksession );
assertLength( 0,
sink.getRetracted() );
// we override and discard the original logical object
assertSame( logicalHandle2,
logicalHandle1 );
// so while new STATED assertion is equal
assertEquals( logicalString1,
ksession.getObject( logicalHandle2 ) );
// they are not identity same
assertNotSame( logicalString1,
ksession.getObject( logicalHandle2 ) );
// Test that a logical assertion cannot override a STATED assertion
node.assertLeftTuple( tuple1,
context1,
ksession );
logicalString2 = new String( "logical" );
logicalHandle2 = ksession.insert( logicalString2 );
// This logical assertion will be ignored as there is already
// an equals STATED assertion.
logicalString1 = new String( "logical" );
logicalHandle1 = ksession.insert( logicalString1,
null,
false,
true,
rule1,
(Activation) tuple1.getObject() );
assertNull( logicalHandle1 );
// Already identify same so return previously assigned handle
logicalHandle1 = ksession.insert( logicalString2,
null,
false,
false,
rule1,
(Activation) tuple1.getObject() );
// return the matched handle
assertSame( logicalHandle2,
logicalHandle1 );