SpringCloudMetadataServiceURLBuilder implements MetadataServiceURLBuilder { @Override public List<URL> build(ServiceInstance serviceInstance) { Map<String, String> metadata = serviceInstance.getMetadata(); String dubboURLsJSON = metadata.get(METADATA_SERVICE_URLS_PROPERTY_NAME); if (StringUtils.isBlank(dubboURLsJSON)) { return Collections.emptyList(); } List<String> urlStrings = JSON.parseArray(dubboURLsJSON, String.class); return urlStrings.stream().map(URL::valueOf).collect(Collectors.toList()); }  @Override List<URL> build(ServiceInstance serviceInstance); static final String NAME; }
@Test public void testBuild() { List<URL> urls = builder.build(new DefaultServiceInstance("127.0.0.1", "test", 8080)); assertEquals(0, urls.size()); urls = builder.build(serviceInstance); assertEquals(1, urls.size()); URL url = urls.get(0); assertEquals("192.168.0.102", url.getHost()); assertEquals(20881, url.getPort()); assertEquals("com.alibaba.cloud.dubbo.service.DubboMetadataService", url.getServiceInterface()); }