### Question:
ZooCache { public List<String> getChildren(final String zPath) { Preconditions.checkState(!closed); ZooRunnable<List<String>> zr = new ZooRunnable<>() { @Override public List<String> run() throws KeeperException, InterruptedException { ImmutableCacheCopies lic = immutableCache; if (lic.childrenCache.containsKey(zPath)) { return lic.childrenCache.get(zPath); } cacheWriteLock.lock(); try { if (childrenCache.containsKey(zPath)) { return childrenCache.get(zPath); } final ZooKeeper zooKeeper = getZooKeeper(); List<String> children = zooKeeper.getChildren(zPath, watcher); if (children != null) { children = List.copyOf(children); } childrenCache.put(zPath, children); immutableCache = new ImmutableCacheCopies(++updateCount, immutableCache, childrenCache); return children; } catch (KeeperException ke) { if (ke.code() != Code.NONODE) { throw ke; } } finally { cacheWriteLock.unlock(); } return null; } }; return zr.retry(); } ZooCache(String zooKeepers, int sessionTimeout);  ZooCache(String zooKeepers, int sessionTimeout, Watcher watcher);  ZooCache(ZooReader reader);  ZooCache(ZooReader reader, Watcher watcher); List<String> getChildren(final String zPath); byte[] get(final String zPath); byte[] get(final String zPath, final ZcStat status); void clear(); void close(); long getUpdateCount(); void clear(String zPath); byte[] getLockData(String path);  }### Answer:
@Test public void testGetChildren() throws Exception { expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))).andReturn(CHILDREN); replay(zk); assertFalse(zc.childrenCached(ZPATH)); assertEquals(CHILDREN, zc.getChildren(ZPATH)); verify(zk); assertTrue(zc.childrenCached(ZPATH)); assertEquals(CHILDREN, zc.getChildren(ZPATH)); }
@Test public void testGetChildren_NoKids() throws Exception { expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))).andReturn(null); replay(zk); assertNull(zc.getChildren(ZPATH)); verify(zk); assertNull(zc.getChildren(ZPATH)); }
@Test public void testGetChildren_Retry() throws Exception { expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))) .andThrow(new KeeperException.BadVersionException(ZPATH)); expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))).andReturn(CHILDREN); replay(zk); assertEquals(CHILDREN, zc.getChildren(ZPATH)); verify(zk); }
@Test public void testGetChildren_EatNoNode() throws Exception { expect(zk.getChildren(eq(ZPATH), anyObject(Watcher.class))) .andThrow(new KeeperException.NoNodeException(ZPATH)); replay(zk); assertNull(zc.getChildren(ZPATH)); verify(zk); }