@Test
public void testUpdateSink() throws FactException {
// Tests that when new child is added only the last added child is
// updated
// When the attachingNewNode flag is set
final PropagationContext context = new PropagationContextImpl( 0,
PropagationContext.ASSERTION,
null,
null,
null );
final RuleBase ruleBase = RuleBaseFactory.newRuleBase();
final ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
(ReteooRuleBase) ruleBase );
final Rete source = new Rete( (InternalRuleBase)ruleBase);
final ObjectTypeNode objectTypeNode = new ObjectTypeNode( 1,
this.entryPoint,
new ClassObjectType( String.class ),
buildContext );
final MockObjectSink sink1 = new MockObjectSink();
objectTypeNode.addObjectSink( sink1 );
final Object string1 = "cheese";
final Object string2 = "bread";
final DefaultFactHandle handle1 = new DefaultFactHandle( 1,
string1 );
final DefaultFactHandle handle2 = new DefaultFactHandle( 2,
string2 );
objectTypeNode.assertObject( handle1,
context,
workingMemory );
objectTypeNode.assertObject( handle2,
context,
workingMemory );
assertEquals( 2,
sink1.getAsserted().size() );
final MockObjectSink sink2 = new MockObjectSink();
objectTypeNode.addObjectSink( sink2 );
assertEquals( 0,
sink2.getAsserted().size() );
objectTypeNode.updateSink( sink2,
new PropagationContextImpl(),
workingMemory );
assertEquals( 2,
sink2.getAsserted().size() );