use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class RESTAnalysisSubmissionController method getAnalysisForSubmission.
/**
* Get the {@link Analysis} for an {@link AnalysisSubmission}.
*
* @param identifier
* {@link AnalysisSubmission} identifier to read
* @return ModelMap containing the {@link Analysis}
*/
@RequestMapping("/{identifier}/analysis")
public ModelMap getAnalysisForSubmission(@PathVariable Long identifier) {
ModelMap model = new ModelMap();
AnalysisSubmission read = analysisSubmissionService.read(identifier);
if (read.getAnalysisState() != AnalysisState.COMPLETED) {
throw new EntityNotFoundException("Analysis is not completed");
}
Analysis analysis = read.getAnalysis();
analysis.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisForSubmission(identifier)).withSelfRel());
/*
* Add links to the available files
*/
for (String name : analysis.getAnalysisOutputFileNames()) {
analysis.add(linkTo(methodOn(RESTAnalysisSubmissionController.class).getAnalysisOutputFile(identifier, name)).withRel(FILE_REL + "/" + name));
}
model.addAttribute(RESOURCE_NAME, analysis);
return model;
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class RemoteAPITokenServiceImplIT method testDeleteToken.
@Test(expected = EntityNotFoundException.class)
public void testDeleteToken() {
RemoteAPI api = null;
try {
api = apiService.read(1L);
tokenService.delete(api);
} catch (EntityNotFoundException ex) {
fail("Token should be able to be deleted");
}
tokenService.getToken(api);
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class SequencingRunServiceImplIT method testAddSequenceFileToMiseqRun.
private void testAddSequenceFileToMiseqRun() throws IOException, InterruptedException {
SequencingRun miseqRun = miseqRunService.read(1L);
// we can't actually know a file name in the XML file that we use to
// populate the database for these tests, so the files don't exist
// anywhere. Create a new temp file and update that in the database
// prior to adding a file to a miseq run so that we have something there
// that we can link to.
Path sequenceFile = Files.createTempFile(null, null);
Files.write(sequenceFile, FASTQ_FILE_CONTENTS);
SequenceFile sf = new SequenceFile(sequenceFile);
SequencingObject so = new SingleEndSequenceFile(sf);
so = objectService.create(so);
miseqRunService.addSequencingObjectToSequencingRun(miseqRun, so);
SequencingRun saved = miseqRunService.read(1L);
SequencingObject readObject = objectService.read(so.getId());
Set<SequencingObject> sequencingObjectsForSequencingRun = objectService.getSequencingObjectsForSequencingRun(saved);
assertTrue("Saved miseq run should have seqence file", sequencingObjectsForSequencingRun.contains(so));
if (SecurityContextHolder.getContext().getAuthentication().getAuthorities().stream().anyMatch(auth -> auth.getAuthority().equals("ROLE_ADMIN"))) {
AnalysisFastQC analysis = null;
do {
try {
readObject = objectService.read(so.getId());
SequenceFile readFile = readObject.getFiles().iterator().next();
analysis = analysisService.getFastQCAnalysisForSequenceFile(readObject, readFile.getId());
} catch (final EntityNotFoundException e) {
logger.info("Fastqc still isn't finished, sleeping a bit.");
Thread.sleep(1000);
}
} while (analysis == null);
assertNotNull("FastQC analysis should have been created for uploaded file.", analysis);
}
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class GenericControllerTest method testUpdateBadResource.
@Test
public void testUpdateBadResource() throws InstantiationException, IllegalAccessException {
when(crudService.updateFields(identifier, updatedFields)).thenThrow(new EntityNotFoundException("not found"));
try {
controller.update(identifier, updatedFields);
fail();
} catch (EntityNotFoundException e) {
} catch (Exception e) {
fail();
}
}
use of ca.corefacility.bioinformatics.irida.exceptions.EntityNotFoundException in project irida by phac-nml.
the class UserControllerTest method testGetUserProjectsBadUser.
@Test
public void testGetUserProjectsBadUser() {
String username = "superbad";
when(userService.getUserByUsername(username)).thenThrow(new EntityNotFoundException(username));
try {
controller.getUserProjects(username);
fail();
} catch (EntityNotFoundException e) {
} catch (Exception e) {
fail();
}
}
Aggregations