use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class ParameterSerializationTest method stringParameterTest.
@Test
public void stringParameterTest() throws Exception {
@SuppressWarnings("unused")
@JsonPropertyOrder({ "parameterName" })
class StringTestParameterObject {
private String parameterName = "test";
public String getParameterName() {
return parameterName;
}
public void setParameterName(String parameterName) {
this.parameterName = parameterName;
}
}
String expected = buildExpectedJson("{\"name\":\"parameterName\",\"valueString\":\"test\"}");
Fhir fhirParameters = new Parameters.Fhir(new StringTestParameterObject());
Assert.assertEquals(expected, objectMapper.writeValueAsString(fhirParameters));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class ParameterSerializationTest method codingParameterTest.
@Test
public void codingParameterTest() throws Exception {
@SuppressWarnings("unused")
@JsonPropertyOrder({ "parameterName" })
class Test {
private Coding parameterName = Coding.builder().code("test").display("displayTest").system("systemTest").build();
public Coding getParameterName() {
return parameterName;
}
public void setParameterName(Coding parameterName) {
this.parameterName = parameterName;
}
}
String expected = buildExpectedJson("{\"name\":\"parameterName\"," + "\"valueCoding\":{\"code\":\"test\"," + "\"system\":\"systemTest\"," + "\"display\":\"displayTest\"}}");
Fhir fhirParameters = new Parameters.Fhir(new Test());
Assert.assertEquals(expected, objectMapper.writeValueAsString(fhirParameters));
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class TranslateRequestDeserializationTest method validRequestWithCodingTest.
@Test
public void validRequestWithCodingTest() throws Exception {
TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).build();
Fhir fhirParameters = new Parameters.Fhir(request);
Parameter parameter = fhirParameters.getByName("coding").get();
Coding coding = (Coding) parameter.getValue();
assertEquals("fatal", coding.getCodeValue());
assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
parameter = fhirParameters.getByName("targetsystem").get();
assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class TranslateRequestDeserializationTest method validRequestWithDependencyTest.
@Test
public void validRequestWithDependencyTest() throws Exception {
Coding dependencyCoding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
CodeableConcept cc = CodeableConcept.builder().addCoding(dependencyCoding).text("text").build();
TranslateRequest request = TranslateRequest.builder().coding(Coding.builder().system("http://hl7.org/fhir/issue-severity").code("fatal").build()).targetSystem(SnomedUri.SNOMED_BASE_URI).addDependency(Dependency.builder().element("element").concept(cc).build()).build();
Fhir fhirParameters = new Parameters.Fhir(request);
Parameter parameter = fhirParameters.getByName("coding").get();
Coding coding = (Coding) parameter.getValue();
assertEquals("fatal", coding.getCodeValue());
assertEquals("http://hl7.org/fhir/issue-severity", coding.getSystem().getUriValue());
parameter = fhirParameters.getByName("targetsystem").get();
assertEquals(SnomedUri.SNOMED_BASE_URI_STRING, ((Uri) parameter.getValue()).getUriValue());
parameter = fhirParameters.getByName("dependency").get();
Parameters dependencyParameters = (Parameters) parameter.getValue();
parameter = dependencyParameters.getByName("concept").get();
assertEquals("text", ((CodeableConcept) parameter.getValue()).getText());
}
use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.
the class ValidateCodeResultTest method fullCircleTest.
@Test
public void fullCircleTest() throws Exception {
ValidateCodeResult request = ValidateCodeResult.builder().artefactNotFoundResult("http://hl7.org/fhir/issue-severity").build();
Json json1 = new Parameters.Json(request);
System.out.println("JSON params:" + json1);
Fhir fhir = new Parameters.Fhir(json1.parameters());
String fhirJson = objectMapper.writeValueAsString(fhir);
System.out.println("This is the JSON request from the client: " + fhirJson);
System.out.println("This is happening in the server-side...");
Fhir parameters = objectMapper.readValue(fhirJson, Parameters.Fhir.class);
System.out.println("Deserialized into FHIR parameters..." + parameters.getParameters());
System.out.println("Back to Domain JSON...");
Json json = new Parameters.Json(parameters);
ValidateCodeResult validateRequest = objectMapper.convertValue(json, ValidateCodeResult.class);
System.out.println("... and back to the object representation we started from:" + validateRequest);
}
Aggregations