### Question:
ZKRegistrationClient implements RegistrationClient { @Override public CompletableFuture<Versioned<Set<BookieId>>> getReadOnlyBookies() { return getChildren(bookieReadonlyRegistrationPath, null); } ZKRegistrationClient(ZooKeeper zk,
                                String ledgersRootPath,
                                ScheduledExecutorService scheduler); @Override void close(); ZooKeeper getZk(); @Override CompletableFuture<Versioned<Set<BookieId>>> getWritableBookies(); @Override CompletableFuture<Versioned<Set<BookieId>>> getAllBookies(); @Override CompletableFuture<Versioned<Set<BookieId>>> getReadOnlyBookies(); @Override CompletableFuture<Versioned<BookieServiceInfo>> getBookieServiceInfo(BookieId bookieId); @Override synchronized CompletableFuture<Void> watchWritableBookies(RegistrationListener listener); @Override synchronized void unwatchWritableBookies(RegistrationListener listener); @Override synchronized CompletableFuture<Void> watchReadOnlyBookies(RegistrationListener listener); @Override synchronized void unwatchReadOnlyBookies(RegistrationListener listener);  }### Answer:
@Test public void testGetReadOnlyBookies() throws Exception { Set<BookieId> addresses = prepareNBookies(10); List<String> children = Lists.newArrayList(); for (BookieId address : addresses) { children.add(address.toString()); prepareReadBookieServiceInfo(address, false); } Stat stat = mock(Stat.class); when(stat.getCversion()).thenReturn(1234); mockGetChildren( regReadonlyPath, false, Code.OK.intValue(), children, stat); Versioned<Set<BookieId>> result = result(zkRegistrationClient.getReadOnlyBookies()); assertEquals(new LongVersion(1234), result.getVersion()); assertSetEquals( addresses, result.getValue()); }
@Test public void testGetReadOnlyBookiesFailure() throws Exception { mockGetChildren( regReadonlyPath, false, Code.NONODE.intValue(), null, null); try { result(zkRegistrationClient.getReadOnlyBookies()); fail("Should fail to get writable bookies"); } catch (ZKException zke) { } }