EtcdMetadataReport extends AbstractMetadataReport { @Override protected void doSaveSubscriberData(SubscriberMetadataIdentifier subscriberMetadataIdentifier, String urlListStr) { String key = getNodeKey(subscriberMetadataIdentifier); if (!etcdClient.put(key, urlListStr)) { logger.error("Failed to put " + subscriberMetadataIdentifier + " to etcd, value: " + urlListStr); } } EtcdMetadataReport(URL url); @Override String getServiceDefinition(MetadataIdentifier metadataIdentifier);  }
@Test public void testDoSaveSubscriberData() throws ExecutionException, InterruptedException { String version = "1.0.0"; String group = null; String application = "etc-metadata-report-consumer-test"; String revision = "90980"; String protocol = "xxx"; URL url = generateURL(TEST_SERVICE, version, group, application); SubscriberMetadataIdentifier subscriberMetadataIdentifier = new SubscriberMetadataIdentifier(application, revision); Gson gson = new Gson(); String r = gson.toJson(Arrays.asList(url)); etcdMetadataReport.doSaveSubscriberData(subscriberMetadataIdentifier, r); CompletableFuture<GetResponse> response = etcdClientForTest.getKVClient().get(ByteSequence.from( etcdMetadataReport.getNodeKey(subscriberMetadataIdentifier), StandardCharsets.UTF_8)); String fileContent = response.get().getKvs().get(0).getValue().toString(StandardCharsets.UTF_8); Assertions.assertNotNull(fileContent); Assertions.assertEquals(fileContent, r); }