EnvironmentSettingRepositoryLoader implements RepositoryLoader { @Override public List<Repository> load(Logger logger) throws LifecycleExecutionException { List<Repository> repositoryList = new ArrayList<>(); String settings = getEnvSetting(ExtensionSettings.REPOSITORIES_SETTING_ENV); if (settings.length() > 0) { for (String scalar : settings.split(",")) { String[] config = scalar.split("="); if (config.length == 2) { repositoryList.add(build(config[0], config[1], logger)); } } if (!repositoryList.isEmpty()) { logger.info(String.format("Add %s repositories found in environment variables", repositoryList.size())); } } return repositoryList; }  @Override List<Repository> load(Logger logger);  }
@Test public void shouldLoadFromEnv() throws LifecycleExecutionException { EnvironmentSettingRepositoryLoader loader = new EnvironmentSettingRepositoryLoader() { @Override protected String getEnvSetting(String name) { return "central=https: } }; List<Repository> repositoryList = loader.load(logger); TestHelper.verifyRepositories(repositoryList); }
@Test public void shouldHandleNonExistingSystemProperty() throws LifecycleExecutionException { EnvironmentSettingRepositoryLoader loader = new EnvironmentSettingRepositoryLoader(); List<Repository> repositoryList = loader.load(logger); Assertions.assertThat(repositoryList).isEmpty(); }