### Question:
SourceServiceImpl implements SourceService { @Override public Collection<Module> getModules(final Space space, final String repositoryAlias, final String branchName) { checkNotNull("repositoryAlias", repositoryAlias); checkNotNull("branchName", branchName); final Repository repository = repositoryService.getRepositoryFromSpace(space, repositoryAlias); if (repository == null) { return new ArrayList<>(); } else { final Optional<Branch> branch = repository.getBranch(branchName); if (branch.isPresent()) { return moduleService.getAllModules(branch.get()); } else { return new ArrayList<>(); } } } 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 testProjects() { final Repository repository = mock(Repository.class); final Branch branch = new Branch(BRANCH_NAME, mock(Path.class)); doReturn(Optional.of(branch)).when(repository).getBranch(eq(BRANCH_NAME)); @SuppressWarnings("unchecked") final Set<Module> modules = mock(Set.class); when(repositoryService.getRepositoryFromSpace(SPACE, REPO_NAME)).thenReturn(repository); when(moduleService.getAllModules(branch)).thenReturn(modules); final Collection<Module> result = service.getModules(SPACE, REPO_NAME, BRANCH_NAME); assertEquals(modules, result); }