File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
main/java/uk/nhs/adaptors/gp2gp/common/service
test/java/uk/nhs/adaptors/gp2gp/common/service Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ public String encodeToJson(IBaseResource resource) {
2626
2727 private IParser prepareParser () {
2828 FhirContext ctx = FhirContext .forDstu3 ();
29- ctx .newJsonParser ();
3029 ctx .setParserErrorHandler (new StrictErrorHandler ());
3130 return ctx .newJsonParser ();
3231 }
Original file line number Diff line number Diff line change 11package uk .nhs .adaptors .gp2gp .common .service ;
22
3+ import ca .uhn .fhir .parser .DataFormatException ;
34import com .fasterxml .jackson .core .JsonProcessingException ;
45import com .fasterxml .jackson .databind .JsonNode ;
56import com .fasterxml .jackson .databind .ObjectMapper ;
@@ -44,6 +45,32 @@ void setUp() {
4445 fhirParseService = new FhirParseService ();
4546 }
4647
48+ @ Test
49+ void shouldThrowValidationExceptionForInvalidJsonDiagnosticsField () {
50+
51+ String invalidJson = "{\n "
52+ + " \" resourceType\" : \" OperationOutcome\" ,\n "
53+ + " \" meta\" : {\n "
54+ + " \" profile\" : [ \" https://fhir.nhs.uk/STU3/StructureDefinition/GPConnect-OperationOutcome-1\" ]\n "
55+ + " },\n "
56+ + " \" issue\" : [ {\n "
57+ + " \" severity\" : \" error\" ,\n "
58+ + " \" code\" : \" value\" ,\n "
59+ + " \" details\" : {\n "
60+ + " \" coding\" : [ {\n "
61+ + " \" system\" : \" http://fhir.nhs.net/ValueSet/gpconnect-error-or-warning-code-1\" ,\n "
62+ + " \" code\" : \" INVALID_IDENTIFIER_VALUE\" \n "
63+ + " } ]\n "
64+ + " },\n "
65+ + " \" diagnosticos\" : \" Provide a conversationId that exists and retry the operation\" \n "
66+ + " } ]\n "
67+ + "}" ;
68+
69+ assertThrows (FhirValidationException .class , () -> {
70+ fhirParseService .parseResource (invalidJson , OperationOutcome .class );
71+ });
72+ }
73+
4774 @ Test
4875 void ableToEncodeOperationOutcomeToJson () throws JsonProcessingException {
4976
You can’t perform that action at this time.
0 commit comments