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