JobNodeStorage { public void addDataListener(final TreeCacheListener listener) { TreeCache cache = (TreeCache) coordinatorRegistryCenter.getRawCache("/" + jobConfiguration.getJobName()); cache.getListenable().addListener(listener); } JobNodeStorage(final CoordinatorRegistryCenter coordinatorRegistryCenter, final JobConfiguration jobConfiguration); boolean isJobNodeExisted(final String node); String getJobNodeData(final String node); String getJobNodeDataDirectly(final String node); List<String> getJobNodeChildrenKeys(final String node); void createJobNodeIfNeeded(final String node); void removeJobNodeIfExisted(final String node); void fillJobNodeIfNullOrOverwrite(final String node, final Object value); void fillEphemeralJobNode(final String node, final Object value); void updateJobNode(final String node, final Object value); void replaceJobNode(final String node, final Object value); void executeInTransaction(final TransactionExecutionCallback callback); void executeInLeader(final String latchNode, final LeaderExecutionCallback callback); void addConnectionStateListener(final ConnectionStateListener listener); void addDataListener(final TreeCacheListener listener); long getRegistryCenterTime();  }
@Test public void assertAddDataListener() { TreeCache treeCache = mock(TreeCache.class); @SuppressWarnings("unchecked") Listenable<TreeCacheListener> listeners = mock(Listenable.class); TreeCacheListener listener = mock(TreeCacheListener.class); when(treeCache.getListenable()).thenReturn(listeners); when(coordinatorRegistryCenter.getRawCache("/testJob")).thenReturn(treeCache); jobNodeStorage.addDataListener(listener); verify(listeners).addListener(listener); }