use of ca.corefacility.bioinformatics.irida.model.project.Project 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.project.Project 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.project.Project 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.project.Project in project irida by phac-nml.
the class ProjectServiceImplIT method testAddRelatedProjectNotAllowed.
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user2", password = "password1", roles = "USER")
public void testAddRelatedProjectNotAllowed() {
Project p6 = projectService.read(6L);
Project p3 = projectService.read(3L);
projectService.addRelatedProject(p6, p3);
}
use of ca.corefacility.bioinformatics.irida.model.project.Project in project irida by phac-nml.
the class ProjectServiceImplIT method testGetUnassociatedProjects.
@Test
@WithMockUser(username = "groupuser", roles = "USER")
public void testGetUnassociatedProjects() {
final Project p = projectService.read(9L);
final Project unassociatedProject = projectService.read(8L);
final Page<Project> unassociated = projectService.getUnassociatedProjects(p, "", 0, 10, Direction.ASC, "name");
assertEquals("This user should have three unassociated projects (one group, two user).", 3, unassociated.getNumberOfElements());
assertTrue("The unassociated project should be the other project.", unassociated.getContent().contains(unassociatedProject));
}
Aggregations