Search in sources :

Example 1 with Snapshot

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.Snapshot in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotController method addSnapshot.

@PostMapping(consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
@io.swagger.annotations.ApiOperation(value = "Create Snapshot", notes = "A `POST` request will create new snapshot for a particular survey.", response = Snapshot.class, tags = {})
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponse(code = 201, message = "The created snapshot", response = Snapshot.class) })
public ResponseEntity addSnapshot(@AuthenticationPrincipal UserDetailsDTO details, @ApiParam(value = "The snapshot", required = true) @RequestBody NewSnapshot snapshot) throws NotFoundException, URISyntaxException {
    LOG.debug("REST request to add Snapshot : {}", snapshot);
    Snapshot data = snapshotService.addSurveySnapshot(details, snapshot);
    URI surveyLocation = new URI("/snapshots/" + data.getSurveyId());
    return ResponseEntity.created(surveyLocation).body(data);
}
Also used : Snapshot(py.org.fundacionparaguaya.pspserver.surveys.dtos.Snapshot) NewSnapshot(py.org.fundacionparaguaya.pspserver.surveys.dtos.NewSnapshot) URI(java.net.URI) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 2 with Snapshot

use of py.org.fundacionparaguaya.pspserver.surveys.dtos.Snapshot in project FP-PSP-SERVER by FundacionParaguaya.

the class SnapshotControllerTest method shouldPostToCreateSnapshot.

@Test
public void shouldPostToCreateSnapshot() throws Exception {
    Snapshot snapshot = getSnapshot();
    when(service.addSurveySnapshot(anyObject(), anyObject())).thenReturn(snapshot);
    String content = TestHelper.mapToJson(snapshot);
    this.mockMvc.perform(post("/api/v1/snapshots").content(content).contentType(MediaType.APPLICATION_JSON_UTF8)).andDo(print()).andExpect(status().isCreated()).andDo(document("snapshots-post", preprocessRequest(prettyPrint()), preprocessResponse(prettyPrint()), requestFields(snapshotDescriptor)));
}
Also used : Snapshot(py.org.fundacionparaguaya.pspserver.surveys.dtos.Snapshot) Test(org.junit.Test) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)

Aggregations

Snapshot (py.org.fundacionparaguaya.pspserver.surveys.dtos.Snapshot)2 URI (java.net.URI)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1 NewSnapshot (py.org.fundacionparaguaya.pspserver.surveys.dtos.NewSnapshot)1