Search in sources :

Example 31 with JsonPath

use of io.restassured.path.json.JsonPath in project snow-owl by b2ihealthcare.

the class SignatureTest method serializeWithReference.

@Test
public void serializeWithReference() throws Exception {
    DateFormat df = new SimpleDateFormat(FhirDates.DATE_TIME_FORMAT);
    Date date = df.parse(TEST_DATE_STRING);
    Instant instant = Instant.builder().instant(date).build();
    Signature signature = Signature.builder().addType(Coding.builder().build()).contentType(new Code("contentTypeCode")).when(instant).whoReference(Reference.builder().reference("reference").identifier(Identifier.builder().build()).display("display").build()).onBehalfOfUri(new Uri("onBehalfUri")).blob("blob".getBytes()).build();
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(signature));
    assertThat(jsonPath.getString("when"), equalTo("2018-03-23T07:49:40Z"));
    jsonPath.setRoot("whoReference");
    assertThat(jsonPath.getString("reference"), equalTo("reference"));
    assertThat(jsonPath.getString("identifier.system"), equalTo(null));
    assertThat(jsonPath.getString("display"), equalTo("display"));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) JsonPath(io.restassured.path.json.JsonPath) SimpleDateFormat(java.text.SimpleDateFormat) OperationOutcomeCode(com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode) Date(java.util.Date) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 32 with JsonPath

use of io.restassured.path.json.JsonPath in project snow-owl by b2ihealthcare.

the class SignatureTest method serialize.

@Test
public void serialize() throws Exception {
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(signature));
    assertThat(jsonPath.getString("when"), equalTo("2018-03-23T07:49:40Z"));
    assertThat(jsonPath.getString("whoUri"), equalTo("whoUri"));
    assertThat(jsonPath.getString("onBehalfOfUri"), equalTo("onBehalfUri"));
    assertThat(jsonPath.getString("contentType"), equalTo("contentTypeCode"));
    assertThat(jsonPath.getString("type[0].code"), equalTo("codingCode"));
    assertThat(jsonPath.getString("type[0].display"), equalTo("codingDisplay"));
    List<Byte> blobList = jsonPath.getList("blob");
    byte[] bytes = Bytes.toArray(blobList);
    assertEquals("blob", new String(bytes));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 33 with JsonPath

use of io.restassured.path.json.JsonPath in project snow-owl by b2ihealthcare.

the class CodingTest method serialize.

@Test
public void serialize() throws Exception {
    Coding coding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(coding));
    assertThat(jsonPath.getString("code"), equalTo("1234"));
    assertThat(jsonPath.getString("system"), equalTo("http://www.whocc.no/atc"));
    assertThat(jsonPath.getString("version"), equalTo("20180131"));
}
Also used : Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 34 with JsonPath

use of io.restassured.path.json.JsonPath in project snow-owl by b2ihealthcare.

the class DesignationSerializationTest method designationTest.

@Test
public void designationTest() throws Exception {
    Coding coding = Coding.builder().code("1234").system("http://www.whocc.no/atc").version("20180131").build();
    Designation designation = Designation.builder().languageCode("en_uk").use(coding).value("dValue").build();
    Fhir fhirParameters = new Parameters.Fhir(designation);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(fhirParameters));
    assertThat(jsonPath.getString("resourceType"), equalTo("Parameters"));
    assertThat(jsonPath.getString("parameter[0].name"), equalTo("language"));
    assertThat(jsonPath.getString("parameter[0].valueCode"), equalTo("en_uk"));
    assertThat(jsonPath.getString("parameter[2].name"), equalTo("value"));
    assertThat(jsonPath.getString("parameter[2].valueString"), equalTo("dValue"));
    jsonPath.setRoot("parameter[1]");
    assertThat(jsonPath.getString("name"), equalTo("use"));
    assertThat(jsonPath.getString("valueCoding.code"), equalTo("1234"));
    assertThat(jsonPath.getString("valueCoding.system"), equalTo("http://www.whocc.no/atc"));
    assertThat(jsonPath.getString("valueCoding.version"), equalTo("20180131"));
}
Also used : Designation(com.b2international.snowowl.fhir.core.model.Designation) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) 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 35 with JsonPath

use of io.restassured.path.json.JsonPath in project snow-owl by b2ihealthcare.

the class BindingTest method serialize.

@Test
public void serialize() throws Exception {
    printPrettyJson(binding);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(binding));
    assertThat(jsonPath.getString("id"), equalTo("id"));
    assertThat(jsonPath.getString("strength"), equalTo("strength"));
    assertThat(jsonPath.getString("description"), equalTo("bindingDescription"));
    assertThat(jsonPath.getString("valueSetReference.reference"), equalTo("reference"));
}
Also used : JsonPath(io.restassured.path.json.JsonPath) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

JsonPath (io.restassured.path.json.JsonPath)117 Test (org.junit.Test)101 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)82 Response (io.restassured.response.Response)9 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)8 Date (java.util.Date)6 Property (com.b2international.snowowl.fhir.core.model.codesystem.Property)4 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)4 SubProperty (com.b2international.snowowl.fhir.core.model.dt.SubProperty)4 CodeSystem (com.b2international.snowowl.fhir.core.model.codesystem.CodeSystem)3 Uri (com.b2international.snowowl.fhir.core.model.dt.Uri)3 HashMap (java.util.HashMap)3 TranslateResult (com.b2international.snowowl.fhir.core.model.conceptmap.TranslateResult)2 BigDecimal (java.math.BigDecimal)2 SimpleDateFormat (java.text.SimpleDateFormat)2 ArrayList (java.util.ArrayList)2 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 MappingJackson2HttpMessageConverter (org.springframework.http.converter.json.MappingJackson2HttpMessageConverter)2 MockMvc (org.springframework.test.web.servlet.MockMvc)2 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)1