Search in sources :

Example 1 with Instant

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

the class MetaTest method setup.

@Before
public void setup() throws Exception {
    DateFormat df = new SimpleDateFormat(FhirDates.DATE_TIME_FORMAT);
    Date date = df.parse(TEST_DATE_STRING);
    Instant instant = Instant.builder().instant(date).build();
    meta = Meta.builder().id("ID").lastUpdated(instant).versionId("VersionID").addExtension(IntegerExtension.builder().url("ExtensionId").value(1).build()).addProfile("profile").addSecurity(securityCoding).addTag(tagCoding).build();
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Instant(com.b2international.snowowl.fhir.core.model.dt.Instant) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Before(org.junit.Before)

Example 2 with Instant

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

the class TypedPropertySerializationTest method instantTypedPropertyTest.

@Test
public void instantTypedPropertyTest() throws Exception {
    Date date = Dates.parse(TEST_DATE_STRING, FhirDates.DATE_TIME_FORMAT);
    Instant instant = Instant.builder().instant(date).build();
    final class TestClass {

        @JsonUnwrapped
        @JsonProperty
        private TypedProperty<?> value = new InstantProperty(instant);
    }
    TestClass testObject = new TestClass();
    printPrettyJson(testObject);
    JsonPath jsonPath = JsonPath.from(objectMapper.writeValueAsString(testObject));
    assertThat(jsonPath.getString("valueInstant"), equalTo("2018-03-23T07:49:40Z"));
}
Also used : Instant(com.b2international.snowowl.fhir.core.model.dt.Instant) JsonPath(io.restassured.path.json.JsonPath) Date(java.util.Date) Test(org.junit.Test)

Example 3 with Instant

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

the class InstantTest method deserialize.

@Test
public void deserialize() throws JsonProcessingException {
    String time = "2021-06-25T19:33:14.520121Z";
    Instant instant = Instant.builder().instant(time).build();
    String serializedString = objectMapper.writeValueAsString(instant);
    Instant readInstant = objectMapper.readValue(serializedString, Instant.class);
    System.out.println("Expected: " + time + " actual: " + readInstant.getInstant());
    assertEquals(time, readInstant.getInstant());
}
Also used : Instant(com.b2international.snowowl.fhir.core.model.dt.Instant) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 4 with Instant

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

the class InstantTest method serialize.

@Test
public void serialize() throws JsonProcessingException {
    String time = "2021-06-25T19:33:14.520121Z";
    Instant instant = Instant.builder().instant(time).build();
    String serializedString = objectMapper.writeValueAsString(instant);
    assertEquals("\"" + time + "\"", serializedString);
}
Also used : Instant(com.b2international.snowowl.fhir.core.model.dt.Instant) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 5 with Instant

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

the class InstantTest method buildFromDate.

@Test
public void buildFromDate() throws Exception {
    Date date = Dates.parse(TEST_DATE_STRING, FhirDates.DATE_TIME_FORMAT);
    Instant instant = Instant.builder().instant(date).build();
    assertEquals("\"2018-03-23T07:49:40Z\"", objectMapper.writeValueAsString(instant));
}
Also used : Instant(com.b2international.snowowl.fhir.core.model.dt.Instant) Date(java.util.Date) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Instant (com.b2international.snowowl.fhir.core.model.dt.Instant)5 Test (org.junit.Test)4 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)3 Date (java.util.Date)3 JsonPath (io.restassured.path.json.JsonPath)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Before (org.junit.Before)1