@Override
    protected String buildHandle(final List<URIRegisterDTO> uriList, final SelectorDO selectorDO) {
        List<DivideUpstream> addList = buildDivideUpstreamList(uriList);
        List<DivideUpstream> canAddList = new CopyOnWriteArrayList<>();
        boolean isEventDeleted = uriList.size() == 1 && EventType.DELETED.equals(uriList.get(0).getEventType());
        if (isEventDeleted) {
            addList.get(0).setStatus(false);
        }

        SpringCloudSelectorHandle springCloudSelectorHandle = GsonUtils.getInstance().fromJson(selectorDO.getHandle(), SpringCloudSelectorHandle.class);
        List<DivideUpstream> existList = springCloudSelectorHandle.getDivideUpstreams();
        if (CollectionUtils.isEmpty(existList)) {
            canAddList = addList;
        } else {
            List<DivideUpstream> diffList = addList.stream().filter(upstream -> !existList.contains(upstream)).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(diffList)) {
                canAddList.addAll(diffList);
                existList.addAll(diffList);
            }
            List<DivideUpstream> diffStatusList = addList.stream().filter(upstream -> !upstream.isStatus()
                    || existList.stream().anyMatch(e -> e.equals(upstream) && e.isStatus() != upstream.isStatus())).collect(Collectors.toList());
            if (CollectionUtils.isNotEmpty(diffStatusList)) {
                canAddList.addAll(diffStatusList);
            }
        }

        if (doSubmit(selectorDO.getId(), canAddList)) {
            return null;
        }
        springCloudSelectorHandle.setDivideUpstreams(CollectionUtils.isEmpty(existList) ? canAddList : existList);
        return GsonUtils.getInstance().toJson(springCloudSelectorHandle);
    }
@Test
    public void testBuildHandle() {
        shenyuClientRegisterSpringCloudService = spy(shenyuClientRegisterSpringCloudService);
        
        final String returnStr = "{serviceId:'test1',gray:false,divideUpstreams:[{weight:50,warmup:10,protocol:"
                + "'http://',upstreamHost:'localhost',upstreamUrl:'localhost:8090',status:'true',timestamp:1637909490935}]}";
        final String expected = "{\"serviceId\":\"test1\",\"gray\":false,\"divideUpstreams\":[{\"weight\":50,\"warmup\":10,\"protocol\":"
                + "\"http://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:8090\",\"status\":true,\"timestamp\":1637909490935}]}";
        final URIRegisterDTO dto1 = URIRegisterDTO.builder().appName("test2")
                .rpcType(RpcTypeEnum.SPRING_CLOUD.getName())
                .host(HOST).port(8090).build();
        final URIRegisterDTO dto2 = URIRegisterDTO.builder().appName("test2")
                .rpcType(RpcTypeEnum.SPRING_CLOUD.getName())
                .host(HOST).port(8091).build();
        
        List<URIRegisterDTO> list = new ArrayList<>();
        list.add(dto1);
        SelectorDO selectorDO = mock(SelectorDO.class);
        doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), any());
        when(selectorDO.getHandle()).thenReturn(returnStr);
        String actual = shenyuClientRegisterSpringCloudService.buildHandle(list, selectorDO);
        assertEquals(expected, actual);
        SpringCloudSelectorHandle handle = GsonUtils.getInstance().fromJson(actual, SpringCloudSelectorHandle.class);
        assertEquals(handle.getDivideUpstreams().size(), 1);

        list.clear();
        list.add(dto1);
        list.add(dto2);
        selectorDO = mock(SelectorDO.class);
        doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), any());
        when(selectorDO.getHandle()).thenReturn(returnStr);
        actual = shenyuClientRegisterSpringCloudService.buildHandle(list, selectorDO);
        handle = GsonUtils.getInstance().fromJson(actual, SpringCloudSelectorHandle.class);
        assertEquals(handle.getDivideUpstreams().size(), 2);

        list.clear();
        list.add(dto1);
        selectorDO = mock(SelectorDO.class);
        doReturn(false).when(shenyuClientRegisterSpringCloudService).doSubmit(any(), any());
        when(selectorDO.getHandle()).thenReturn("{serviceId:'test1',gray:false,divideUpstreams:[]}");
        actual = shenyuClientRegisterSpringCloudService.buildHandle(list, selectorDO);
        handle = GsonUtils.getInstance().fromJson(actual, SpringCloudSelectorHandle.class);
        assertEquals(handle.getDivideUpstreams().size(), 1);
    }