@Test
    public void convertInstancesToProviders() {
        Instance instance = new Instance();
        instance.setClusterName(NacosRegistryHelper.DEFAULT_CLUSTER);
        instance.setIp("1.1.1.1");
        instance.setPort(12200);
        instance.setServiceName("com.alipay.xxx.TestService");

        List<ProviderInfo> providerInfos = NacosRegistryHelper
            .convertInstancesToProviders(Lists.newArrayList(instance));
        assertNotNull(providerInfos);
        assertEquals(1, providerInfos.size());

        ProviderInfo providerInfo = providerInfos.get(0);
        assertNotNull(providerInfo);
        assertEquals(instance.getIp(), providerInfo.getHost());
        assertEquals(instance.getPort(), providerInfo.getPort());

        assertEquals(RpcConfigs.getStringValue(RpcOptions.DEFAULT_PROTOCOL), providerInfo.getProtocolType());

        Map<String, String> metaData = Maps.newHashMap();
        metaData.put(RpcConstants.CONFIG_KEY_PROTOCOL, RpcConstants.PROTOCOL_TYPE_REST);
        instance.setMetadata(metaData);

        providerInfos = NacosRegistryHelper.convertInstancesToProviders(Lists.newArrayList(instance));
        providerInfo = providerInfos.get(0);
        assertEquals(RpcConstants.PROTOCOL_TYPE_REST, providerInfo.getProtocolType());
    }
@author zhuoyu.sjw
@version $Id: NacosRegistryHelperTest.java, v 0.1 2018-12-07 19:22 zhuoyu.sjw Exp $$
registry/registry-nacos/src/test/java/com/alipay/sofa/rpc/registry/nacos/NacosRegistryHelperTest.java