use of com.b2international.snowowl.fhir.core.model.OperationOutcome in project snow-owl by b2ihealthcare.
the class OperationOutcomeTest method serialize.
@Test
public void serialize() throws JsonProcessingException {
OperationOutcome operationOutcome = OperationOutcome.builder().addIssue(Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).addLocation("location").build()).build();
JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(operationOutcome));
assertThat(jsonPath.getString("resourceType"), equalTo("OperationOutcome"));
jsonPath.setRoot("issue[0]");
assertThat(jsonPath.getString("severity"), equalTo("error"));
assertThat(jsonPath.getString("code"), equalTo("required"));
assertThat(jsonPath.getList("location"), equalTo(Lists.newArrayList("location")));
}
use of com.b2international.snowowl.fhir.core.model.OperationOutcome in project snow-owl by b2ihealthcare.
the class AbstractFhirController method handle.
@ExceptionHandler
@ResponseStatus(HttpStatus.UNAUTHORIZED)
@ResponseBody
public ResponseEntity<OperationOutcome> handle(final UnauthorizedException ex) {
FhirException fhirException = FhirException.createFhirError(ex.getMessage(), OperationOutcomeCode.MSG_AUTH_REQUIRED);
OperationOutcome body = fhirException.toOperationOutcome();
HttpHeaders headers = new HttpHeaders();
headers.add("WWW-Authenticate", "Basic");
headers.add("WWW-Authenticate", "Bearer");
return new ResponseEntity<>(body, headers, HttpStatus.UNAUTHORIZED);
}
Aggregations