use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AnalysisSubmissionSampleProcessorImplIT method testUpdateSamplesFailAnalysisSubmittedNonProjectOwner.
/**
* Verifies that even if "fbristow" (the project owner) is set to run this
* code, the RunAsUserAspect will switch the user to the owner of the
* analysis submission, a non-project owner who should not have the ability
* to write to the samples (and so should throw an AccessDeniedException
* for this test).
*/
@Test(expected = AccessDeniedException.class)
@WithMockUser(username = "fbristow", roles = "USER")
public void testUpdateSamplesFailAnalysisSubmittedNonProjectOwner() throws PostProcessingException {
AnalysisSubmission a = analysisSubmissionRepository.findOne(3L);
analysisSubmissionSampleProcessorImpl.updateSamples(a);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class AssemblySampleUpdaterIT method testUpdateSuccess.
@Test
@WithMockUser(username = "fbristow", roles = "USER")
public void testUpdateSuccess() {
AnalysisSubmission a = analysisSubmissionRepository.findOne(1L);
Sample s = sampleRepository.findOne(2L);
assertEquals("Should be no join between sample and assembly", 0, sampleGenomeAssemblyJoinRepository.count());
assemblySampleUpdater.update(Sets.newHashSet(s), a);
assertEquals("Should exist a join between sample and assembly", 1, sampleGenomeAssemblyJoinRepository.count());
SampleGenomeAssemblyJoin j = sampleGenomeAssemblyJoinRepository.findAll().iterator().next();
assertEquals("Should have joined sample 2L", (Long) 2L, j.getSubject().getId());
assertNotNull("Should have joined an assembly", j.getObject().getId());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class SISTRSampleUpdaterTest method testUpdaterPassed.
@SuppressWarnings("unchecked")
@Test
public void testUpdaterPassed() throws PostProcessingException, AnalysisAlreadySetException {
ImmutableMap<String, String> expectedResults = ImmutableMap.of("SISTR serovar", "Enteritidis", "SISTR cgMLST Subspecies", "enterica", "SISTR QC Status", "PASS");
Path outputPath = Paths.get("src/test/resources/files/sistr-predictions-pass.json");
AnalysisOutputFile outputFile = new AnalysisOutputFile(outputPath, null, null, null);
Analysis analysis = new Analysis(null, ImmutableMap.of("sistr-predictions", outputFile), null, null);
AnalysisSubmission submission = AnalysisSubmission.builder(UUID.randomUUID()).inputFiles(ImmutableSet.of(new SingleEndSequenceFile(null))).build();
submission.setAnalysis(analysis);
Sample sample = new Sample();
sample.setId(1L);
ImmutableMap<MetadataTemplateField, MetadataEntry> metadataMap = ImmutableMap.of(new MetadataTemplateField("SISTR Field", "text"), new MetadataEntry("Value1", "text"));
when(metadataTemplateService.getMetadataMap(any(Map.class))).thenReturn(metadataMap);
updater.update(Lists.newArrayList(sample), submission);
ArgumentCaptor<Map> mapCaptor = ArgumentCaptor.forClass(Map.class);
// this is the important bit. Ensures the correct values got pulled from the file
verify(metadataTemplateService).getMetadataMap(mapCaptor.capture());
Map<String, MetadataEntry> metadata = mapCaptor.getValue();
int found = 0;
for (Map.Entry<String, MetadataEntry> e : metadata.entrySet()) {
if (expectedResults.containsKey(e.getKey())) {
String expected = expectedResults.get(e.getKey());
MetadataEntry value = e.getValue();
assertEquals("metadata values should match", expected, value.getValue());
found++;
}
}
assertEquals("should have found the same number of results", expectedResults.keySet().size(), found);
// this bit just ensures the merged data got saved
verify(sampleService).updateFields(eq(sample.getId()), mapCaptor.capture());
Map<MetadataTemplateField, MetadataEntry> value = (Map<MetadataTemplateField, MetadataEntry>) mapCaptor.getValue().get("metadata");
assertEquals(metadataMap.keySet().iterator().next(), value.keySet().iterator().next());
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class SISTRSampleUpdaterTest method testUpdaterBadFile.
@Test(expected = PostProcessingException.class)
public void testUpdaterBadFile() throws PostProcessingException, AnalysisAlreadySetException {
ImmutableMap<String, String> expectedResults = ImmutableMap.of("SISTR serovar", "Enteritidis", "SISTR cgMLST Subspecies", "enterica", "SISTR QC Status", "PASS");
Path outputPath = Paths.get("src/test/resources/files/snp_tree.tree");
AnalysisOutputFile outputFile = new AnalysisOutputFile(outputPath, null, null, null);
Analysis analysis = new Analysis(null, ImmutableMap.of("sistr-predictions", outputFile), null, null);
AnalysisSubmission submission = AnalysisSubmission.builder(UUID.randomUUID()).inputFiles(ImmutableSet.of(new SingleEndSequenceFile(null))).build();
submission.setAnalysis(analysis);
Sample sample = new Sample();
sample.setId(1L);
updater.update(Lists.newArrayList(sample), submission);
}
use of ca.corefacility.bioinformatics.irida.model.workflow.submission.AnalysisSubmission in project irida by phac-nml.
the class SISTRSampleUpdaterTest method testUpdaterNoFile.
@Test(expected = PostProcessingException.class)
public void testUpdaterNoFile() throws PostProcessingException, AnalysisAlreadySetException {
ImmutableMap<String, String> expectedResults = ImmutableMap.of("SISTR serovar", "Enteritidis", "SISTR cgMLST Subspecies", "enterica", "SISTR QC Status", "PASS");
Path outputPath = Paths.get("src/test/resources/files/not_really_a_file.txt");
AnalysisOutputFile outputFile = new AnalysisOutputFile(outputPath, null, null, null);
Analysis analysis = new Analysis(null, ImmutableMap.of("sistr-predictions", outputFile), null, null);
AnalysisSubmission submission = AnalysisSubmission.builder(UUID.randomUUID()).inputFiles(ImmutableSet.of(new SingleEndSequenceFile(null))).build();
submission.setAnalysis(analysis);
Sample sample = new Sample();
sample.setId(1L);
updater.update(Lists.newArrayList(sample), submission);
}
Aggregations