@Test public void testAttach() throws Exception { when(constraint.isAllowedCachedLeft(any(ContextEntry.class), any(InternalFactHandle.class ) ) ).thenReturn( true ); when( constraint.isAllowedCachedRight( any( LeftTupleImpl.class ), any( ContextEntry.class ) ) ).thenReturn( true ); final Field objectFfield = ObjectSource.class.getDeclaredField( "sink" ); objectFfield.setAccessible( true ); ObjectSinkPropagator objectSink = (ObjectSinkPropagator) objectFfield.get( this.objectSource ); final Field tupleField = LeftTupleSource.class.getDeclaredField( "sink" ); tupleField.setAccessible( true ); LeftTupleSinkPropagator tupleSink = (LeftTupleSinkPropagator) tupleField.get( this.tupleSource ); assertEquals( 15, this.node.getId() ); assertNotNull( objectSink ); assertNotNull( tupleSink ); InternalKnowledgeBase kBase = (InternalKnowledgeBase) KnowledgeBaseFactory.newKnowledgeBase(); BuildContext context = new BuildContext(kBase, kBase.getReteooBuilder().getIdGenerator() ); this.node.attach(context); objectSink = (ObjectSinkPropagator) objectFfield.get( this.objectSource ); tupleSink = (LeftTupleSinkPropagator) tupleField.get( this.tupleSource ); assertEquals( 1, objectSink.getSinks().length ); assertEquals( 1, tupleSink.getSinks().length ); assertSame( this.node, objectSink.getSinks()[0] ); assertSame( this.node, tupleSink.getSinks()[0] ); }