@Override
    public ObjectNode queryService(String namespaceId, String serviceName) throws NacosException {
        Service service = getServiceFromGroupedServiceName(namespaceId, serviceName, true);
        if (!ServiceManager.getInstance().containSingleton(service)) {
            throw new NacosApiException(NacosException.INVALID_PARAM, ErrorCode.SERVICE_NOT_EXIST,
                    "service not found, namespace: " + namespaceId + ", serviceName: " + serviceName);
        }
        ObjectNode result = JacksonUtils.createEmptyJsonNode();
        ServiceMetadata serviceMetadata = metadataManager.getServiceMetadata(service).orElse(new ServiceMetadata());
        setServiceMetadata(result, serviceMetadata, service);
        ArrayNode clusters = JacksonUtils.createEmptyArrayNode();
        for (String each : serviceStorage.getClusters(service)) {
            ClusterMetadata clusterMetadata =
                    serviceMetadata.getClusters().containsKey(each) ? serviceMetadata.getClusters().get(each)
                            : new ClusterMetadata();
            clusters.add(newClusterNode(each, clusterMetadata));
        }
        result.set(FieldsConstants.CLUSTERS, clusters);
        return result;
    }
@Test
    void testQueryService() throws NacosException {
        ClusterMetadata clusterMetadata = new ClusterMetadata();
        Map<String, ClusterMetadata> clusterMetadataMap = new HashMap<>(2);
        clusterMetadataMap.put("D", clusterMetadata);
        ServiceMetadata metadata = new ServiceMetadata();
        metadata.setClusters(clusterMetadataMap);
        Mockito.when(metadataManager.getServiceMetadata(Mockito.any())).thenReturn(Optional.of(metadata));
        
        Mockito.when(serviceStorage.getClusters(Mockito.any())).thenReturn(Collections.singleton("D"));
        
        ObjectNode objectNode = serviceOperatorV2.queryService("A", "B@@C");
        
        assertEquals("A", objectNode.get(FieldsConstants.NAME_SPACE_ID).asText());
        assertEquals("C", objectNode.get(FieldsConstants.NAME).asText());
        assertEquals(1, objectNode.get(FieldsConstants.CLUSTERS).size());
    }