@Test
    public void convertProviderToInstances() {
        ServerConfig serverConfig = new ServerConfig()
            .setProtocol("bolt")
            .setHost("0.0.0.0")
            .setPort(12200);

        ProviderConfig<?> provider = new ProviderConfig();
        provider.setInterfaceId("com.alipay.xxx.TestService")
            .setApplication(new ApplicationConfig().setAppName("test-server"))
            .setUniqueId("nacos-test")
            .setProxy("javassist")
            .setRegister(true)
            .setSerialization("hessian2")
            .setServer(serverConfig)
            .setWeight(222)
            .setTimeout(3000);

        List<Instance> instances = NacosRegistryHelper.convertProviderToInstances(provider);
        assertNotNull(instances);
        assertEquals(1, instances.size());

        Instance instance = instances.get(0);
        assertNotNull(instance);
        assertEquals(NacosRegistryHelper.DEFAULT_CLUSTER, instance.getClusterName());
        assertEquals(serverConfig.getPort(), instance.getPort());
        assertEquals(serverConfig.getProtocol(), instance.getMetadata().get(RpcConstants.CONFIG_KEY_PROTOCOL));
        assertEquals(provider.getSerialization(), instance.getMetadata().get(RpcConstants.CONFIG_KEY_SERIALIZATION));
        assertEquals(provider.getUniqueId(), instance.getMetadata().get(RpcConstants.CONFIG_KEY_UNIQUEID));
        assertEquals(provider.getWeight(),
            Integer.parseInt(instance.getMetadata().get(RpcConstants.CONFIG_KEY_WEIGHT)));
        assertEquals(provider.getTimeout(),
            Integer.parseInt(instance.getMetadata().get(RpcConstants.CONFIG_KEY_TIMEOUT)));
        assertEquals(provider.getSerialization(), instance.getMetadata().get(RpcConstants.CONFIG_KEY_SERIALIZATION));
        assertEquals(provider.getAppName(), instance.getMetadata().get(RpcConstants.CONFIG_KEY_APP_NAME));
        assertEquals("com.alipay.xxx.TestService:nacos-test:DEFAULT", instance.getServiceName());
    }
@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