use of ca.corefacility.bioinformatics.irida.model.run.MiseqRun in project irida by phac-nml.
the class SequencingRunServiceImplIT method testCreateMiseqRunAsAdmin.
@Test
@WithMockUser(username = "fbristow", password = "password1", roles = "ADMIN")
public void testCreateMiseqRunAsAdmin() {
MiseqRun r = new MiseqRun(LayoutType.PAIRED_END, "workflow");
miseqRunService.create(r);
}
use of ca.corefacility.bioinformatics.irida.model.run.MiseqRun in project irida by phac-nml.
the class SequencingRunServiceImplIT method testCreateMiseqRunAsSequencer.
@Test
@WithMockUser(username = "sequencer", password = "password1", roles = "SEQUENCER")
public void testCreateMiseqRunAsSequencer() {
MiseqRun mr = new MiseqRun(LayoutType.PAIRED_END, "workflow");
SequencingRun returned = miseqRunService.create(mr);
assertNotNull("Created run was not assigned an ID.", returned.getId());
}
use of ca.corefacility.bioinformatics.irida.model.run.MiseqRun in project irida by phac-nml.
the class SequencingRunControllerTest method testGetDetailsPage.
@Test
public void testGetDetailsPage() throws IOException {
Long runId = 1L;
SequencingRun sequencingRunEntity = new MiseqRun(SequencingRun.LayoutType.PAIRED_END, "");
ExtendedModelMap model = new ExtendedModelMap();
when(sequencingRunService.read(runId)).thenReturn(sequencingRunEntity);
String detailsPage = controller.getDetailsPage(runId, model);
verify(sequencingRunService).read(runId);
assertEquals(SequencingRunController.DETAILS_VIEW, detailsPage);
assertEquals(sequencingRunEntity, model.get("run"));
}
use of ca.corefacility.bioinformatics.irida.model.run.MiseqRun in project irida by phac-nml.
the class SequencingRunSequenceFilesControllerTest method addSequenceFileToMiseqRunTest.
@Test
public void addSequenceFileToMiseqRunTest() throws IOException {
Long seqId = 1L;
Long sequencingrunId = 2L;
MockHttpServletResponse response = new MockHttpServletResponse();
SingleEndSequenceFile singleEndSequenceFile = TestDataFactory.constructSingleEndSequenceFile();
MiseqRun run = new MiseqRun(LayoutType.SINGLE_END, "workflow");
Map<String, String> representation = new HashMap<String, String>();
representation.put(RESTSequencingRunSequenceFilesController.SEQUENCEFILE_ID_KEY, "" + seqId);
when(objectService.read(seqId)).thenReturn(singleEndSequenceFile);
when(miseqRunService.read(sequencingrunId)).thenReturn(run);
ModelMap modelMap = controller.addSequenceFileToMiseqRun(sequencingrunId, representation, response);
verify(objectService).read(seqId);
verify(miseqRunService).read(sequencingrunId);
Object o = modelMap.get(RESTGenericController.RESOURCE_NAME);
assertNotNull("Object should not be null", o);
assertTrue("Object should be an instance of MiseqRunResource", o instanceof MiseqRun);
MiseqRun res = (MiseqRun) o;
String seqFileLocation = linkTo(RESTSequencingRunController.class).slash(sequencingrunId).slash("sequenceFiles").slash(seqId).withSelfRel().getHref();
assertEquals("Sequence file location should be correct", seqFileLocation, res.getLink(Link.REL_SELF).getHref());
assertEquals("Sequence file location should be correct", seqFileLocation, response.getHeader(HttpHeaders.LOCATION));
assertEquals("HTTP status must be CREATED", HttpStatus.CREATED.value(), response.getStatus());
}
use of ca.corefacility.bioinformatics.irida.model.run.MiseqRun in project irida by phac-nml.
the class RESTSequencingRunSequenceFilesController method addSequenceFileToMiseqRun.
/**
* Add a relationship between a {@link MiseqRun} and a {@link SequenceFile}.
*
* @param sequencingrunId
* the id of the run to add sequence file to.
* @param representation
* the JSON key-value pair that contains the identifier for the
* sequenceFile
* @param response
* a reference to the response.
* @return a response indicating that the collection was modified.
*/
@RequestMapping(value = "/api/sequencingrun/{sequencingrunId}/sequenceFiles", method = RequestMethod.POST)
public ModelMap addSequenceFileToMiseqRun(@PathVariable Long sequencingrunId, @RequestBody Map<String, String> representation, HttpServletResponse response) {
ModelMap modelMap = new ModelMap();
String stringId = representation.get(SEQUENCEFILE_ID_KEY);
long seqId = Long.parseLong(stringId);
// first, get the SequenceFile
SequencingObject sequencingObject = sequencingObjectService.read(seqId);
// then, get the miseq run
SequencingRun run = miseqRunService.read(sequencingrunId);
// then add the user to the project with the specified role.
miseqRunService.addSequencingObjectToSequencingRun(run, sequencingObject);
MiseqRun miseqRun;
if (run instanceof MiseqRun) {
miseqRun = (MiseqRun) run;
} else {
throw new IllegalArgumentException("The sequencing run ID must correspond to a a valid MiSeq sequence");
}
Link seqFileLocation = linkTo(RESTSequencingRunController.class).slash(sequencingrunId).slash("sequenceFiles").slash(seqId).withSelfRel();
miseqRun.add(seqFileLocation);
modelMap.addAttribute(RESTGenericController.RESOURCE_NAME, miseqRun);
response.addHeader(HttpHeaders.LOCATION, seqFileLocation.getHref());
response.setStatus(HttpStatus.CREATED.value());
return modelMap;
}
Aggregations