@Override
    public void close() {
        if (Objects.nonNull(zkClient)) {
            zkClient.close();
        }
    }
@Test
    public void testZookeeperInstanceRegisterRepository() throws Exception {

        ZookeeperClient zkClient = mock(ZookeeperClient.class);
        PluginDataSubscriber pluginDataSubscriber = mock(PluginDataSubscriber.class);

        List<TreeCacheListener> treeCacheListeners = new ArrayList<>();
        doAnswer(invocationOnMock -> {
            treeCacheListeners.add(invocationOnMock.getArgument(1));
            return null;
        }).when(zkClient).addCache(any(), any());
        final AuthDataSubscriber authDataSubscriber = mock(AuthDataSubscriber.class);
        final MetaDataSubscriber metaDataSubscriber = mock(MetaDataSubscriber.class);
        final ProxySelectorDataSubscriber proxySelectorDataSubscriber = mock(ProxySelectorDataSubscriber.class);
        final DiscoveryUpstreamDataSubscriber discoveryUpstreamDataSubscriber = mock(DiscoveryUpstreamDataSubscriber.class);
        final ZookeeperSyncDataService zookeeperSyncDataService = new ZookeeperSyncDataService(zkClient,
                pluginDataSubscriber, Collections.singletonList(metaDataSubscriber), Collections.singletonList(authDataSubscriber),
                Collections.singletonList(proxySelectorDataSubscriber), Collections.singletonList(discoveryUpstreamDataSubscriber));

        List<TreeCacheEvent> treeCacheEvents = new ArrayList<>();
        // register uri
        treeCacheEvents.add(treeCacheEvent("/shenyu/uri/test/test/test", TreeCacheEvent.Type.NODE_REMOVED));
        // register metadata
        treeCacheEvents.add(treeCacheEvent("/shenyu/metaData/test", TreeCacheEvent.Type.NODE_REMOVED));
        // register auth
        treeCacheEvents.add(treeCacheEvent("/shenyu/auth/test", TreeCacheEvent.Type.NODE_REMOVED));
        // register rule
        treeCacheEvents.add(treeCacheEvent("/shenyu/rule/test/test-1", TreeCacheEvent.Type.NODE_REMOVED));
        // register plugin
        treeCacheEvents.add(treeCacheEvent("/shenyu/plugin/test", TreeCacheEvent.Type.NODE_REMOVED));
        // register selector
        treeCacheEvents.add(treeCacheEvent("/shenyu/selector/test/test", TreeCacheEvent.Type.NODE_REMOVED));

        final CuratorFramework curatorFramework = mock(CuratorFramework.class);
        for (TreeCacheListener treeCacheListener : treeCacheListeners) {
            for (TreeCacheEvent event : treeCacheEvents) {
                treeCacheListener.childEvent(curatorFramework, event);
            }
        }
        final TreeCacheListener treeCacheListener = treeCacheListeners.stream().findFirst().orElse(null);
        if (Objects.nonNull(treeCacheListener)) {
            TreeCacheEvent event = mock(TreeCacheEvent.class);
            ChildData childData = mock(ChildData.class);
            treeCacheListener.childEvent(curatorFramework, event);
            when(event.getData()).thenReturn(childData);
            when(childData.getPath()).thenReturn("");
            treeCacheListener.childEvent(curatorFramework, event);
        }

        zookeeperSyncDataService.close();
    }