Search in sources :

Example 36 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile 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));
}
Also used : Sample(ca.corefacility.bioinformatics.irida.model.sample.Sample) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) ProjectSampleJoin(ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin) Project(ca.corefacility.bioinformatics.irida.model.project.Project) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) DataAddedToSampleProjectEvent(ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent) SampleSequencingObjectJoin(ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin) UserRoleSetProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRoleSetProjectEvent) UserRemovedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.UserRemovedProjectEvent) DataAddedToSampleProjectEvent(ca.corefacility.bioinformatics.irida.model.event.DataAddedToSampleProjectEvent) ProjectEvent(ca.corefacility.bioinformatics.irida.model.event.ProjectEvent) SampleAddedProjectEvent(ca.corefacility.bioinformatics.irida.model.event.SampleAddedProjectEvent) Test(org.junit.Test)

Example 37 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class GzipFileProcessorTest method handleUncompressedFile.

@Test
public void handleUncompressedFile() throws IOException {
    // the file processor just shouldn't do *anything*.
    SequenceFile sf = constructSequenceFile();
    Path original = sf.getFile();
    SingleEndSequenceFile so = new SingleEndSequenceFile(sf);
    fileProcessor.process(so);
    verify(sequenceFileRepository, times(0)).save(any(SequenceFile.class));
    Files.deleteIfExists(sf.getFile());
    Files.deleteIfExists(original);
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 38 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SequenceFileRepositoryImplTest method testUpdateFileMissingIdentifier.

@Test
public void testUpdateFileMissingIdentifier() throws IOException {
    SequenceFile s = new SequenceFile(getTempFile());
    try {
        repository.save(s);
        fail();
    } catch (IllegalArgumentException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) IOException(java.io.IOException) Test(org.junit.Test)

Example 39 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SequenceFileRepositoryImplTest method testUpdateMissingDirectory.

@Test
public void testUpdateMissingDirectory() throws IOException {
    Path f = getTempFile();
    SequenceFile s = new SequenceFile(f);
    try {
        repository.save(s);
        fail();
    } catch (IllegalArgumentException e) {
    } catch (Exception e) {
        fail();
    }
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) IOException(java.io.IOException) Test(org.junit.Test)

Example 40 with SequenceFile

use of ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile in project irida by phac-nml.

the class SequenceFileRepositoryImplTest method testUpdate.

@Test
public void testUpdate() throws IOException {
    Long lId = new Long(9999);
    Path originalFile = getTempFile();
    SequenceFile original = new SequenceFile(originalFile);
    original.setId(lId);
    when(entityManager.find(SequenceFile.class, lId)).thenReturn(original);
    when(entityManager.merge(original)).thenReturn(original);
    original = repository.save(original);
    Path updatedFile = getTempFile();
    original.setFile(updatedFile);
    SequenceFile updated = repository.save(original);
    Path updatedPersistedFile = updated.getFile();
    assertEquals(updatedFile.getFileName(), updatedPersistedFile.getFileName());
    assertTrue(Files.exists(baseDirectory.resolve(updatedPersistedFile)));
    // make sure that the other file is still there:
    Path file = original.getFile();
    assertTrue(Files.exists(baseDirectory.resolve(file)));
}
Also used : Path(java.nio.file.Path) SequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile) Test(org.junit.Test)

Aggregations

SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)111 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)84 Test (org.junit.Test)61 Path (java.nio.file.Path)50 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)39 SampleSequencingObjectJoin (ca.corefacility.bioinformatics.irida.model.sample.SampleSequencingObjectJoin)31 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)25 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)20 Project (ca.corefacility.bioinformatics.irida.model.project.Project)15 AnalysisFastQC (ca.corefacility.bioinformatics.irida.model.workflow.analysis.AnalysisFastQC)15 WithMockUser (org.springframework.security.test.context.support.WithMockUser)13 IOException (java.io.IOException)11 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)9 ArrayList (java.util.ArrayList)9 ProjectSampleJoin (ca.corefacility.bioinformatics.irida.model.joins.impl.ProjectSampleJoin)8 GZIPOutputStream (java.util.zip.GZIPOutputStream)8 Link (org.springframework.hateoas.Link)8 AnalysisSubmission (ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission)7 OutputStream (java.io.OutputStream)7 Before (org.junit.Before)7