Search in sources :

Example 16 with Join

use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.

the class ProjectServiceImplIT method testRemoveSamplesFromProject.

@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testRemoveSamplesFromProject() {
    Sample s1 = sampleService.read(1L);
    Sample s2 = sampleService.read(2L);
    Project p = projectService.read(2L);
    projectService.removeSamplesFromProject(p, ImmutableList.of(s1, s2));
    Collection<Join<Project, Sample>> samples = sampleService.getSamplesForProject(p);
    assertTrue("No samples should be assigned to project.", samples.isEmpty());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) RelatedProjectJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) ProjectAnalysisSubmissionJoin(ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 17 with Join

use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.

the class ReferenceFileServiceImplIT method testGetReferenceFilesForProject.

@Test
@WithMockUser(username = "fbristow", roles = "ADMIN")
public void testGetReferenceFilesForProject() {
    Project p = projectService.read(1L);
    List<Join<Project, ReferenceFile>> prs = referenceFileService.getReferenceFilesForProject(p);
    assertEquals("Wrong number of reference files for project.", 1, prs.size());
    ReferenceFile rf = prs.iterator().next().getObject();
    assertEquals("Wrong reference file attached to project.", Long.valueOf(1), rf.getId());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ReferenceFile(ca.corefacility.bioinformatics.irida.model.project.ReferenceFile) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 18 with Join

use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.

the class UserServiceImplIT method testGetUsersForProject.

@Test
@WithMockUser(username = "fbristow", roles = "MANAGER")
public void testGetUsersForProject() {
    Project p = projectService.read(1L);
    Collection<Join<Project, User>> projectUsers = userService.getUsersForProject(p);
    assertEquals("Wrong number of users.", 1, projectUsers.size());
    Join<Project, User> projectUser = projectUsers.iterator().next();
    assertEquals("Wrong project.", p, projectUser.getSubject());
    assertEquals("Wrong user.", "fbristow", projectUser.getObject().getUsername());
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) WithMockUser(org.springframework.security.test.context.support.WithMockUser) User(ca.corefacility.bioinformatics.irida.model.user.User) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 19 with Join

use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.

the class ProjectSamplesControllerTest method mockSidebarInfo.

/**
 * Mocks the information found within the project sidebar.
 */
private void mockSidebarInfo() {
    Project project = getProject();
    Collection<Join<Project, User>> ownerList = new ArrayList<>();
    ownerList.add(new ProjectUserJoin(project, user, ProjectRole.PROJECT_OWNER));
    when(projectService.read(PROJECT_ID)).thenReturn(project);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)

Example 20 with Join

use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.

the class ProjectsControllerTest method testGetSpecificProjectPage.

@Test
public void testGetSpecificProjectPage() {
    Model model = new ExtendedModelMap();
    Long projectId = 1L;
    Principal principal = () -> USER_NAME;
    List<Join<Project, User>> projects = getProjectsForUser();
    when(userService.getUsersForProjectByRole(getProject(), ProjectRole.PROJECT_OWNER)).thenReturn(getUsersForProjectByRole());
    when(projectService.getProjectsForUser(user)).thenReturn(projects);
    when(projectService.getRelatedProjects(getProject())).thenReturn(getRelatedProjectJoin(projects));
    assertEquals("Returns the correct Project Page", ProjectsController.SPECIFIC_PROJECT_PAGE, controller.getProjectSpecificPage(projectId, model, principal));
}
Also used : ExtendedModelMap(org.springframework.ui.ExtendedModelMap) Model(org.springframework.ui.Model) Join(ca.corefacility.bioinformatics.irida.model.joins.Join) ProjectUserJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin) RelatedProjectJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin) Principal(java.security.Principal) Test(org.junit.Test)

Aggregations

Join (ca.corefacility.bioinformatics.irida.model.joins.Join)65 Project (ca.corefacility.bioinformatics.irida.model.project.Project)60 Test (org.junit.Test)40 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)35 User (ca.corefacility.bioinformatics.irida.model.user.User)35 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)34 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)26 ProjectUserJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectUserJoin)23 ArrayList (java.util.ArrayList)20 WithMockUser (org.springframework.security.test.context.support.WithMockUser)20 ProjectAnalysisSubmissionJoin (ca.corefacility.bioinformatics.irida.model.workflow.submission.ProjectAnalysisSubmissionJoin)16 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)14 ProjectRole (ca.corefacility.bioinformatics.irida.model.enums.ProjectRole)13 ReferenceFile (ca.corefacility.bioinformatics.irida.model.project.ReferenceFile)13 List (java.util.List)12 Set (java.util.Set)12 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)11 Autowired (org.springframework.beans.factory.annotation.Autowired)11 ProjectSampleJoinRepository (ca.corefacility.bioinformatics.irida.repositories.joins.project.ProjectSampleJoinRepository)10 ProjectService (ca.corefacility.bioinformatics.irida.service.ProjectService)10