use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class ExportUploadServiceTest method createFakeSubmission.
/**
* Create a fake submission for test uploads
*
* @return a {@link NcbiExportSubmission}
* @throws IOException
* if the test file couldn't be created
*/
private NcbiExportSubmission createFakeSubmission() throws IOException {
NcbiExportSubmission submission = new NcbiExportSubmission();
submission.setId(1L);
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles();
Path tempFile = Files.createTempFile("sequencefile", ".fastq");
SequenceFile sequenceFile = new SequenceFile(tempFile);
sequenceFile.setId(1L);
SingleEndSequenceFile singleFile = new SingleEndSequenceFile(sequenceFile);
singleFile.setId(1L);
ncbiBioSampleFiles.setFiles(Lists.newArrayList(singleFile));
submission.setBioSampleFiles(Lists.newArrayList(ncbiBioSampleFiles));
return submission;
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SamplesControllerTest method testUploadSequenceFiles.
// ************************************************************************************************
// AJAX REQUESTS
// ************************************************************************************************
@Test
public void testUploadSequenceFiles() throws IOException {
Sample sample = TestDataFactory.constructSample();
when(sampleService.read(sample.getId())).thenReturn(sample);
List<MultipartFile> fileList = createMultipartFileList(MULTIPARTFILE_PATHS);
ArgumentCaptor<SingleEndSequenceFile> sequenceFileArgumentCaptor = ArgumentCaptor.forClass(SingleEndSequenceFile.class);
HttpServletResponse response = new MockHttpServletResponse();
controller.uploadSequenceFiles(sample.getId(), fileList, response);
assertEquals("Response is ok", HttpServletResponse.SC_OK, response.getStatus());
verify(sequencingObjectService, times(2)).createSequencingObjectInSample(sequenceFileArgumentCaptor.capture(), eq(sample));
assertEquals("Should have the correct file name", "test_file_B.fastq", sequenceFileArgumentCaptor.getValue().getLabel());
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SamplesControllerTest method testGetSampleFiles.
@SuppressWarnings("unchecked")
@Test
public void testGetSampleFiles() throws IOException {
ExtendedModelMap model = new ExtendedModelMap();
Long sampleId = 1L;
Sample sample = new Sample();
SequenceFile file = new SequenceFile(Paths.get("/tmp"));
file.setId(2L);
Project project = new Project();
List<SampleSequencingObjectJoin> files = Lists.newArrayList(new SampleSequencingObjectJoin(sample, new SingleEndSequenceFile(file)));
when(sampleService.read(sampleId)).thenReturn(sample);
when(sequencingObjectService.getSequencesForSampleOfType(sample, SingleEndSequenceFile.class)).thenReturn(files);
when(projectService.getProjectsForSample(sample)).thenReturn(Lists.newArrayList(new ProjectSampleJoin(project, sample, true)));
when(updateSamplePermission.isAllowed(any(Authentication.class), eq(sample))).thenReturn(true);
String sampleFiles = controller.getSampleFilesWithoutProject(model, sampleId);
assertEquals(SamplesController.SAMPLE_FILES_PAGE, sampleFiles);
assertTrue((boolean) model.get(SamplesController.MODEL_ATTR_CAN_MANAGE_SAMPLE));
verify(sampleService).read(sampleId);
verify(sequencingObjectService).getSequencesForSampleOfType(sample, SingleEndSequenceFile.class);
verify(sequencingObjectService).getSequencesForSampleOfType(sample, SequenceFilePair.class);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SamplesControllerTest method testGetSampleFilesAsAdmin.
@Test
public void testGetSampleFilesAsAdmin() throws IOException {
ExtendedModelMap model = new ExtendedModelMap();
Long sampleId = 1L;
Sample sample = new Sample();
SequenceFile file = new SequenceFile(Paths.get("/tmp"));
file.setId(2L);
List<SampleSequencingObjectJoin> files = Lists.newArrayList(new SampleSequencingObjectJoin(sample, new SingleEndSequenceFile(file)));
when(sampleService.read(sampleId)).thenReturn(sample);
when(sequencingObjectService.getSequencesForSampleOfType(sample, SingleEndSequenceFile.class)).thenReturn(files);
when(updateSamplePermission.isAllowed(any(Authentication.class), eq(sample))).thenReturn(true);
String sampleFiles = controller.getSampleFilesWithoutProject(model, sampleId);
assertEquals(SamplesController.SAMPLE_FILES_PAGE, sampleFiles);
assertTrue((boolean) model.get(SamplesController.MODEL_ATTR_CAN_MANAGE_SAMPLE));
verify(sampleService).read(sampleId);
verify(sequencingObjectService).getSequencesForSampleOfType(sample, SingleEndSequenceFile.class);
verify(sequencingObjectService).getSequencesForSampleOfType(sample, SequenceFilePair.class);
verifyZeroInteractions(projectService);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile in project irida by phac-nml.
the class SamplesControllerTest method testRemoveFileFromSample.
@Test
public void testRemoveFileFromSample() {
Long sampleId = 1L;
Long fileId = 2L;
Sample sample = new Sample();
SequencingObject file = new SingleEndSequenceFile(new SequenceFile(Paths.get("/tmp")));
when(sampleService.read(sampleId)).thenReturn(sample);
when(sequencingObjectService.readSequencingObjectForSample(sample, fileId)).thenReturn(file);
RedirectAttributesModelMap attributes = new RedirectAttributesModelMap();
HttpServletRequest request = new MockHttpServletRequest();
controller.removeSequencingObjectFromSample(attributes, sampleId, fileId, request, Locale.US);
verify(sampleService).removeSequencingObjectFromSample(sample, file);
}
Aggregations