use of ca.corefacility.bioinformatics.irida.model.sample.Sample 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.sample.Sample 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.sample.Sample in project irida by phac-nml.
the class ProjectServiceImplIT method s.
private Sample s() {
Sample s = new Sample();
s.setSampleName("Samplename");
s.setDescription("Description");
return s;
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class ProjectServiceImplIT method testShareSamplesWithOwnerRemoteFail.
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user1", roles = "USER")
public void testShareSamplesWithOwnerRemoteFail() {
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);
projectService.shareSamples(source, destination, samples, true);
}
use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.
the class ProjectServiceImplIT method testAddSampleToProjectAsSequencer.
@Test
@WithMockUser(username = "sequencer", roles = "SEQUENCER")
public void testAddSampleToProjectAsSequencer() {
Project p = projectService.read(1L);
Sample s = s();
Join<Project, Sample> join = projectService.addSampleToProject(p, s, true);
assertNotNull("Join should not be empty.", join);
assertEquals("Wrong project in join.", p, join.getSubject());
assertEquals("Wrong sample in join.", s, join.getObject());
}
Aggregations