use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class UpdateSamplePermissionTest method testRejectPermissionNotOwner.
@Test
public void testRejectPermissionNotOwner() {
final Project p1 = new Project();
final Sample s = new Sample();
when(projectSampleJoinRepository.getProjectForSample(s)).thenReturn(ImmutableList.of(new ProjectSampleJoin(p1, s, false)));
when(projectOwnerPermission.isAllowed(auth, p1)).thenReturn(true);
assertFalse("Permission to update sample should not be given.", updateSamplePermission.isAllowed(auth, s));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class TestDataFactory method constructListJoinProjectSample.
public static List<Join<Project, Sample>> constructListJoinProjectSample() {
List<Join<Project, Sample>> list = new ArrayList<>();
Sample sample = constructSample();
Project project = constructProject();
for (int i = 0; i < 10; i++) {
list.add(new ProjectSampleJoin(project, sample, true));
}
return list;
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class ProjectServiceImplIT method testMoveSamplesWithOwner.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testMoveSamplesWithOwner() {
Project source = projectService.read(2L);
Project destination = projectService.read(10L);
Sample sample1 = sampleService.read(1L);
Set<Sample> samples = Sets.newHashSet(sample1);
List<ProjectSampleJoin> movedSamples = projectService.moveSamples(source, destination, samples, true);
assertEquals(samples.size(), movedSamples.size());
movedSamples.forEach(j -> {
assertTrue("Project should be owner for sample", j.isOwner());
});
assertNull("Sample should have been moved from source project", projectSampleJoinRepository.readSampleForProject(source, sample1));
assertNotNull("Sample should have been moved to destination project", projectSampleJoinRepository.readSampleForProject(destination, sample1));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class ProjectServiceImplIT method testMoveLockedSamplesWithoutOwner.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testMoveLockedSamplesWithoutOwner() {
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.impl.ProjectSampleJoin in project irida by phac-nml.
the class ProjectServiceImplIT method testShareSamplesWithoutOwnerRemote.
@Test
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithoutOwnerRemote() {
Project source = projectService.read(11L);
Project destination = projectService.read(10L);
assertTrue("Source project should be a remote project for the test", source.isRemote());
assertFalse("Destination project should not be a remote project for the test", destination.isRemote());
Sample sample = sampleService.read(3L);
Set<Sample> samples = Sets.newHashSet(sample);
List<ProjectSampleJoin> copiedSamples = projectService.shareSamples(source, destination, samples, false);
assertEquals(samples.size(), copiedSamples.size());
copiedSamples.forEach(j -> {
assertFalse("Project should not be owner for sample", j.isOwner());
});
assertNotNull("Samples should still exist in source project", projectSampleJoinRepository.readSampleForProject(source, sample));
assertNotNull("Sample should exist in destination project", projectSampleJoinRepository.readSampleForProject(destination, sample));
}
Aggregations