### Question:
SourceServiceImpl implements SourceService { @Override public Collection<String> getRepositories(final String organizationalUnit) { checkNotNull("organizationalUnit", organizationalUnit); OrganizationalUnit ou = organizationalUnitService.getOrganizationalUnit(organizationalUnit); if (ou == null) { return new ArrayList<>(); } else { return organizationalUnitService.getOrganizationalUnit(organizationalUnit) .getRepositories() .stream() .filter(repository -> authorizationManager.authorize(repository, identity)) .map(Repository::getAlias) .collect(Collectors.toList()); } } SourceServiceImpl(); @Inject  SourceServiceImpl(OrganizationalUnitService organizationalUnitService,
                             RepositoryService repositoryService,
                             ModuleService<? extends Module> moduleService,
                             AuthorizationManager authorizationManager,
                             User identity); @Override Collection<String> getOrganizationUnits(); @Override Collection<String> getRepositories(final String organizationalUnit); @Override Collection<String> getBranches(final Space space, final String repositoryName); @Override Collection<Module> getModules(final Space space,
                                         final String repositoryAlias,
                                         final String branchName);  }### Answer:
@Test public void testGetRepositories() { List<Repository> repositories = mockRepositories("RepoName.", REPOSITORIES_SIZE); OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class); when(organizationalUnit.getName()).thenReturn(OU_NAME); when(organizationalUnitService.getOrganizationalUnit(OU_NAME)).thenReturn(null); Collection<String> result = service.getRepositories(OU_NAME); assertTrue(result.isEmpty()); when(organizationalUnitService.getOrganizationalUnit(OU_NAME)).thenReturn(organizationalUnit); when(organizationalUnit.getRepositories()).thenReturn(repositories); result = service.getRepositories(OU_NAME); assertTrue(result.isEmpty()); List<Integer> authorizedIndexes = new ArrayList<>(); List<String> authorizedNames = new ArrayList<>(); authorizedIndexes.add(1); authorizedIndexes.add(4); authorizedIndexes.add(6); authorizedIndexes.forEach(index -> { when(authorizationManager.authorize(repositories.get(index), identity)).thenReturn(true); authorizedNames.add(repositories.get(index).getAlias()); }); result = service.getRepositories(OU_NAME); assertEquals(authorizedNames, result); }