JobNodeStorage { public void removeJobNodeIfExisted(final String node) { if (isJobNodeExisted(node)) { coordinatorRegistryCenter.remove(jobNodePath.getFullPath(node)); } } 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 assertRemoveJobNodeIfNeeded() { when(coordinatorRegistryCenter.isExisted("/testJob/config")).thenReturn(true); jobNodeStorage.removeJobNodeIfExisted("config"); verify(coordinatorRegistryCenter).isExisted("/testJob/config"); verify(coordinatorRegistryCenter).remove("/testJob/config"); }
@Test public void assertRemoveJobNodeIfNotNeeded() { when(coordinatorRegistryCenter.isExisted("/testJob/config")).thenReturn(false); jobNodeStorage.removeJobNodeIfExisted("config"); verify(coordinatorRegistryCenter).isExisted("/testJob/config"); verify(coordinatorRegistryCenter, times(0)).remove("/testJob/config"); }