WorkspaceProjectServiceImpl implements WorkspaceProjectService { @Override public Collection<WorkspaceProject> getAllWorkspaceProjects() { final List<WorkspaceProject> result = new ArrayList<>(); for (final OrganizationalUnit ou : organizationalUnitService.getOrganizationalUnits()) { result.addAll(getAllWorkspaceProjects(ou)); } return result; } WorkspaceProjectServiceImpl(); @Inject  WorkspaceProjectServiceImpl(final OrganizationalUnitService organizationalUnitService,
                                       final RepositoryService repositoryService,
                                       final SpacesAPI spaces,
                                       final Event<NewProjectEvent> newProjectEvent,
                                       final Event<RepositoryUpdatedEvent> repositoryUpdatedEvent,
                                       final Event<NewBranchEvent> newBranchEvent,
                                       final Instance<ModuleService<? extends Module>> moduleServices,
                                       final ModuleRepositoryResolver repositoryResolver,
                                       @Named("ioStrategy") final IOService ioService,
                                       final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                                       final PathUtil pathUtil,
                                       final ChangeRequestService changeRequestService,
                                       final POMService pomService); @Override Collection<WorkspaceProject> getAllWorkspaceProjects(); @Override Collection<WorkspaceProject> getAllWorkspaceProjects(final OrganizationalUnit organizationalUnit); @Override Collection<WorkspaceProject> getAllWorkspaceProjectsByName(final OrganizationalUnit organizationalUnit,
                                                                      final String name); Collection<WorkspaceProject> getAllWorkspaceProjectsByName(final OrganizationalUnit organizationalUnit,
                                                                      final String name,
                                                                      final boolean includeDeleted); @Override boolean spaceHasNoProjectsWithName(final OrganizationalUnit organizationalUnit,
                                              final String name,
                                              final WorkspaceProject projectToIgnore); @Override WorkspaceProject newProject(final OrganizationalUnit organizationalUnit,
                                       final POM pom); @Override WorkspaceProject newProject(final OrganizationalUnit organizationalUnit,
                                       final POM pom,
                                       final DeploymentMode mode); @Override WorkspaceProject newProject(final OrganizationalUnit organizationalUnit,
                                       final POM pom,
                                       final DeploymentMode mode,
                                       final List<Contributor> contributors); @Override WorkspaceProject newProject(final OrganizationalUnit organizationalUnit,
                                       final POM pom,
                                       final DeploymentMode mode,
                                       final List<Contributor> contributors,
                                       final Repository templateRepository); @Override WorkspaceProject newProject(final OrganizationalUnit organizationalUnit,
                                       final POM pom,
                                       final DeploymentMode mode,
                                       final List<Contributor> contributors,
                                       final Repository templateRepository,
                                       final String remoteRepositoryUrl); @Override String createFreshProjectName(final OrganizationalUnit organizationalUnit,
                                         final String name); @Override WorkspaceProject resolveProject(final Repository repository); @Override WorkspaceProject resolveProject(final Space space,
                                           final Branch branch); @Override WorkspaceProject resolveProject(final Space space,
                                           final Module module); @Override WorkspaceProject resolveProject(final Space space,
                                           final String name); @Override WorkspaceProject resolveProject(final Space space,
                                           final String projectName,
                                           final String branchName); @Override WorkspaceProject resolveProjectByRepositoryAlias(final Space space,
                                                            final String repositoryAlias); @Override WorkspaceProject resolveProject(final Space space,
                                           final Path path); @Override WorkspaceProject resolveProject(Path path); @Override void addBranch(final String newBranchName,
                          final String baseBranchName,
                          final WorkspaceProject project,
                          final String userIdentifier); @Override void removeBranch(final String branchName,
                             final WorkspaceProject project,
                             final String userIdentifier);  }
@Test public void getAllProjects() { final Collection<WorkspaceProject> allWorkspaceProjects = workspaceProjectService.getAllWorkspaceProjects(); assertEquals(3, allWorkspaceProjects.size()); }
@Test public void getAllProjectsForOU1() { final Collection<WorkspaceProject> allWorkspaceProjects = workspaceProjectService.getAllWorkspaceProjects(ou1); assertContains(repository1, allWorkspaceProjects); assertContains(repository2, allWorkspaceProjects); assertEquals(2, allWorkspaceProjects.size()); }
@Test public void getAllProjectsForOU2() { final Collection<WorkspaceProject> allWorkspaceProjects = workspaceProjectService.getAllWorkspaceProjects(ou2); assertContains(repository3, allWorkspaceProjects); assertEquals(1, allWorkspaceProjects.size()); }
@Test public void noProjects() { final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class); doReturn("myOU").when(organizationalUnit).getName(); doReturn(organizationalUnit).when(organizationalUnitService).getOrganizationalUnit("myOU"); assertTrue(workspaceProjectService.getAllWorkspaceProjects(organizationalUnit).isEmpty()); }