@Override
    public synchronized void loadApiDocument() {
        if (!isEnabledLoad()) {
            return;
        }
        List<UpstreamInstance> serviceList = this.getAllClusterLastUpdateInstanceList();
        if (CollectionUtils.isEmpty(serviceList)) {
            LOG.info("load api document No service registered.");
            return;
        }
        final Set<UpstreamInstance> currentServices = new HashSet<>(serviceList);
        LOG.info("load api document, serviceList={}", JsonUtils.toJson(currentServices));
        pullSwaggerDocService.pullApiDocument(currentServices);
    }
@Test
    public void testLoadApiDocument() {
        ShenyuDictVO shenyuInitData = new ShenyuDictVO();
        shenyuInitData.setDictValue("true");
        when(shenyuDictService.findByDictCodeName(any(), any())).thenReturn(shenyuInitData);
        List<PluginDO> pluginDOList = new ArrayList<>();
        PluginDO pluginDO = new PluginDO();
        pluginDO.setId("1");
        pluginDO.setName("test");
        pluginDOList.add(pluginDO);
        CommonPager<SelectorVO> commonPager = new CommonPager<>();
        List<SelectorVO> list = new ArrayList<>();
        String dateString = "2023-05-06 03:48:48";
        SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        SimpleDateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
        Date date = null;
        try {
            date = inputFormat.parse(dateString);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        String formattedDateString = outputFormat.format(date);
        SelectorVO selectorVO = new SelectorVO(
                "1",
                "1",
                "test",
                1,
                "testMatchMode",
                1,
                "testType",
                1,
                true,
                true,
                true,
                true,
                "[{\"weight\":1}]",
                new ArrayList<>(),
                formattedDateString,
                formattedDateString,
                SYS_DEFAULT_NAMESPACE_ID
        );
        list.add(selectorVO);
        commonPager.setDataList(list);
        commonPager.setPage(new PageParameter(1, 1));
        List<CommonUpstream> upstreamList = new ArrayList<>();
        upstreamList.add(new CommonUpstream("testProtocol", "testUpstreamHost", "testUrl", true, 1000L));
        DiscoveryUpstreamData discoveryUpstreamData = new DiscoveryUpstreamData();
        discoveryUpstreamData.setUrl("127.0.0.1:8080");
        discoveryUpstreamData.setProps("{}");
        discoveryUpstreamData.setDiscoveryHandlerId("1");
        discoveryUpstreamData.setStatus(0);
        when(selectorService.listByPage(any())).thenReturn(commonPager);
        when(pluginMapper.selectByNames(any())).thenReturn(pluginDOList);
        when(discoveryUpstreamService.findBySelectorId(any())).thenReturn(Collections.singletonList(discoveryUpstreamData));
        loadServiceDocEntry.loadApiDocument();
        verify(pullSwaggerDocService).pullApiDocument((Set<UpstreamInstance>) any());
    }