@Test public void assertLoadAllWithRootNode() { when(regCenter.isExisted("/config/job")).thenReturn(true); when(regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT)).thenReturn(Arrays.asList("test_job_1", "test_job_2")); when(regCenter.get("/config/job/test_job_1")).thenReturn(CloudJsonConstants.getJobJson("test_job_1")); Collection<CloudJobConfigurationPOJO> actual = configService.loadAll(); assertThat(actual.size(), is(1)); assertThat(actual.iterator().next().getJobName(), is("test_job_1")); verify(regCenter).isExisted("/config/job"); verify(regCenter).getChildrenKeys("/config/job"); verify(regCenter).get("/config/job/test_job_1"); verify(regCenter).get("/config/job/test_job_2"); }
public Collection<CloudJobConfigurationPOJO> loadAll() { if (!regCenter.isExisted(CloudJobConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> jobNames = regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT); Collection<CloudJobConfigurationPOJO> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { load(each).ifPresent(result::add); } return result; }
CloudJobConfigurationService { public Collection<CloudJobConfigurationPOJO> loadAll() { if (!regCenter.isExisted(CloudJobConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> jobNames = regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT); Collection<CloudJobConfigurationPOJO> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { load(each).ifPresent(result::add); } return result; } }
CloudJobConfigurationService { public Collection<CloudJobConfigurationPOJO> loadAll() { if (!regCenter.isExisted(CloudJobConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> jobNames = regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT); Collection<CloudJobConfigurationPOJO> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { load(each).ifPresent(result::add); } return result; }  }
CloudJobConfigurationService { public Collection<CloudJobConfigurationPOJO> loadAll() { if (!regCenter.isExisted(CloudJobConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> jobNames = regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT); Collection<CloudJobConfigurationPOJO> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { load(each).ifPresent(result::add); } return result; }  void add(final CloudJobConfigurationPOJO cloudJobConfig); void update(final CloudJobConfigurationPOJO cloudJobConfig); Collection<CloudJobConfigurationPOJO> loadAll(); Optional<CloudJobConfigurationPOJO> load(final String jobName); void remove(final String jobName); }
CloudJobConfigurationService { public Collection<CloudJobConfigurationPOJO> loadAll() { if (!regCenter.isExisted(CloudJobConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> jobNames = regCenter.getChildrenKeys(CloudJobConfigurationNode.ROOT); Collection<CloudJobConfigurationPOJO> result = new ArrayList<>(jobNames.size()); for (String each : jobNames) { load(each).ifPresent(result::add); } return result; }  void add(final CloudJobConfigurationPOJO cloudJobConfig); void update(final CloudJobConfigurationPOJO cloudJobConfig); Collection<CloudJobConfigurationPOJO> loadAll(); Optional<CloudJobConfigurationPOJO> load(final String jobName); void remove(final String jobName);  }