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);
}
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)));
}
Aggregations