@Override
    public Boolean exists(final String key) {
        try {
            List<Instance> instances = namingService.selectInstances(key, groupName, true);
            return !instances.isEmpty();
        } catch (NacosException e) {
            LOGGER.error("Error checking Nacos service existence: {}", e.getMessage(), e);
            throw new ShenyuException(e);
        }
    }
@Test
    void testExists() throws NacosException {
        List<Instance> mockInstances = new ArrayList<>();
        mockInstances.add(mock(Instance.class));
        // Mock this service exists
        when(namingService.selectInstances(anyString(), anyString(), anyBoolean())).thenReturn(mockInstances);
        assertTrue(nacosDiscoveryServiceUnderTest.exists("key"));
        // Mock the service does not exist
        when(namingService.selectInstances(anyString(), anyString(), anyBoolean())).thenReturn(Collections.emptyList());
        assertFalse(nacosDiscoveryServiceUnderTest.exists("key"));
        // Mock the throwing of NacosException
        when(namingService.selectInstances(anyString(), anyString(), anyBoolean())).thenThrow(new NacosException());
        assertThrows(ShenyuException.class, () -> nacosDiscoveryServiceUnderTest.exists("key"));
    }