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));
}
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);
}
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();
}
}
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();
}
}
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)));
}
Aggregations