use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationWithTypeInfo01.
@Test
public void testSerializationWithTypeInfo01() throws Exception {
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2);
IonObjectMapper mapper = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "'" + OffsetDateTime.class.getName() + "'::123456789.183917322", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsTimestamp03Milliseconds.
@Test
public void testSerializationAsTimestamp03Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
OffsetDateTime date = OffsetDateTime.now(Z3);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", Long.toString(date.toInstant().toEpochMilli()), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsTimestamp02Nanoseconds.
@Test
public void testSerializationAsTimestamp02Nanoseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
OffsetDateTime date = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z2);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", "123456789.183917322", value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationAsTimestamp03Nanoseconds.
@Test
public void testSerializationAsTimestamp03Nanoseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).enable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
OffsetDateTime date = OffsetDateTime.now(Z3);
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", TimestampUtils.getFractionalSeconds(date.toInstant()).toString(), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeSerializerTest method testSerializationWithTypeInfo03.
@Test
public void testSerializationWithTypeInfo03() throws Exception {
OffsetDateTime date = OffsetDateTime.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.", "'" + OffsetDateTime.class.getName() + "'::" + TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value);
}
Aggregations