### Question:
CloudAppConfigurationService { public Collection<CloudAppConfiguration> loadAll() { if (!regCenter.isExisted(CloudAppConfigurationNode.ROOT)) { return Collections.emptyList(); } List<String> appNames = regCenter.getChildrenKeys(CloudAppConfigurationNode.ROOT); Collection<CloudAppConfiguration> result = new ArrayList<>(appNames.size()); for (String each : appNames) { Optional<CloudAppConfiguration> config = load(each); if (config.isPresent()) { result.add(config.get()); } } return result; }  void add(final CloudAppConfiguration appConfig); void update(final CloudAppConfiguration appConfig); Optional<CloudAppConfiguration> load(final String appName); Collection<CloudAppConfiguration> loadAll(); void remove(final String appName);  }### Answer:
@Test public void assertLoadAllWithoutRootNode() { Mockito.when(regCenter.isExisted("/config/app")).thenReturn(false); Assert.assertTrue(configService.loadAll().isEmpty()); Mockito.verify(regCenter).isExisted("/config/app"); }
@Test public void assertLoadAllWithRootNode() { Mockito.when(regCenter.isExisted("/config/app")).thenReturn(true); Mockito.when(regCenter.getChildrenKeys(CloudAppConfigurationNode.ROOT)).thenReturn(Arrays.asList("test_app_1", "test_app_2")); Mockito.when(regCenter.get("/config/app/test_app_1")).thenReturn(CloudAppJsonConstants.getAppJson("test_app_1")); Collection<CloudAppConfiguration> actual = configService.loadAll(); Assert.assertThat(actual.size(), Is.is(1)); Assert.assertThat(actual.iterator().next().getAppName(), Is.is("test_app_1")); Mockito.verify(regCenter).isExisted("/config/app"); Mockito.verify(regCenter).getChildrenKeys("/config/app"); Mockito.verify(regCenter).get("/config/app/test_app_1"); Mockito.verify(regCenter).get("/config/app/test_app_2"); }