ConfigurationManagementServiceImpl implements ConfigurationManagementService { @Override public Configuration getConfiguration() { final Lock readLock = configurationLock.readLock(); readLock.lock(); try { return new Configuration(configuration); } finally { readLock.unlock(); } }  @PostConstruct void init(); @Override MutableConfiguration getMutableConfigurationClone(); @Override Configuration getConfiguration(); @Override void setConfiguration(MutableConfiguration newConf); @Override void setInstanceName(String instanceName); @Override void setBaseUrl(String baseUrl); @Override void setPort(int port); @Override void setProxyConfiguration(String storageId,
                                      String repositoryId,
                                      MutableProxyConfiguration proxyConfiguration); @Override void saveStorage(StorageDto storage); @Override void addStorageIfNotExists(StorageDto storage); @Override void removeStorage(String storageId); @Override void saveRepository(String storageId,
                               RepositoryDto repository); @Override void removeRepositoryFromAssociatedGroups(String storageId,
                                                     String repositoryId); @Override void removeRepository(String storageId,
                                 String repositoryId); @Override void setProxyRepositoryMaxConnections(String storageId,
                                                 String repositoryId,
                                                 int numberOfConnections); @Override MutableRoutingRules getRoutingRules(); @Override MutableRoutingRule getRoutingRule(UUID uuid); @Override boolean updateRoutingRule(UUID uuid,
                                     MutableRoutingRule routingRule); @Override boolean addRoutingRule(MutableRoutingRule routingRule); @Override boolean removeRoutingRule(UUID uuid); @Override void addRepositoryToGroup(String storageId,
                                     String repositoryId,
                                     String repositoryGroupMemberId); @Override void setRepositoryArtifactCoordinateValidators(); @Override void putInService(final String storageId,
                             final String repositoryId); @Override void putOutOfService(final String storageId,
                                final String repositoryId); @Override void setArtifactMaxSize(final String storageId,
                                   final String repositoryId,
                                   final long value); @Override void set(final MutableRemoteRepositoryRetryArtifactDownloadConfiguration remoteRepositoryRetryArtifactDownloadConfiguration); @Override void addRepositoryArtifactCoordinateValidator(final String storageId,
                                                         final String repositoryId,
                                                         final String alias); @Override boolean removeRepositoryArtifactCoordinateValidator(final String storageId,
                                                               final String repositoryId,
                                                               final String alias); @Override void setCorsAllowedOrigins(final List<String> allowedOrigins); @Override void setSmtpSettings(MutableSmtpConfiguration smtpConfiguration);  }
@Test public void groupRepositoriesShouldBeSortedAsExpected() { Repository repository = configurationManagementService.getConfiguration().getRepository( STORAGE_COMMON_PROXIES, REPOSITORY_GROUP_COMMON_PROXIES); Iterator<String> iterator = repository.getGroupRepositories().iterator(); assertThat(iterator.next()).isEqualTo("carlspring"); assertThat(iterator.next()).isEqualTo("maven-central"); assertThat(iterator.next()).isEqualTo("apache-snapshots"); assertThat(iterator.next()).isEqualTo("jboss-public-releases"); }
@Test public void testGetRepositories() { List<Repository> repositories = configurationManagementService.getConfiguration().getRepositories(); assertThat(repositories).isNotEmpty(); logger.debug("Repositories:"); for (Repository repository : repositories) { logger.debug(" - {}", repository.getId()); } }
@Test public void testGetGroupRepositories() { List<Repository> groupRepositories = configurationManagementService.getConfiguration().getGroupRepositories(); assertThat(groupRepositories).isNotEmpty(); logger.debug("Group repositories:"); for (Repository repository : groupRepositories) { logger.debug(" - {}", repository.getId()); } }
@ExtendWith(RepositoryManagementTestExecutionListener.class) @Test public void testGetGroupRepositoriesContainingRepository(@RawRepository(repositoryId = REPOSITORY_RELEASES_1) Repository releases1, @Group(repositories = REPOSITORY_RELEASES_1) @RawRepository(repositoryId = REPOSITORY_GROUP_1) Repository releasesGroup) { final String storageId = releases1.getStorage().getId(); final String releases1Id = releases1.getId(); List<Repository> groups = configurationManagementService.getConfiguration() .getGroupRepositoriesContaining(storageId, releases1Id); assertThat(groups).isNotEmpty(); logger.debug("Group repositories containing \"{}\" repository:", releases1Id); for (Repository repository : groups) { logger.debug(" - {}", repository.getId()); } }
@ExtendWith(RepositoryManagementTestExecutionListener.class) @Test public void testCanGetRepositoriesWithStorageAndLayout(@RawRepository(repositoryId = REPOSITORY_RELEASES_1) Repository releases1, @RawRepository(repositoryId = REPOSITORY_RELEASES_2) Repository releases2, @Group(repositories = REPOSITORY_RELEASES_1) @RawRepository(repositoryId = REPOSITORY_GROUP_1) Repository releasesGroup1, @Group(repositories = REPOSITORY_RELEASES_1) @RawRepository(repositoryId = REPOSITORY_GROUP_2) Repository releasesGroup2) { List<Repository> repositories = configurationManagementService.getConfiguration() .getRepositoriesWithLayout(STORAGE0, RawArtifactCoordinates.LAYOUT_NAME); assertThat(repositories).isNotEmpty(); repositories.forEach(repository -> { assertThat(repository.getLayout()).isEqualTo(RawArtifactCoordinates.LAYOUT_NAME); assertThat(repository.getStorage().getId()).isEqualTo(STORAGE0); }); }
@ExtendWith(RepositoryManagementTestExecutionListener.class) @Test public void testCanGetRepositoriesWithStorageAndLayoutNotExistedStorage(@RawRepository(repositoryId = REPOSITORY_RELEASES_1) Repository releases1, @RawRepository(repositoryId = REPOSITORY_RELEASES_2) Repository releases2, @Group(repositories = REPOSITORY_RELEASES_1) @RawRepository(repositoryId = REPOSITORY_GROUP_1) Repository releasesGroup1, @Group(repositories = REPOSITORY_RELEASES_1) @RawRepository(repositoryId = REPOSITORY_GROUP_2) Repository releasesGroup2) { List<Repository> repositories = configurationManagementService.getConfiguration() .getRepositoriesWithLayout("notExistingStorage", RawArtifactCoordinates.LAYOUT_NAME); assertThat(repositories).isEmpty(); }