ServiceInstanceMetadataUtils { public static String getMetadataServiceParameter(List<URL> urls) { Map<String, Map<String, String>> params = new HashMap<>(); urls.stream() .map(url -> url.removeParameter(APPLICATION_KEY)) .map(url -> url.removeParameter(GROUP_KEY)) .map(url -> url.removeParameter(DEPRECATED_KEY)) .map(url -> url.removeParameter(TIMESTAMP_KEY)) .forEach(url -> { String protocol = url.getProtocol(); params.put(protocol, getParams(url)); }); if (params.isEmpty()) { return null; } return JSON.toJSONString(params); }  static Map<String, Map<String, String>> getMetadataServiceURLsParams(ServiceInstance serviceInstance); static Map<String, String> getMetadataServiceURLParams(ServiceInstance serviceInstance, String protocol); static String getMetadataServiceParameter(List<URL> urls); static String getExportedServicesRevision(ServiceInstance serviceInstance); static String getMetadataStorageType(URL registryURL); static String getMetadataStorageType(ServiceInstance serviceInstance); static void setMetadataStorageType(ServiceInstance serviceInstance, String metadataType); static String getRemoteCluster(ServiceInstance serviceInstance); static boolean isDubboServiceInstance(ServiceInstance serviceInstance); static void setEndpoints(ServiceInstance serviceInstance, Map<String, Integer> protocolPorts); static Integer getProtocolPort(ServiceInstance serviceInstance, String protocol); static void calInstanceRevision(ServiceDiscovery serviceDiscovery, ServiceInstance instance); static boolean isInstanceUpdated(ServiceInstance instance); static void refreshMetadataAndInstance(); static final String METADATA_SERVICE_PREFIX; static final String ENDPOINTS; static String METADATA_SERVICE_URL_PARAMS_PROPERTY_NAME; static final String METADATA_SERVICE_URLS_PROPERTY_NAME; static String EXPORTED_SERVICES_REVISION_PROPERTY_NAME; static String METADATA_STORAGE_TYPE_PROPERTY_NAME; static String METADATA_CLUSTER_PROPERTY_NAME; static String INSTANCE_REVISION_UPDATED_KEY; }
@Test public void testMetadataServiceURLParameters() { List<URL> urls = Arrays.asList(url, url2); String parameter = ServiceInstanceMetadataUtils.getMetadataServiceParameter(urls); JSONObject jsonObject = JSON.parseObject(parameter); urls.forEach(url -> { JSONObject map = jsonObject.getJSONObject(url.getProtocol()); for (Map.Entry<String, String> param : url.getParameters().entrySet()) { String value = map.getString(param.getKey()); if (value != null) { assertEquals(param.getValue(), value); } } }); assertEquals(VALUE, parameter); }