### Question:
WorkerRegistry { public void registry() { String address = NetUtils.getHost(); Set<String> workerZkPaths = getWorkerZkPaths(); int workerHeartbeatInterval = workerConfig.getWorkerHeartbeatInterval(); for (String workerZKPath : workerZkPaths) { zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath, ""); zookeeperRegistryCenter.getZookeeperCachedOperator().getZkClient().getConnectionStateListenable().addListener(new ConnectionStateListener() { @Override public void stateChanged(CuratorFramework client, ConnectionState newState) { if (newState == ConnectionState.LOST) { logger.error("worker : {} connection lost from zookeeper", address); } else if (newState == ConnectionState.RECONNECTED) { logger.info("worker : {} reconnected to zookeeper", address); zookeeperRegistryCenter.getZookeeperCachedOperator().persistEphemeral(workerZKPath, ""); } else if (newState == ConnectionState.SUSPENDED) { logger.warn("worker : {} connection SUSPENDED ", address); } } }); logger.info("worker node : {} registry to ZK {} successfully", address, workerZKPath); } HeartBeatTask heartBeatTask = new HeartBeatTask(this.startTime, this.workerConfig.getWorkerReservedMemory(), this.workerConfig.getWorkerMaxCpuloadAvg(), workerZkPaths, this.zookeeperRegistryCenter); this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, workerHeartbeatInterval, workerHeartbeatInterval, TimeUnit.SECONDS); logger.info("worker node : {} heartbeat interval {} s", address, workerHeartbeatInterval); }  @PostConstruct void init(); void registry(); void unRegistry();  }### Answer:
@Test public void testRegistry() { workerRegistry.init(); workerRegistry.registry(); String workerPath = zookeeperRegistryCenter.getWorkerPath(); int i = 0; for (String workerGroup : workerConfig.getWorkerGroups()) { String workerZkPath = workerPath + "/" + workerGroup.trim() + "/" + (NetUtils.getHost() + ":" + workerConfig.getListenPort()); String heartbeat = zookeeperRegistryCenter.getZookeeperCachedOperator().get(workerZkPath); if (0 == i) { Assert.assertTrue(workerZkPath.startsWith("/dolphinscheduler/nodes/worker/test/")); } else { Assert.assertTrue(workerZkPath.startsWith("/dolphinscheduler/nodes/worker/default/")); } i++; } workerRegistry.unRegistry(); workerConfig.getWorkerGroups().add(StringUtils.EMPTY); workerRegistry.init(); workerRegistry.registry(); workerRegistry.unRegistry(); workerConfig.getWorkerGroups().remove(StringUtils.EMPTY); workerConfig.getWorkerGroups().remove(TEST_WORKER_GROUP); workerConfig.getWorkerGroups().remove(DEFAULT_WORKER_GROUP); workerRegistry.init(); workerRegistry.registry(); List<String> testWorkerGroupPathZkChildren = zookeeperRegistryCenter.getChildrenKeys(workerPath + "/" + TEST_WORKER_GROUP); List<String> defaultWorkerGroupPathZkChildren = zookeeperRegistryCenter.getChildrenKeys(workerPath + "/" + DEFAULT_WORKER_GROUP); Assert.assertEquals(0, testWorkerGroupPathZkChildren.size()); Assert.assertEquals(0, defaultWorkerGroupPathZkChildren.size()); workerRegistry.unRegistry(); }