DefaultExtensionManagerConfiguration implements ExtensionManagerConfiguration { @Override public Collection<ExtensionRepositoryDescriptor> getExtensionRepositoryDescriptors() { Collection<ExtensionRepositoryDescriptor> repositories; List<String> repositoryStrings = this.configuration.get().getProperty(CK_PREFIX + "repositories", Collections.emptyList()); if (repositoryStrings.isEmpty()) { repositories = null; } else { Map<String, ExtensionRepositoryDescriptor> repositoriesMap = new LinkedHashMap<>(); for (String repositoryString : repositoryStrings) { if (StringUtils.isNotBlank(repositoryString)) { try { ExtensionRepositoryDescriptor extensionRepositoryId = parseRepository(repositoryString); if (repositoriesMap.containsKey(extensionRepositoryId.getId())) { this.logger.warn( "Duplicated repository id in [{}] first found in [{}]. The last one will be used.", extensionRepositoryId, repositoriesMap.get(extensionRepositoryId.getId())); } repositoriesMap.put(extensionRepositoryId.getId(), extensionRepositoryId); } catch (Exception e) { this.logger.warn("Ignoring invalid repository configuration [{}]. " + "Root cause [{}]", repositoryString, ExceptionUtils.getRootCauseMessage(e)); } } else { this.logger.debug("Empty repository id found in the configuration"); } } repositories = repositoriesMap.values(); for (ExtensionRepositoryDescriptor descriptor : repositories) { setRepositoryProperties((DefaultExtensionRepositoryDescriptor) descriptor); } } return repositories; }  File getHome(); @Override File getLocalRepository(); @Override Collection<ExtensionRepositoryDescriptor> getExtensionRepositoryDescriptors(); @Override Collection<ExtensionRepositoryId> getRepositories(); @Override String getUserAgent(); @Override boolean resolveCoreExtensions(); @Override VersionConstraint getRecomendedVersionConstraint(String id); @Override VersionConstraint getRecomendedVersionConstraint(String id, VersionConstraint defaultVersion); @Override boolean isIgnoredDependency(ExtensionDependency dependency);  }
@Test void getRepositoriesWithInvalid() throws Exception { this.source.setProperty("extension.repositories", Arrays.asList("id:type:http: assertEquals( Arrays.asList(new DefaultExtensionRepositoryDescriptor("id", "type", new URI("http: new ArrayList<>(this.configuration.getExtensionRepositoryDescriptors())); assertEquals(1, this.logCapture.size()); assertEquals("Ignoring invalid repository configuration [invalid]. Root cause " + "[ExtensionManagerConfigurationException: Invalid repository configuration format for [invalid]. Should " + "have been matching [([^:]+):([^:]+):(.+)].]", this.logCapture.getMessage(0)); }
@Test void getExtensionRepositoryDescriptorsEmpty() { assertNull(this.configuration.getExtensionRepositoryDescriptors()); assertEquals(0, this.logCapture.size()); }
@Test void getExtensionRepositoryDescriptorsWithProperties() throws URISyntaxException { this.source.setProperty("extension.repositories", Arrays.asList("id:type:http: this.source.setProperty("extension.repositories.id.property", "value"); this.source.setProperty("extension.repositories.id.property.with.dots", "other value"); Collection<ExtensionRepositoryDescriptor> descriptors = this.configuration.getExtensionRepositoryDescriptors(); assertFalse(descriptors.isEmpty()); ExtensionRepositoryDescriptor descriptor = descriptors.iterator().next(); assertEquals("id", descriptor.getId()); assertEquals("type", descriptor.getType()); assertEquals(new URI("http: assertEquals("value", descriptor.getProperty("property")); assertEquals("other value", descriptor.getProperty("property.with.dots")); assertEquals(0, this.logCapture.size()); }