NacosRegistryHelper { static String buildServiceName(AbstractInterfaceConfig config, String protocol) { if (RpcConstants.PROTOCOL_TYPE_BOLT.equals(protocol) || RpcConstants.PROTOCOL_TYPE_TR.equals(protocol)) { return ConfigUniqueNameGenerator.getServiceName(config) + ":DEFAULT"; } else { return ConfigUniqueNameGenerator.getServiceName(config) + ":" + protocol; } }    }
@Test public void buildServiceName() { 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); String serviceName = NacosRegistryHelper.buildServiceName(provider, RpcConstants.PROTOCOL_TYPE_BOLT); assertEquals(serviceName, "com.alipay.xxx.TestService:nacos-test:DEFAULT"); serviceName = NacosRegistryHelper.buildServiceName(provider, RpcConstants.PROTOCOL_TYPE_TR); assertEquals(serviceName, "com.alipay.xxx.TestService:nacos-test:DEFAULT"); serviceName = NacosRegistryHelper.buildServiceName(provider, RpcConstants.PROTOCOL_TYPE_TRIPLE); assertEquals(serviceName, "com.alipay.xxx.TestService:nacos-test:" + RpcConstants.PROTOCOL_TYPE_TRIPLE); serviceName = NacosRegistryHelper.buildServiceName(provider, RpcConstants.PROTOCOL_TYPE_REST); assertEquals(serviceName, "com.alipay.xxx.TestService:nacos-test:" + RpcConstants.PROTOCOL_TYPE_REST); }