use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class IonTimestampOffsetDateTimeDeserializerTest method testDeserializationWithTypeInfo02.
@Test
public void testDeserializationWithTypeInfo02() throws Exception {
OffsetDateTime expected = OffsetDateTime.ofInstant(Instant.ofEpochSecond(123456789L, 0), 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]", 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 IonAnnotationTypeDeserializerWithClassNameAnnotationTest method setupClass.
@BeforeClass
public static void setupClass() throws IOException {
ClassA inner = new ClassA();
inner.value = 42;
ClassB<ClassA> outer = new ClassB<>();
outer.content = inner;
IonObjectMapper mapper = new IonObjectMapper();
ionValueWithoutAnnotation = mapper.writeValueAsIonValue(outer);
mapper = constructIomWithClassNameIdResolver();
ionValueWithAnnotation = mapper.writeValueAsIonValue(outer);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class PolymorphicRoundtripTest method testSubclass.
@Test
public void testSubclass() throws IOException {
IonObjectMapper mapper = IonObjectMapper.builder().addModule(new IonAnnotationModule()).build();
Bean original = new Bean("parent_field", new ChildBeanSub("child_field", "extended_field"));
String serialized = mapper.writeValueAsString(original);
Bean deserialized = mapper.readValue(serialized, Bean.class);
assertEquals(original.field, deserialized.field);
assertEquals(original.child.someField, deserialized.child.someField);
assertTrue(deserialized.child instanceof ChildBeanSub);
assertEquals(((ChildBeanSub) original.child).extraField, ((ChildBeanSub) deserialized.child).extraField);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class PolymorphicRoundtripTest method testTopLevelPolymorphism.
@Test
public void testTopLevelPolymorphism() throws IOException {
resolveAllTypes = true;
Bean original = new Bean("parent_field", new ChildBean("child_field"));
IonObjectMapper mapper = IonObjectMapper.builder().addModule(new IonAnnotationModule()).build();
String serialized = mapper.writeValueAsString(original);
Object obj = mapper.readValue(serialized, Object.class);
assertTrue(obj instanceof Bean);
Bean deserialized = (Bean) obj;
assertEquals(original.field, deserialized.field);
assertEquals(original.child.someField, deserialized.child.someField);
}
use of com.fasterxml.jackson.dataformat.ion.IonObjectMapper in project jackson-dataformats-binary by FasterXML.
the class PolymorphicRoundtripTest method testPolymorphicTypeWithDate.
@Test
public void testPolymorphicTypeWithDate() throws IOException {
resolveAllTypes = true;
long etime = 1449191416000L;
java.util.Date uDate = new java.util.Date(etime);
java.sql.Date sDate = new java.sql.Date(etime);
Bean original = new Bean("parent_field", new ChildBeanSub("child_field", "extra_field", uDate, sDate, null));
IonObjectMapper mapper = IonObjectMapper.builder().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).addModule(new IonAnnotationModule()).build();
// roundtrip
String serialized = mapper.writeValueAsString(original);
Bean deserialized = mapper.readValue(serialized, Bean.class);
ChildBeanSub deserializedSub = (ChildBeanSub) deserialized.child;
Assert.assertEquals("Date result not the same as serialized value.", uDate, deserializedSub.uDate);
Assert.assertEquals("Date result not the same as serialized value.", sDate, deserializedSub.sDate);
}
Aggregations