use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest method testSerializationAsTimestamp01Milliseconds.
@Test
public void testSerializationAsTimestamp01Milliseconds() throws Exception {
IonObjectMapper mapper = newMapperBuilder().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).disable(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS).build();
Instant date = Instant.ofEpochSecond(0L);
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 IonTimestampOffsetDateTimeDeserializerTest method testDeserializationWithTypeInfo04.
@Test
public void testDeserializationWithTypeInfo04() throws Exception {
Instant now = Instant.now();
OffsetDateTime expected = OffsetDateTime.ofInstant(now, UTC);
IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Timestamp timestamp = TimestampUtils.toTimestamp(now, ZoneOffset.UTC);
Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class);
assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime);
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 IonTimestampOffsetDateTimeDeserializerTest method testDeserializationWithTypeInfo01NonUTCDefault.
@Test
public void testDeserializationWithTypeInfo01NonUTCDefault() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), Z1);
IonObjectMapper m = newMapperBuilder().defaultTimeZone(TimeZone.getTimeZone(Z1)).enable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\",123456789.183917322]", Temporal.class);
assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime);
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 IonTimestampOffsetDateTimeDeserializerTest method testDeserializationWithTypeInfo04NonUTCOffset.
@Test
public void testDeserializationWithTypeInfo04NonUTCOffset() throws Exception {
Instant now = Instant.now();
OffsetDateTime expected = OffsetDateTime.ofInstant(now, Z1);
IonObjectMapper m = newMapperBuilder().addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Timestamp timestamp = TimestampUtils.toTimestamp(now, expected.getOffset());
Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\"," + timestamp.toString() + "]", Temporal.class);
assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime);
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 IonTimestampOffsetDateTimeSerializerTest method testSerializationAsString03.
@Test
public void testSerializationAsString03() throws Exception {
OffsetDateTime date = OffsetDateTime.now(Z3);
IonObjectMapper mapper = newMapperBuilder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).build();
String value = mapper.writeValueAsString(date);
assertEquals("The value is not correct.", TimestampUtils.toTimestamp(date.toInstant(), date.getOffset()).toString(), value);
}
Aggregations