Search in sources :

Example 76 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class ProjectServiceImplIT method testMoveSamplesWithoutOwnerRemoteFail.

@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "user1", roles = "USER")
public void testMoveSamplesWithoutOwnerRemoteFail() {
    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.moveSamples(source, destination, samples, false);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 77 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class ProjectServiceImplIT method testAddSampleToProjectWithSameSequencerId.

@Test(expected = EntityExistsException.class)
@WithMockUser(username = "admin", roles = "ADMIN")
public void testAddSampleToProjectWithSameSequencerId() {
    Sample s = sampleService.read(1L);
    Project p = projectService.read(1L);
    projectService.addSampleToProject(p, s, true);
    Sample otherSample = new Sample(s.getSampleName());
    projectService.addSampleToProject(p, otherSample, true);
    // if 2 exist with the same id, this call will fail
    Sample sampleBySequencerSampleId = sampleService.getSampleBySampleName(p, otherSample.getSampleName());
    assertNotNull(sampleBySequencerSampleId);
}
Also used : Project(ca.corefacility.bioinformatics.irida.model.project.Project) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 78 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample 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 79 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class SequencingObjectServiceImplIT method testGetSequenceFilePairForSample.

@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetSequenceFilePairForSample() {
    Sample s = sampleService.read(2L);
    Set<Long> fileIds = Sets.newHashSet(3L, 4L);
    Collection<SampleSequencingObjectJoin> sequenceFilePairsForSample = objectService.getSequencesForSampleOfType(s, SequenceFilePair.class);
    assertEquals(1, sequenceFilePairsForSample.size());
    SequencingObject pair = sequenceFilePairsForSample.iterator().next().getObject();
    for (SequenceFile file : pair.getFiles()) {
        assertTrue("file id should be in set", fileIds.contains(file.getId()));
        fileIds.remove(file.getId());
    }
    assertTrue("all file ids should have been found", fileIds.isEmpty());
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 80 with Sample

use of ca.corefacility.bioinformatics.irida.model.sample.Sample in project irida by phac-nml.

the class SequencingObjectServiceImplIT method testGetUniqueSamplesForSequencingObjectsSuccess.

/**
 * Tests to make sure we get a properly constructed map of samples to sequencing objects.
 */
@Test
@WithMockUser(username = "admin", roles = "ADMIN")
public void testGetUniqueSamplesForSequencingObjectsSuccess() {
    SequencingObject s1 = objectService.read(1L);
    SequencingObject s2 = objectService.read(2L);
    Sample sa1 = sampleService.read(1L);
    Sample sa2 = sampleService.read(2L);
    Map<Sample, SequencingObject> sampleMap = objectService.getUniqueSamplesForSequencingObjects(Sets.newHashSet(s1, s2));
    assertEquals("Incorrect number of results returned in sample map", 2, sampleMap.size());
    assertEquals("Incorrect sequencing object mapped to sample", s2.getId(), sampleMap.get(sa1).getId());
    assertEquals("Incorrect sequencing object mapped to sample", s1.getId(), sampleMap.get(sa2).getId());
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Aggregations

Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)243 Test (org.junit.Test)162 Project (ca.corefacility.bioinformatics.irida.model.project.Project)114 WithMockUser (org.springframework.security.test.context.support.WithMockUser)71 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)62 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)53 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)53 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)41 Join (ca.corefacility.bioinformatics.irida.model.joins.Join)33 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)33 Path (java.nio.file.Path)28 ModelMap (org.springframework.ui.ModelMap)28 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)24 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)24 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)23 ArrayList (java.util.ArrayList)22 EntityNotFoundException (ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException)17 User (ca.corefacility.bioinformatics.irida.model.user.User)14 HashMap (java.util.HashMap)14 RelatedProjectJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.RelatedProjectJoin)13