### Question:
NameService { public static List<NameService> fromConfig(ConfigHelper config, Cluster cluster) { return nameServiceIds(config, cluster).stream() .map(nameServiceId -> nameService(nameServiceId, config, cluster)) .collect(Collectors.toList()); } private  NameService(String nameServiceId, List<NameNode> nameNodes); static List<NameService> fromConfig(ConfigHelper config, Cluster cluster); List<NameNode> getNameNodes(); @Override String toString(); final String nameServiceId; }### Answer:
@Test public void testParseFederatedNameService() { defineHdfsProperty("dfs.internal.nameservices", "ns1,ns2"); defineHdfsProperty("dfs.ha.namenodes.ns1", "nn1,nn2"); defineHdfsProperty("dfs.ha.namenodes.ns2", "nn3,nn4"); defineHdfsProperty("dfs.namenode.http-address.ns1.nn1", "c6401:1234"); defineHdfsProperty("dfs.namenode.http-address.ns1.nn2", "c6402:1234"); defineHdfsProperty("dfs.namenode.http-address.ns2.nn3", "c6403:1234"); defineHdfsProperty("dfs.namenode.http-address.ns2.nn4", "c6404:1234"); replay(config); assertThat(NameService.fromConfig(config, cluster), hasOnlyItems( hasNameNodes(hasOnlyItems(hasHost("c6401"), hasHost("c6402"))), hasNameNodes(hasOnlyItems(hasHost("c6403"), hasHost("c6404"))) )); }
@Test public void tesEmptyWhenNameServiceIdIsMissingFromConfig() { defineHdfsProperty("dfs.internal.nameservices", null); replay(config); assertThat(NameService.fromConfig(config, cluster), hasSize(0)); }