use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampZonedDateTimeSerializerTest method testSerializationAsTimestamp01Nanoseconds.
@Test
public void testSerializationAsTimestamp01Nanoseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(0L), Z1);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "0.", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampZonedDateTimeSerializerTest method testSerializationAsTimestamp02Milliseconds.
@Test
public void testSerializationAsTimestamp02Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
ZonedDateTime date = ZonedDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "123456789183", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampZonedDateTimeSerializerTest method testSerializationWithTypeInfo03.
@Test
public void testSerializationWithTypeInfo03() throws Exception {
ZonedDateTime date = ZonedDateTime.now(Z3);
IonObjectMapper mapper = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
String value = mapper.writeValueAsString(date);
assertNotNull("The value should not be null.", value);
assertEquals("The value is not correct.", "'" + ZonedDateTime.class.getName() + "'::" + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationWithTypeInfo02.
@Test
public void testDeserializationWithTypeInfo02() throws Exception {
Instant expected = Instant.ofEpochSecond(123456789L, 0);
IonObjectMapper m = newMapperBuilder().enable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\",123456789]", Temporal.class);
assertTrue("The actual should be an Instant.", actual instanceof Instant);
assertEquals("The value is not correct.", expected, actual);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantDeserializerTest method testDeserializationWithTypeInfo03.
@Test
public void testDeserializationWithTypeInfo03() throws Exception {
Instant expected = Instant.ofEpochSecond(123456789L, 422000000);
IonObjectMapper m = newMapperBuilder().disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + Instant.class.getName() + "\", 123456789422]", Temporal.class);
assertTrue("The actual should be an Instant.", actual instanceof Instant);
assertEquals("The value is not correct.", expected, actual);
}
Aggregations