when( mockContext.getServiceReferences( IPentahoInitializer.class, null ) )
.thenReturn( Collections.singletonList( ref ) );
final AtomicBoolean initialized = new AtomicBoolean( false );
IPentahoInitializer initializer = new IPentahoInitializer() {
@Override
public void init( IPentahoSession session ) {
initialized.set( true );
}
};
when( mockContext.getService( ref ) ).thenReturn( initializer );
assertTrue( "initializer should be rested", initialized.get() == false );
OSGIObjectFactory factory = new OSGIObjectFactory( mockContext );
IPentahoInitializer actual = factory.get( IPentahoInitializer.class, session );
assertSame( initializer, actual );
assertTrue( "initializer not called", initialized.get() );
verify( mockContext ).getServiceReferences( IPentahoInitializer.class, null );