@Test public void getLibraryInfoTest() { final Path path1 = mockPath("file: final WorkspaceProject project1 = mock(WorkspaceProject.class); final Repository repository1 = mock(Repository.class); when(project1.getRootPath()).thenReturn(path1); when(project1.getRepository()).thenReturn(repository1); final Path path2 = mockPath("file: final WorkspaceProject project2 = mock(WorkspaceProject.class); final Repository repository2 = mock(Repository.class); when(project2.getRootPath()).thenReturn(path2); when(project2.getRepository()).thenReturn(repository2); doReturn(true).when(authorizationManager).authorize(same(repository2), eq(RepositoryAction.READ), any()); doReturn(true).when(ioService).exists(any()); final Set<WorkspaceProject> projects = new HashSet<>(); projects.add(project1); projects.add(project2); doReturn(projects).when(projectService).getAllWorkspaceProjects(ou1); final LibraryInfo libraryInfo = libraryService.getLibraryInfo(ou1); assertEquals(1, libraryInfo.getProjects().size()); assertSame(project2, libraryInfo.getProjects().iterator().next()); }
@Override public LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit) { final List<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit).stream() .filter(p -> userCanReadProject(p)) .collect(Collectors.toList()); return new LibraryInfo(projects); }
LibraryServiceImpl implements LibraryService { @Override public LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit) { final List<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit).stream() .filter(p -> userCanReadProject(p)) .collect(Collectors.toList()); return new LibraryInfo(projects); } }
LibraryServiceImpl implements LibraryService { @Override public LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit) { final List<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit).stream() .filter(p -> userCanReadProject(p)) .collect(Collectors.toList()); return new LibraryInfo(projects); } LibraryServiceImpl(); @Inject  LibraryServiceImpl(final OrganizationalUnitService ouService,
                              final RefactoringQueryService refactoringQueryService,
                              final LibraryPreferences preferences,
                              final AuthorizationManager authorizationManager,
                              final SessionInfo sessionInfo,
                              final ExplorerServiceHelper explorerServiceHelper,
                              final WorkspaceProjectService projectService,
                              final KieModuleService moduleService,
                              final ExamplesService examplesService,
                              @Named("ioStrategy") final IOService ioService,
                              final UserManagerService userManagerService,
                              final IndexStatusOracle indexOracle,
                              final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                              final ClusterService clusterService,
                              final ArchetypeService archetypeService); }
LibraryServiceImpl implements LibraryService { @Override public LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit) { final List<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit).stream() .filter(p -> userCanReadProject(p)) .collect(Collectors.toList()); return new LibraryInfo(projects); } LibraryServiceImpl(); @Inject  LibraryServiceImpl(final OrganizationalUnitService ouService,
                              final RefactoringQueryService refactoringQueryService,
                              final LibraryPreferences preferences,
                              final AuthorizationManager authorizationManager,
                              final SessionInfo sessionInfo,
                              final ExplorerServiceHelper explorerServiceHelper,
                              final WorkspaceProjectService projectService,
                              final KieModuleService moduleService,
                              final ExamplesService examplesService,
                              @Named("ioStrategy") final IOService ioService,
                              final UserManagerService userManagerService,
                              final IndexStatusOracle indexOracle,
                              final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                              final ClusterService clusterService,
                              final ArchetypeService archetypeService); @Override OrganizationalUnitRepositoryInfo getDefaultOrganizationalUnitRepositoryInfo(); @Override OrganizationalUnitRepositoryInfo getOrganizationalUnitRepositoryInfo(final OrganizationalUnit selectedOrganizationalUnit); @Override LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit); @Override WorkspaceProject createProject(final OrganizationalUnit organizationalUnit,
                                          final String remoteRepositoryUrl,
                                          final String repositoryAlias); @Override WorkspaceProject createProject(final String projectName,
                                          final OrganizationalUnit selectedOrganizationalUnit,
                                          final String projectDescription,
                                          final DeploymentMode deploymentMode); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode,
                                          final String templateId); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode,
                                          final String templateId,
                                          final String remoteRepositoryUrl); @Override Boolean thereIsAProjectInTheWorkbench(); @Override AssetQueryResult getProjectAssets(final ProjectAssetsQuery query); @Override Boolean hasProjects(final OrganizationalUnit organizationalUnit); @Override Boolean hasAssets(final WorkspaceProject project); @Override Set<ImportProject> getExampleProjects(OrganizationalUnit organizationalUnit); @Override List<OrganizationalUnit> getOrganizationalUnits(); @Override GAV createGAV(final String projectName,
                         final OrganizationalUnit selectedOrganizationalUnit); @Override synchronized List<String> getAllUsers(); @Override void addBranch(final String newBranchName,
                          final String baseBranchName,
                          final WorkspaceProject project); @Override void removeBranch(final WorkspaceProject project,
                             final Branch branch); @Override BranchPermissions loadBranchPermissions(final String spaceName,
                                                   final String projectIdentifier,
                                                   final String branchName); @Override void saveBranchPermissions(final String spaceName,
                                      final String projectIdentifier,
                                      final String branchName,
                                      final BranchPermissions branchPermissions); @Override Boolean isClustered(); @Override int getNumberOfAssets(final ProjectAssetsQuery query); @Override int getNumberOfAssets(final WorkspaceProject module); @Override OrganizationalUnit getDefaultOrganizationalUnit(); }
LibraryServiceImpl implements LibraryService { @Override public LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit) { final List<WorkspaceProject> projects = projectService.getAllWorkspaceProjects(organizationalUnit).stream() .filter(p -> userCanReadProject(p)) .collect(Collectors.toList()); return new LibraryInfo(projects); } LibraryServiceImpl(); @Inject  LibraryServiceImpl(final OrganizationalUnitService ouService,
                              final RefactoringQueryService refactoringQueryService,
                              final LibraryPreferences preferences,
                              final AuthorizationManager authorizationManager,
                              final SessionInfo sessionInfo,
                              final ExplorerServiceHelper explorerServiceHelper,
                              final WorkspaceProjectService projectService,
                              final KieModuleService moduleService,
                              final ExamplesService examplesService,
                              @Named("ioStrategy") final IOService ioService,
                              final UserManagerService userManagerService,
                              final IndexStatusOracle indexOracle,
                              final SpaceConfigStorageRegistry spaceConfigStorageRegistry,
                              final ClusterService clusterService,
                              final ArchetypeService archetypeService); @Override OrganizationalUnitRepositoryInfo getDefaultOrganizationalUnitRepositoryInfo(); @Override OrganizationalUnitRepositoryInfo getOrganizationalUnitRepositoryInfo(final OrganizationalUnit selectedOrganizationalUnit); @Override LibraryInfo getLibraryInfo(final OrganizationalUnit organizationalUnit); @Override WorkspaceProject createProject(final OrganizationalUnit organizationalUnit,
                                          final String remoteRepositoryUrl,
                                          final String repositoryAlias); @Override WorkspaceProject createProject(final String projectName,
                                          final OrganizationalUnit selectedOrganizationalUnit,
                                          final String projectDescription,
                                          final DeploymentMode deploymentMode); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode,
                                          final String templateId); @Override WorkspaceProject createProject(final OrganizationalUnit activeOrganizationalUnit,
                                          final POM pom,
                                          final DeploymentMode mode,
                                          final String templateId,
                                          final String remoteRepositoryUrl); @Override Boolean thereIsAProjectInTheWorkbench(); @Override AssetQueryResult getProjectAssets(final ProjectAssetsQuery query); @Override Boolean hasProjects(final OrganizationalUnit organizationalUnit); @Override Boolean hasAssets(final WorkspaceProject project); @Override Set<ImportProject> getExampleProjects(OrganizationalUnit organizationalUnit); @Override List<OrganizationalUnit> getOrganizationalUnits(); @Override GAV createGAV(final String projectName,
                         final OrganizationalUnit selectedOrganizationalUnit); @Override synchronized List<String> getAllUsers(); @Override void addBranch(final String newBranchName,
                          final String baseBranchName,
                          final WorkspaceProject project); @Override void removeBranch(final WorkspaceProject project,
                             final Branch branch); @Override BranchPermissions loadBranchPermissions(final String spaceName,
                                                   final String projectIdentifier,
                                                   final String branchName); @Override void saveBranchPermissions(final String spaceName,
                                      final String projectIdentifier,
                                      final String branchName,
                                      final BranchPermissions branchPermissions); @Override Boolean isClustered(); @Override int getNumberOfAssets(final ProjectAssetsQuery query); @Override int getNumberOfAssets(final WorkspaceProject module); @Override OrganizationalUnit getDefaultOrganizationalUnit();  }