@Override
    public List<String> getRegisterData(final String key) {
        try {
            List<Instance> instances = namingService.selectInstances(key, groupName, true);
            List<String> registerData = new ArrayList<>();
            for (Instance instance : instances) {
                String data = buildUpstreamJsonFromInstance(instance);
                registerData.add(data);
            }
            return registerData;
        } catch (NacosException e) {
            LOGGER.error("Error getting Nacos service instances: {}", e.getMessage(), e);
            throw new ShenyuException(e);
        }
    }
@Test
    void testGetRegisterData() throws NacosException {
        final String key = "test";
        Instance instance1 = new Instance();
        instance1.setIp("192.168.1.1");
        instance1.setPort(8080);

        Instance instance2 = new Instance();
        instance2.setIp("192.168.1.2");
        instance2.setPort(8081);

        final List<Instance> mockInstances = Arrays.asList(instance1, instance2);
        when(namingService.selectInstances(key, "SHENYU_GROUP", true)).thenReturn(mockInstances);
        final List<String> result = nacosDiscoveryServiceUnderTest.getRegisterData(key);
        verify(namingService).selectInstances(key, "SHENYU_GROUP", true);

        // Verify that the data format is consistent
        assertEquals(mockInstances.size(), result.size());
        for (int i = 0; i < mockInstances.size(); i++) {
            Instance instance = mockInstances.get(i);
            String expectedJson = buildInstanceInfoJson(instance);
            assertEquals(expectedJson, result.get(i));
        }
    }