ObjectSource extends BaseNode implements
    Externalizable { public void addObjectSink(final ObjectSink objectSink) { this.sink = this.sink.addObjectSink( objectSink, this.alphaNodeHashingThreshold ); } ObjectSource(); protected  ObjectSource(final int id,
                 final RuleBasePartitionId partitionId,
                 final boolean partitionsEnabled);   ObjectSource(final int id,
                 final RuleBasePartitionId partitionId,
                 final boolean partitionsEnabled,
                 final ObjectSource objectSource,
                 final int alphaNodeHashingThreshold); void readExternal(ObjectInput in); void writeExternal(ObjectOutput out); ObjectSource getParentObjectSource(); void setParentObjectSource(ObjectSource source); InternalKnowledgeBase getKnowledgeBase(); void initDeclaredMask(BuildContext context); abstract BitMask calculateDeclaredMask(Class modifiedClass, List<String> settableProperties); void resetInferredMask(); BitMask updateMask(BitMask mask); @Override void setPartitionId(BuildContext context, RuleBasePartitionId partitionId); final RuleBasePartitionId setSourcePartitionId(RuleBasePartitionId partitionId); final void setPartitionIdWithSinks( RuleBasePartitionId partitionId ); void addObjectSink(final ObjectSink objectSink); void removeObjectSink(final ObjectSink objectSink); abstract void updateSink(ObjectSink sink,
                                    PropagationContext context,
                                    InternalWorkingMemory workingMemory); void networkUpdated(UpdateContext updateContext); ObjectSinkPropagator getObjectSinkPropagator(); void setObjectSinkPropagator(ObjectSinkPropagator sink); boolean isInUse(); @Override ObjectTypeNode getObjectTypeNode(); BitMask getDeclaredMask();  }
@Test public void testAddObjectSink() throws Exception { final MockObjectSource source = new MockObjectSource( 15 ); final Field field = ObjectSource.class.getDeclaredField( "sink" ); field.setAccessible( true ); ObjectSinkPropagator sink = (ObjectSinkPropagator) field.get( source ); assertSame( EmptyObjectSinkAdapter.getInstance(), sink ); final MockObjectSink sink1 = new MockObjectSink(); source.addObjectSink( sink1 ); sink = (ObjectSinkPropagator) field.get( source ); assertSame( SingleObjectSinkAdapter.class, sink.getClass() ); assertEquals( 1, sink.getSinks().length ); final MockObjectSink sink2 = new MockObjectSink(); source.addObjectSink( sink2 ); sink = (ObjectSinkPropagator) field.get( source ); assertSame( CompositeObjectSinkAdapter.class, sink.getClass() ); assertEquals( 2, sink.getSinks().length ); final MockObjectSink sink3 = new MockObjectSink(); source.addObjectSink( sink3 ); assertSame( CompositeObjectSinkAdapter.class, sink.getClass() ); assertEquals( 3, sink.getSinks().length ); source.removeObjectSink( sink2 ); assertSame( CompositeObjectSinkAdapter.class, sink.getClass() ); assertEquals( 2, sink.getSinks().length ); source.removeObjectSink( sink1 ); sink = (ObjectSinkPropagator) field.get( source ); assertSame( SingleObjectSinkAdapter.class, sink.getClass() ); assertEquals( 1, sink.getSinks().length ); source.removeObjectSink( sink3 ); sink = (ObjectSinkPropagator) field.get( source ); assertSame( EmptyObjectSinkAdapter.getInstance(), sink ); assertEquals( 0, sink.getSinks().length ); }