@Override
    public List<ProviderGroup> subscribe(ConsumerConfig config) {
        String directUrl = config.getDirectUrl();
        if (StringUtils.isNotBlank(directUrl)) {
            List<ConsumerConfig> listeners = notifyListeners.get(directUrl);
            if (listeners == null) {
                notifyListeners.putIfAbsent(directUrl, new CopyOnWriteArrayList<>());
                listeners = notifyListeners.get(directUrl);
            }
            listeners.add(config);
            ProviderGroup directGroup = getDirectGroup(directUrl);
            ArrayList<ProviderGroup> providerGroups = new ArrayList<>();
            providerGroups.add(directGroup);
            return providerGroups;
        } else {
            return null;
        }
    }
@Test
    public void testSubscribe() {
        ConsumerConfig<Object> consumerConfig = new ConsumerConfig<>();
        String directUrl = "bolt://alipay.com";
        consumerConfig.setDirectUrl(directUrl);
        List<ProviderGroup> providerGroups = domainRegistry.subscribe(consumerConfig);
        assertTrue(domainRegistry.notifyListeners.containsKey(directUrl));
        assertSame(consumerConfig, domainRegistry.notifyListeners.get(directUrl).get(0));

        assertEquals(1, providerGroups.size());
        ProviderGroup providerGroup = providerGroups.get(0);
        assertEquals(RpcConstants.ADDRESS_DIRECT_GROUP, providerGroup.getName());


        ConsumerConfig<Object> notDirect = new ConsumerConfig<>();
        notDirect.setDirectUrl("");
        domainRegistry.subscribe(notDirect);
        assertFalse(domainRegistry.notifyListeners.containsKey(""));

        ConsumerConfig<Object> ipConfig = new ConsumerConfig<>();
        String ip = "bolt://127.0.0.1";
        ipConfig.setDirectUrl(ip);
        List<ProviderGroup> ipProviderGroup = domainRegistry.subscribe(ipConfig);
        assertTrue(domainRegistry.notifyListeners.containsKey(directUrl));
        assertSame(consumerConfig, domainRegistry.notifyListeners.get(directUrl).get(0));

        assertEquals(1, ipProviderGroup.size());
        ProviderGroup ipGroup = ipProviderGroup.get(0);
        assertEquals(RpcConstants.ADDRESS_DIRECT_GROUP, ipGroup.getName());
        assertEquals(1, ipGroup.getProviderInfos().size());
        assertEquals("127.0.0.1", ipGroup.getProviderInfos().get(0).getHost());
    }