ServerStatisticsAPIImpl implements ServerStatisticsAPI { @Override public int getServersTotalCount() { Set<String> servers = new HashSet<>(); for (String jobName : regCenter.getChildrenKeys("/")) { JobNodePath jobNodePath = new JobNodePath(jobName); servers.addAll(regCenter.getChildrenKeys(jobNodePath.getServerNodePath())); } return servers.size(); }  @Override int getServersTotalCount(); @Override Collection<ServerBriefInfo> getAllServersBriefInfo();  }
@Test public void assertGetJobsTotalCount() { when(regCenter.getChildrenKeys("/")).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.getChildrenKeys("/test_job_1/servers")).thenReturn(Arrays.asList("ip1", "ip2")); when(regCenter.getChildrenKeys("/test_job_2/servers")).thenReturn(Arrays.asList("ip2", "ip3")); assertThat(serverStatisticsAPI.getServersTotalCount(), is(3)); }