use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile 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.SequenceFile in project irida by phac-nml.
the class NcbiExportSubmissionServceTest method testCreatePairs.
@Test
public void testCreatePairs() {
SequenceFile sequenceFile = new SequenceFile();
NcbiBioSampleFiles ncbiBioSampleFiles = new NcbiBioSampleFiles("sample", Lists.newArrayList(), Lists.newArrayList(new SequenceFilePair(sequenceFile, sequenceFile)), null, "library_name", null, null, null, "library_construction_protocol", "namespace");
NcbiExportSubmission submission = new NcbiExportSubmission(null, null, "bioProjectId", "organization", "ncbiNamespace", new Date(), Lists.newArrayList(ncbiBioSampleFiles));
service.create(submission);
verify(repository).save(submission);
}
use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile 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.SequenceFile 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.SequenceFile 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