Source:
<code>public void setup() throws Exception { mockLedgerMetadataRegistry = new ConcurrentHashMap<>(); mockLedgerData = new ConcurrentHashMap<>(); mockNextLedgerId = new AtomicLong(1); fencedLedgers = new ConcurrentSkipListSet<>(); scheduler = new ScheduledThreadPoolExecutor(4); executor = OrderedSafeExecutor.newBuilder().build(); bookieWatcher = mock(BookieWatcher.class); bookieClient = mock(BookieClient.class); ledgerManager = mock(LedgerManager.class); ledgerIdGenerator = mock(LedgerIdGenerator.class); bk = mock(BookKeeper.class); <START> Whitebox.setInternalState(bk, "bookieWatcher", bookieWatcher); <END> Whitebox.setInternalState(bk, "disableEnsembleChangeFeature", mock(Feature.class)); NullStatsLogger nullStatsLogger = setupLoggers(); failedBookies = new ArrayList<>(); availableBookies = new HashSet<>(); when(bk.getCloseLock()).thenReturn(new ReentrantReadWriteLock()); when(bk.isClosed()).thenReturn(false); when(bk.getBookieWatcher()).thenReturn(bookieWatcher); when(bk.getExplicitLacInterval()).thenReturn(0); when(bk.getMainWorkerPool()).thenReturn(executor); when(bk.getBookieClient()).thenReturn(bookieClient); when(bk.getScheduler()).thenReturn(scheduler); when(bk.getReadSpeculativeRequestPolicy()).thenReturn(Optional.absent()); when(bk.getConf()).thenReturn(new ClientConfiguration()); when(bk.getStatsLogger()).thenReturn(nullStatsLogger); when(bk.getLedgerManager()).thenReturn(ledgerManager); when(bk.getLedgerIdGenerator()).thenReturn(ledgerIdGenerator); when(bk.getReturnRc(anyInt())).thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); setupLedgerIdGenerator(); setupCreateLedgerMetadata(); setupReadLedgerMetadata(); setupWriteLedgerMetadata(); setupRemoveLedgerMetadata(); setupRegisterLedgerMetadataListener(); setupBookieWatcherForNewEnsemble(); setupBookieWatcherForEnsembleChange(); setupBookieClientReadEntry(); setupBookieClientAddEntry(); }</code><technical_language>This is needed, 149</technical_language>

Target:
public void setup() throws Exception { mockLedgerMetadataRegistry = new ConcurrentHashMap<>(); mockLedgerData = new ConcurrentHashMap<>(); mockNextLedgerId = new AtomicLong(1); fencedLedgers = new ConcurrentSkipListSet<>(); scheduler = new ScheduledThreadPoolExecutor(4); executor = OrderedSafeExecutor.newBuilder().build(); bookieWatcher = mock(BookieWatcher.class); bookieClient = mock(BookieClient.class); ledgerManager = mock(LedgerManager.class); ledgerIdGenerator = mock(LedgerIdGenerator.class); bk = mock(BookKeeper.class); NullStatsLogger nullStatsLogger = setupLoggers(); failedBookies = new ArrayList<>(); availableBookies = new HashSet<>(); when(bk.getCloseLock()).thenReturn(new ReentrantReadWriteLock()); when(bk.isClosed()).thenReturn(false); when(bk.getBookieWatcher()).thenReturn(bookieWatcher); when(bk.getDisableEnsembleChangeFeature()).thenReturn(mock(Feature.class)); when(bk.getExplicitLacInterval()).thenReturn(0); when(bk.getMainWorkerPool()).thenReturn(executor); when(bk.getBookieClient()).thenReturn(bookieClient); when(bk.getScheduler()).thenReturn(scheduler); when(bk.getReadSpeculativeRequestPolicy()).thenReturn(Optional.absent()); when(bk.getConf()).thenReturn(new ClientConfiguration()); when(bk.getStatsLogger()).thenReturn(nullStatsLogger); when(bk.getLedgerManager()).thenReturn(ledgerManager); when(bk.getLedgerIdGenerator()).thenReturn(ledgerIdGenerator); when(bk.getReturnRc(anyInt())).thenAnswer(invocationOnMock -> invocationOnMock.getArgument(0)); setupLedgerIdGenerator(); setupCreateLedgerMetadata(); setupReadLedgerMetadata(); setupWriteLedgerMetadata(); setupRemoveLedgerMetadata(); setupRegisterLedgerMetadataListener(); setupBookieWatcherForNewEnsemble(); setupBookieWatcherForEnsembleChange(); setupBookieClientReadEntry(); setupBookieClientAddEntry(); }