use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class SampleSequenceFilesControllerTest method testAddNewSequenceFilePairToSampleMismatchedRunIDs.
@Test(expected = IllegalArgumentException.class)
public void testAddNewSequenceFilePairToSampleMismatchedRunIDs() throws IOException {
Project p = TestDataFactory.constructProject();
Sample s = TestDataFactory.constructSample();
SequenceFilePair pair = TestDataFactory.constructSequenceFilePair();
SampleSequencingObjectJoin sso = new SampleSequencingObjectJoin(s, pair);
SequenceFileResource resource1 = new SequenceFileResource();
SequenceFileResource resource2 = new SequenceFileResource();
resource1.setMiseqRunId(1L);
resource2.setMiseqRunId(2L);
Path f1 = Files.createTempFile(null, null);
Path f2 = Files.createTempFile(null, null);
MockMultipartFile mmf1 = new MockMultipartFile("filename1", "filename1", "blurgh1", FileCopyUtils.copyToByteArray(f1.toFile()));
MockMultipartFile mmf2 = new MockMultipartFile("filename2", "filename2", "blurgh2", FileCopyUtils.copyToByteArray(f2.toFile()));
MockHttpServletResponse response = new MockHttpServletResponse();
when(sampleService.getSampleForProject(p, s.getId())).thenReturn(new ProjectSampleJoin(p, s, true));
when(sequencingObjectService.createSequencingObjectInSample(any(SequenceFilePair.class), Matchers.eq(s))).thenReturn(sso);
controller.addNewSequenceFilePairToSample(s.getId(), mmf1, resource1, mmf2, resource2, response);
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class AssemblyFileProcessorTest method testAssembleFile.
@Test
public void testAssembleFile() {
Long sequenceFileId = 1L;
SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
Sample sample = new Sample();
Project project = new Project();
project.setAssembleUploads(true);
when(objectRepository.findOne(sequenceFileId)).thenReturn(pair);
when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(project, sample, true)));
assertTrue("should want to assemble file", processor.shouldProcessFile(sequenceFileId));
processor.process(pair);
verify(submissionRepository).save(any(AnalysisSubmission.class));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class AssemblyFileProcessorTest method testOneProjectEnabled.
@Test
public void testOneProjectEnabled() {
SequenceFilePair pair = new SequenceFilePair(new SequenceFile(Paths.get("file_R1_1.fastq.gz")), new SequenceFile(Paths.get("file_R2_1.fastq.gz")));
Sample sample = new Sample();
Project project = new Project();
project.setAssembleUploads(true);
Project disabledProject = new Project();
disabledProject.setAssembleUploads(false);
when(ssoRepository.getSampleForSequencingObject(pair)).thenReturn(new SampleSequencingObjectJoin(sample, pair));
when(psjRepository.getProjectForSample(sample)).thenReturn(ImmutableList.of(new ProjectSampleJoin(disabledProject, sample, true), new ProjectSampleJoin(project, sample, true)));
processor.process(pair);
verify(submissionRepository).save(any(AnalysisSubmission.class));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class ProjectEventHandlerTest method testHandleSequenceFileAddedEventMultipleReturn.
@SuppressWarnings("unchecked")
@Test
public void testHandleSequenceFileAddedEventMultipleReturn() {
Class<? extends ProjectEvent> clazz = DataAddedToSampleProjectEvent.class;
Project project = new Project();
Sample sample = new Sample();
SequenceFile file = new SequenceFile();
SingleEndSequenceFile seqObj1 = new SingleEndSequenceFile(file);
SingleEndSequenceFile seqObj2 = new SingleEndSequenceFile(file);
SampleSequencingObjectJoin join1 = new SampleSequencingObjectJoin(sample, seqObj1);
SampleSequencingObjectJoin join2 = new SampleSequencingObjectJoin(sample, seqObj2);
when(psjRepository.getProjectForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true)));
when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new DataAddedToSampleProjectEvent(project, sample));
Object[] args = {};
MethodEvent methodEvent = new MethodEvent(clazz, Lists.newArrayList(join1, join2), args);
handler.delegate(methodEvent);
ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
verify(eventRepository).save(captor.capture());
ProjectEvent event = captor.getValue();
assertTrue(event instanceof DataAddedToSampleProjectEvent);
verify(projectRepository).save(any(Project.class));
verify(sampleRepository).save(any(Sample.class));
}
use of ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin in project irida by phac-nml.
the class ProjectEventHandlerTest method testDelegateSampleAdded.
@Test
public void testDelegateSampleAdded() {
Class<? extends ProjectEvent> clazz = SampleAddedProjectEvent.class;
Project project = new Project();
Sample sample = new Sample();
ProjectSampleJoin returnValue = new ProjectSampleJoin(project, sample, true);
Object[] args = { project, sample };
MethodEvent methodEvent = new MethodEvent(clazz, returnValue, args);
when(eventRepository.save(any(ProjectEvent.class))).thenReturn(new SampleAddedProjectEvent(returnValue));
handler.delegate(methodEvent);
ArgumentCaptor<ProjectEvent> captor = ArgumentCaptor.forClass(ProjectEvent.class);
verify(eventRepository).save(captor.capture());
ProjectEvent event = captor.getValue();
assertTrue(event instanceof SampleAddedProjectEvent);
verify(projectRepository).save(any(Project.class));
}
Aggregations