use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class BundleEntryTest method buildInvalidParametersEntry.
@Test
public void buildInvalidParametersEntry() {
ValidationException exception = assertThrows(ValidationException.class, () -> {
LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
Json json1 = new Parameters.Json(lookupRequest);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
});
Issue expectedIssue = validationErrorIssueBuilder.addLocation("ParametersRequestEntry.post").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'post' content is invalid [false]. Violation: Only POST requests can be parameter-based.").build();
assertThat(exception, FhirExceptionIssueMatcher.issue(expectedIssue));
}
use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class BundleEntryTest method requestEntryWithParametersTest.
@Test
public void requestEntryWithParametersTest() throws Exception {
LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
Json json1 = new Parameters.Json(lookupRequest);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
String json = objectMapper.writeValueAsString(entry);
Entry readEntry = objectMapper.readValue(json, Entry.class);
assertTrue(readEntry instanceof ParametersRequestEntry);
}
use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class LookupSnomedRestTest method lookupVersionPostTest.
@Test
public void lookupVersionPostTest() throws Exception {
Coding coding = Coding.builder().system("http://snomed.info/sct/900000000000207008/version/20170131").code(Concepts.IS_A).build();
LookupRequest request = LookupRequest.builder().coding(coding).build();
Fhir fhirParameters = new Parameters.Fhir(request);
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(fhirParameters).when().post("/CodeSystem/$lookup").then().statusCode(200).body("resourceType", equalTo("Parameters")).body("parameter.size()", is(2)).body("parameter[0].name", equalTo("name")).body("parameter[0].valueString", equalTo("SNOMED CT")).body("parameter[1].name", equalTo("display")).body("parameter[1].valueString", equalTo("Is a"));
}
use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class FhirCodeSystemLookupOperationTest method POST_CodeSystem_$lookup_Existing_Property.
@Test
public void POST_CodeSystem_$lookup_Existing_Property() throws Exception {
LookupRequest request = LookupRequest.builder().coding(Coding.of(SNOMEDCT_URL, CLINICAL_FINDING)).addProperty("parent").build();
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(toFhirParameters(request)).when().post(CODESYSTEM_LOOKUP).then().assertThat().statusCode(200).body("resourceType", equalTo("Parameters")).body("parameter[0].name", equalTo("name")).body("parameter[0].valueString", equalTo("SNOMEDCT")).body("parameter[1].name", equalTo("display")).body("parameter[1].valueString", equalTo("Clinical finding")).body("parameter[2].name", equalTo("property")).body("parameter[2].part[0].valueCode", equalTo("parent")).body("parameter[2].part[1].valueCode", equalTo(Concepts.ROOT_CONCEPT)).body("parameter[2].part[2].valueString", equalTo("SNOMED CT Concept"));
}
use of com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest in project snow-owl by b2ihealthcare.
the class FhirBatchApiRestTest method singleRequestWithFailedLookup.
@Test
public void singleRequestWithFailedLookup() {
LookupRequest request = LookupRequest.builder().coding(Coding.builder().system("http://snomed.info/sct").code(Concepts.IS_A).build()).build();
Json json = new Parameters.Json(request);
ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createPostRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json.parameters())).build();
RequestEntry entry2 = RequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup?system=whatever&code=1234")).build();
Bundle bundle = Bundle.builder().language("en").total(2).type(BundleType.BATCH).addEntry(entry).addEntry(entry2).build();
givenAuthenticatedRequest(FHIR_ROOT_CONTEXT).contentType(APPLICATION_FHIR_JSON).body(bundle).when().post("/").prettyPeek().then().statusCode(200).body("resourceType", equalTo("Bundle")).body("type", is("batch-response")).body("entry[0].response.status", equalTo("200")).body("entry[0].resource.resourceType", equalTo("Parameters")).body("entry[1].response.status", equalTo("404")).body("entry[1].resource.resourceType", equalTo("OperationOutcome"));
}
Aggregations