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