### Question:
MetadataReportService { public void publishProvider(URL providerUrl) throws RpcException { providerUrl = providerUrl.removeParameters(Constants.PID_KEY, Constants.TIMESTAMP_KEY, Constants.BIND_IP_KEY, Constants.BIND_PORT_KEY, Constants.TIMESTAMP_KEY); try { String interfaceName = providerUrl.getParameter(Constants.INTERFACE_KEY); if (StringUtils.isNotEmpty(interfaceName)) { Class interfaceClass = Class.forName(interfaceName); FullServiceDefinition fullServiceDefinition = ServiceDefinitionBuilder.buildFullDefinition(interfaceClass, providerUrl.getParameters()); metadataReport.storeProviderMetadata(new MetadataIdentifier(providerUrl.getServiceInterface(), providerUrl.getParameter(Constants.VERSION_KEY), providerUrl.getParameter(Constants.GROUP_KEY), Constants.PROVIDER_SIDE,providerUrl.getParameter(Constants.APPLICATION_KEY)), fullServiceDefinition); return; } logger.error("publishProvider interfaceName is empty . providerUrl: " + providerUrl.toFullString()); } catch (ClassNotFoundException e) { logger.error("publishProvider getServiceDescriptor error. providerUrl: " + providerUrl.toFullString(), e); } } MetadataReportService(URL metadataReportURL); static MetadataReportService instance(Supplier<URL> metadataReportUrl); void publishProvider(URL providerUrl); void publishConsumer(URL consumerURL);  }### Answer:
@Test public void testPublishProviderNoInterfaceName() { URL publishUrl = URL.valueOf("dubbo: metadataReportService1.publishProvider(publishUrl); Assertions.assertTrue(metadataReportService1.metadataReport instanceof JTestMetadataReport4Test); JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.metadataReport; Assertions.assertTrue(!jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl))); }
@Test public void testPublishProviderWrongInterface() { URL publishUrl = URL.valueOf("dubbo: metadataReportService1.publishProvider(publishUrl); Assertions.assertTrue(metadataReportService1.metadataReport instanceof JTestMetadataReport4Test); JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.metadataReport; Assertions.assertTrue(!jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl))); }
@Test public void testPublishProviderContainInterface() throws InterruptedException { URL publishUrl = URL.valueOf("dubbo: metadataReportService1.publishProvider(publishUrl); Thread.sleep(300); Assertions.assertTrue(metadataReportService1.metadataReport instanceof JTestMetadataReport4Test); JTestMetadataReport4Test jTestMetadataReport4Test = (JTestMetadataReport4Test) metadataReportService1.metadataReport; Assertions.assertTrue(jTestMetadataReport4Test.store.containsKey(JTestMetadataReport4Test.getProviderKey(publishUrl))); String value = jTestMetadataReport4Test.store.get(JTestMetadataReport4Test.getProviderKey(publishUrl)); FullServiceDefinition fullServiceDefinition = toServiceDefinition(value); Map<String,String> map = fullServiceDefinition.getParameters(); Assertions.assertEquals(map.get("application"), "vicpubp"); Assertions.assertEquals(map.get("version"), "1.0.3"); Assertions.assertEquals(map.get("interface"), "org.apache.dubbo.metadata.integration.InterfaceNameTestService"); }