### Question:
ZooAuthenticationKeyDistributor { public List<AuthenticationKey> getCurrentKeys() throws KeeperException, InterruptedException { checkState(initialized.get(), "Not initialized"); List<String> children = zk.getChildren(baseNode); if (children.isEmpty()) { return Collections.emptyList(); } List<AuthenticationKey> keys = new ArrayList<>(children.size()); for (String child : children) { byte[] data = zk.getData(qualifyPath(child), null); if (data != null) { AuthenticationKey key = new AuthenticationKey(); try { key.readFields(new DataInputStream(new ByteArrayInputStream(data))); } catch (IOException e) { throw new AssertionError("Error reading from in-memory buffer which should not happen", e); } keys.add(key); } } return keys; } ZooAuthenticationKeyDistributor(ZooReaderWriter zk, String baseNode); synchronized void initialize(); List<AuthenticationKey> getCurrentKeys(); synchronized void advertise(AuthenticationKey newKey); synchronized void remove(AuthenticationKey key);  }### Answer:
@Test(expected = IllegalStateException.class) public void testInitializedNotCalledCurrentKeys() throws Exception { ZooAuthenticationKeyDistributor distributor = new ZooAuthenticationKeyDistributor(zrw, baseNode); distributor.getCurrentKeys(); }
@Test public void testGetCurrentKeys() throws Exception { ZooAuthenticationKeyDistributor distributor = new ZooAuthenticationKeyDistributor(zrw, baseNode); List<AuthenticationKey> keys = new ArrayList<>(5); List<byte[]> serializedKeys = new ArrayList<>(5); List<String> children = new ArrayList<>(5); for (int i = 1; i < 6; i++) { children.add(Integer.toString(i)); AuthenticationKey key = new AuthenticationKey(i, 0L, 10L, keyGen.generateKey()); keys.add(key); ByteArrayOutputStream baos = new ByteArrayOutputStream(); key.write(new DataOutputStream(baos)); serializedKeys.add(baos.toByteArray()); } expect(zrw.exists(baseNode)).andReturn(true); expect(zrw.getACL(eq(baseNode), anyObject(Stat.class))).andReturn(Collections.singletonList( new ACL(ZooUtil.PRIVATE.get(0).getPerms(), new Id("digest", "accumulo:DEFAULT")))); expect(zrw.getChildren(baseNode)).andReturn(children); for (int i = 1; i < 6; i++) { expect(zrw.getData(baseNode + "/" + i, null)).andReturn(serializedKeys.get(i - 1)); } replay(zrw); distributor.initialize(); assertEquals(keys, distributor.getCurrentKeys()); verify(zrw); }