Search in sources :

Example 46 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class PropertySerializationTest method dateTimePropertyTest.

@Test
public void dateTimePropertyTest() throws Exception {
    Date date = Dates.parse("2018-03-09T20:50:21.000+0100", FhirDates.DATE_TIME_FORMAT);
    Property property = Property.builder().code("123").valueDateTime(date).description("propertyDescription").build();
    Fhir fhirParameters = new Parameters.Fhir(property);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(3));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("value", FhirDataType.DATETIME, "2018-03-09T19:50:21.000+0000"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("description", FhirDataType.STRING, "propertyDescription"));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) SubProperty(com.b2international.snowowl.fhir.core.model.dt.SubProperty) Date(java.util.Date) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 47 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class PropertySerializationTest method subPropertyTest.

@Test
public void subPropertyTest() throws Exception {
    Property property = Property.builder().code("123").valueInteger(2).description("propertyDescription").addSubProperty(SubProperty.builder().code("subCode").description("subDescription").valueInteger(1).build()).build();
    Fhir fhirParameters = new Parameters.Fhir(property);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(4));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("code", FhirDataType.CODE, "123"));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("value", FhirDataType.INTEGER, 2));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("description", FhirDataType.STRING, "propertyDescription"));
    assertThat(jsonPath.getString("parameter[3].name"), equalTo("subproperty"));
    assertThat(jsonPath.getString("parameter[3].part[0].name"), equalTo("code"));
    assertThat(jsonPath.getString("parameter[3].part[0].valueCode"), equalTo("subCode"));
    assertThat(jsonPath.getString("parameter[3].part[1].name"), equalTo("value"));
    assertThat(jsonPath.getInt("parameter[3].part[1].valueInteger"), equalTo(1));
    assertThat(jsonPath.getString("parameter[3].part[2].name"), equalTo("description"));
    assertThat(jsonPath.getString("parameter[3].part[2].valueString"), equalTo("subDescription"));
}
Also used : Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) Property(com.b2international.snowowl.fhir.core.model.codesystem.Property) SubProperty(com.b2international.snowowl.fhir.core.model.dt.SubProperty) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 48 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class TranslateResultSerializationTest method validResultTest.

@Test
public void validResultTest() throws Exception {
    Match match = Match.builder().equivalence(ConceptMapEquivalence.EQUAL).build();
    Match match2 = Match.builder().equivalence(ConceptMapEquivalence.DISJOINT).build();
    TranslateResult translateResult = TranslateResult.builder().message("This is a test result").addMatch(match).addMatch(match2).build();
    Fhir fhirParameters = new Parameters.Fhir(translateResult);
    Parameter parameter = fhirParameters.getByName("result").get();
    Boolean result = (Boolean) parameter.getValue();
    assertEquals(true, result.booleanValue());
    parameter = fhirParameters.getByName("message").get();
    String message = (String) parameter.getValue();
    assertEquals("This is a test result", message);
    parameter = fhirParameters.getByName("match").get();
    Parameters matchParameters = (Parameters) parameter.getValue();
    parameter = matchParameters.getByName("equivalence").get();
    assertEquals("equal", ((Code) parameter.getValue()).getCodeValue());
}
Also used : Parameters(com.b2international.snowowl.fhir.core.model.dt.Parameters) TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Parameter(com.b2international.snowowl.fhir.core.model.dt.Parameter) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) Match(com.b2international.snowowl.fhir.core.model.conceptmap.Match) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 49 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class TranslateResultSerializationTest method falseResultTest.

@Test
public void falseResultTest() throws Exception {
    TranslateResult translateResult = TranslateResult.builder().build();
    Fhir fhirParameters = new Parameters.Fhir(translateResult);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(1));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("result", FhirDataType.BOOLEAN, false));
}
Also used : TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 50 with Fhir

use of com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir in project snow-owl by b2ihealthcare.

the class TranslateResultSerializationTest method parameterizedTest.

@Test
public void parameterizedTest() throws Exception {
    TranslateResult translateResult = TranslateResult.builder().build();
    Fhir fhirParameters = new Parameters.Fhir(translateResult);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getList("parameter").size(), is(1));
    assertThat(jsonPath, FhirParameterMatcher.hasParameter("result", FhirDataType.BOOLEAN, false));
}
Also used : TranslateResult(com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult) Fhir(com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir) JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)52 Test (org.junit.Test)44 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)35 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)23 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)19 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)11 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)10 FhirRestTest (com.b2international.snowowl.fhir.tests.FhirRestTest)9 ValidateCodeRequest (com.b2international.snowowl.fhir.core.model.codesystem.ValidateCodeRequest)8 JsonPath (io.restassured.path.json.JsonPath)8 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)7 Optional (java.util.Optional)6 Assert.assertTrue (org.junit.Assert.assertTrue)6 Bundle (com.b2international.snowowl.fhir.core.model.Bundle)5 Entry (com.b2international.snowowl.fhir.core.model.Entry)5 Issue (com.b2international.snowowl.fhir.core.model.Issue)5 OperationOutcomeEntry (com.b2international.snowowl.fhir.core.model.OperationOutcomeEntry)5 ParametersRequestEntry (com.b2international.snowowl.fhir.core.model.ParametersRequestEntry)5 ParametersResponseEntry (com.b2international.snowowl.fhir.core.model.ParametersResponseEntry)5 ResourceRequestEntry (com.b2international.snowowl.fhir.core.model.ResourceRequestEntry)5