Search in sources :

Example 1 with MiseqRun

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);
}
Also used : MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 2 with MiseqRun

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());
}
Also used : MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) WithMockUser(org.springframework.security.test.context.support.WithMockUser) Test(org.junit.Test)

Example 3 with MiseqRun

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"));
}
Also used : MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) ExtendedModelMap(org.springframework.ui.ExtendedModelMap) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) Test(org.junit.Test)

Example 4 with MiseqRun

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());
}
Also used : MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) RESTSequencingRunController(ca.corefacility.bioinformatics.irida.web.controller.api.sequencingrun.RESTSequencingRunController) HashMap(java.util.HashMap) ModelMap(org.springframework.ui.ModelMap) MockHttpServletResponse(org.springframework.mock.web.MockHttpServletResponse) SingleEndSequenceFile(ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile) Test(org.junit.Test)

Example 5 with MiseqRun

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;
}
Also used : SequencingObject(ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject) MiseqRun(ca.corefacility.bioinformatics.irida.model.run.MiseqRun) SequencingRun(ca.corefacility.bioinformatics.irida.model.run.SequencingRun) ModelMap(org.springframework.ui.ModelMap) Link(org.springframework.hateoas.Link) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MiseqRun (ca.corefacility.bioinformatics.irida.model.run.MiseqRun)9 Test (org.junit.Test)8 SequencingRun (ca.corefacility.bioinformatics.irida.model.run.SequencingRun)7 SingleEndSequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SingleEndSequenceFile)3 WithMockUser (org.springframework.security.test.context.support.WithMockUser)3 Sample (ca.corefacility.bioinformatics.irida.model.sample.Sample)2 SequencingObject (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequencingObject)2 ExtendedModelMap (org.springframework.ui.ExtendedModelMap)2 ModelMap (org.springframework.ui.ModelMap)2 SequenceFile (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFile)1 SequenceFilePair (ca.corefacility.bioinformatics.irida.model.sequenceFile.SequenceFilePair)1 RESTSequencingRunController (ca.corefacility.bioinformatics.irida.web.controller.api.sequencingrun.RESTSequencingRunController)1 HashMap (java.util.HashMap)1 Link (org.springframework.hateoas.Link)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1