Search in sources :

Example 1 with SubProperty

use of com.b2international.snowowl.fhir.core.model.dt.SubProperty 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)

Aggregations

Property (com.b2international.snowowl.fhir.core.model.codesystem.Property)1 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)1 SubProperty (com.b2international.snowowl.fhir.core.model.dt.SubProperty)1 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)1 JsonPath (io.restassured.path.json.JsonPath)1 Test (org.junit.Test)1