use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.
the class ProjectServiceImplIT method testMoveLockedSamplesWithOwnerFail.
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user1", roles = "USER")
public void testMoveLockedSamplesWithOwnerFail() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
List<Join<Project, Sample>> samplesForProject = sampleService.getSamplesForProject(source);
Set<Sample> samples = samplesForProject.stream().map(j -> j.getObject()).collect(Collectors.toSet());
projectService.moveSamples(source, destination, samples, true);
}
use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.
the class ProjectServiceImplIT method testShareSamplesWithoutOwner.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithoutOwner() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
List<Join<Project, Sample>> samplesForProject = sampleService.getSamplesForProject(source);
Set<Sample> samples = samplesForProject.stream().map(j -> j.getObject()).collect(Collectors.toSet());
List<ProjectSampleJoin> copiedSamples = projectService.shareSamples(source, destination, samples, false);
assertEquals(samples.size(), copiedSamples.size());
copiedSamples.forEach(j -> {
assertFalse("Project shouldn't be owner for sample", j.isOwner());
});
assertEquals("Samples should still exist in source project", Sets.newHashSet(1L, 2L), projectSampleJoinRepository.getSamplesForProject(source).stream().map(j -> j.getObject().getId()).collect(Collectors.toSet()));
assertEquals("Samples should exist in destination project", Sets.newHashSet(1L, 2L), projectSampleJoinRepository.getSamplesForProject(destination).stream().map(j -> j.getObject().getId()).collect(Collectors.toSet()));
}
use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.
the class ProjectServiceImplIT method testAddTwoUsersToProject.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testAddTwoUsersToProject() {
Project p = projectService.read(1L);
User u1 = userService.read(1L);
User u2 = userService.read(2L);
projectService.addUserToProject(p, u1, ProjectRole.PROJECT_OWNER);
projectService.addUserToProject(p, u2, ProjectRole.PROJECT_OWNER);
Collection<Join<Project, User>> usersOnProject = userService.getUsersForProject(p);
assertEquals("Wrong number of users on project.", 2, usersOnProject.size());
Set<User> users = Sets.newHashSet(u1, u2);
for (Join<Project, User> user : usersOnProject) {
assertTrue("No such user on project.", users.remove(user.getObject()));
}
assertEquals("Too many users on project", 0, users.size());
}
use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.
the class ProjectServiceImplIT method testMoveSamplesWithoutOwner.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testMoveSamplesWithoutOwner() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
List<Join<Project, Sample>> samplesForProject = sampleService.getSamplesForProject(source);
Set<Sample> samples = samplesForProject.stream().map(j -> j.getObject()).collect(Collectors.toSet());
List<ProjectSampleJoin> movedSamples = projectService.moveSamples(source, destination, samples, false);
assertEquals(samples.size(), movedSamples.size());
movedSamples.forEach(j -> {
assertFalse("Project shouldn't be owner for sample", j.isOwner());
});
assertEquals("Samples should not exist in source project", Long.valueOf(0L), projectSampleJoinRepository.countSamplesForProject(source));
assertEquals("Samples should exist in destination project", Sets.newHashSet(1L, 2L), projectSampleJoinRepository.getSamplesForProject(destination).stream().map(j -> j.getObject().getId()).collect(Collectors.toSet()));
}
use of ca.corefacility.bioinformatics.irida.model.joins.Join in project irida by phac-nml.
the class ProjectServiceImplIT method testAddUserToProject.
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testAddUserToProject() {
Project p = projectService.read(1L);
User u = userService.read(1L);
Join<Project, User> join = projectService.addUserToProject(p, u, ProjectRole.PROJECT_OWNER);
assertNotNull("Join was not populated.", join);
assertEquals("Join has wrong project.", p, join.getSubject());
assertEquals("Join has wrong user.", u, join.getObject());
List<Join<Project, User>> projects = projectService.getProjectsForUser(u);
assertEquals("User is not part of project.", p, projects.iterator().next().getSubject());
}
Aggregations