use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampInstantSerializerTest 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();
Instant date = Instant.now();
String value = mapper.writeValueAsString(date);
// TODO
assertEquals("The value is not correct.", TimestampUtils.getFractionalSeconds(date).toString(), value);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationWithTypeInfo01.
/*
**********************************************************************
* Deserialization from values with type info
**********************************************************************
*/
@Test
public void testDeserializationWithTypeInfo01() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 183917322), UTC);
IonObjectMapper m = newMapperBuilder().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 testDeserializationWithTypeInfo03.
@Test
public void testDeserializationWithTypeInfo03() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 422000000), UTC);
IonObjectMapper m = newMapperBuilder().disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\", 123456789422]", 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 testDeserializationWithTypeInfo02NonUTCDefault.
@Test
public void testDeserializationWithTypeInfo02NonUTCDefault() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 0), 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]", 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 testDeserializationWithTypeInfo03NonUTCDefault.
@Test
public void testDeserializationWithTypeInfo03NonUTCDefault() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 422000000), Z1);
IonObjectMapper m = newMapperBuilder().defaultTimeZone(TimeZone.getTimeZone(Z1)).disable(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS).addMixIn(Temporal.class, MockObjectConfiguration.class).build();
Temporal actual = m.readValue("[\"" + OffsetDateTime.class.getName() + "\", 123456789422]", Temporal.class);
assertTrue("The value should be an OffsetDateTime.", actual instanceof OffsetDateTime);
assertEquals("The value is not correct.", expected, actual);
}
Aggregations