RepositoryServiceImpl implements RepositoryService { @Override public Repository createRepository(final OrganizationalUnit organizationalUnit, final String scheme, final String alias, final RepositoryEnvironmentConfigurations repositoryEnvironmentConfigurations) throws RepositoryAlreadyExistsException { return createRepository(organizationalUnit, scheme, alias, repositoryEnvironmentConfigurations, organizationalUnit.getContributors()); } RepositoryServiceImpl(); @Inject  RepositoryServiceImpl(@Named("ioStrategy") final IOService ioService,
                                 final GitMetadataStore metadataStore,
                                 final ConfigurationService configurationService,
                                 final OrganizationalUnitService organizationalUnitService,
                                 final ConfigurationFactory configurationFactory,
                                 final RepositoryFactory repositoryFactory,
                                 final Event<NewRepositoryEvent> event,
                                 final Event<RepositoryRemovedEvent> repositoryRemovedEvent,
                                 final BackwardCompatibleUtil backward,
                                 final ConfiguredRepositories configuredRepositories,
                                 final AuthorizationManager authorizationManager,
                                 final User user,
                                 final SpacesAPI spacesAPI,
                                 final SpaceConfigStorageRegistry spaceConfigStorage,
                                 final Event<RepositoryContributorsUpdatedEvent> repositoryContributorsUpdatedEvent,
                                 final PasswordService secureService); @Override RepositoryInfo getRepositoryInfo(final Space space,
                                            final String alias); @Override List<VersionRecord> getRepositoryHistory(final Space space,
                                                    final String alias,
                                                    final int startIndex); @Override List<VersionRecord> getRepositoryHistory(final Space space,
                                                    final String alias,
                                                    int startIndex,
                                                    int endIndex); @Override Repository getRepositoryFromSpace(final Space space,
                                             final String alias); @Override Repository getRepository(final Path root); @Override Repository getRepository(final Space space,
                                    final Path root); @Override String normalizeRepositoryName(String name); @Override boolean validateRepositoryName(String name); @Override Collection<Repository> getAllRepositories(final Space space); @Override Collection<Repository> getAllDeletedRepositories(final Space space); @Override Collection<Repository> getAllRepositories(Space space,
                                                     boolean includeDeleted); @Override Collection<Repository> getAllRepositoriesFromAllUserSpaces(); @Override Collection<Repository> getRepositories(final Space space); @Override Repository createRepository(final OrganizationalUnit organizationalUnit,
                                       final String scheme,
                                       final String alias,
                                       final RepositoryEnvironmentConfigurations repositoryEnvironmentConfigurations); @Override Repository createRepository(final OrganizationalUnit organizationalUnit,
                                       final String scheme,
                                       final String alias,
                                       final RepositoryEnvironmentConfigurations repositoryEnvironmentConfigurations,
                                       final Collection<Contributor> contributors); @Override void removeRepository(final Space space,
                                 final String alias); @Override void removeRepositories(final Space space,
                                   final Set<String> aliases); @SuppressWarnings({"unchecked", "rawtypes"}) @Override void addGroup(final Repository repository,
                         final String group); @SuppressWarnings({"unchecked", "rawtypes"}) @Override void removeGroup(Repository repository,
                            String group); @Override void updateContributors(final Repository repository,
                                   final List<Contributor> contributors); @Override List<VersionRecord> getRepositoryHistoryAll(final Space space,
                                                       final String alias);  }
@Test public void testCreateRepositoryConfiguration() { final String space = "space"; final String scheme = "git"; final String repoName = "test"; final String userName = "user"; final String password = "pass"; OrganizationalUnit orgUnit = mock(OrganizationalUnit.class); when(orgUnit.getName()).thenReturn(space); final SpaceConfigStorage spaceConfigStorage = mock(SpaceConfigStorage.class); when(registry.getBatch(anyString())).thenReturn(new SpaceConfigStorageRegistryImpl.SpaceStorageBatchImpl(spaceConfigStorage)); when(spacesAPI.getSpace(anyString())).thenAnswer((Answer<Space>) invocationOnMock -> new Space(invocationOnMock.getArguments()[0].toString())); when(passwordService.encrypt(anyString())).thenAnswer(invocationOnMock -> invocationOnMock.getArguments()[0].toString()); RepositoryEnvironmentConfigurations configurations = new RepositoryEnvironmentConfigurations(); configurations.setUserName(userName); configurations.setPassword(password); configurations.setOrigin("https: repositoryService.createRepository(orgUnit, scheme, repoName, configurations, Collections.emptyList()); verify(passwordService, times(1)).encrypt(eq(password)); ArgumentCaptor<RepositoryInfo> captor = ArgumentCaptor.forClass(RepositoryInfo.class); verify(repositoryFactory).newRepository(captor.capture()); RepositoryInfo info = captor.getValue(); Assertions.assertThat(info) .isNotNull() .hasFieldOrPropertyWithValue("name", repoName) .hasFieldOrPropertyWithValue("deleted", false); assertEquals(scheme, info.getScheme()); assertEquals(space, info.getSpace()); assertEquals(userName, info.getConfiguration().get(String.class, "username")); assertEquals(password, info.getConfiguration().get(String.class, "secure:password")); }