Search in sources :

Example 1 with LocationEntity

use of io.requery.test.model3.LocationEntity in project requery by requery.

the class JacksonTest method testEmbedSerialize.

@Test
public void testEmbedSerialize() {
    LocationEntity t1 = new LocationEntity();
    t1.setId(1);
    data.insert(t1);
    ObjectMapper mapper = new EntityMapper(Models.MODEL3, data);
    StringWriter writer = new StringWriter();
    try {
        mapper.writeValue(writer, t1);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    String value = writer.toString();
    System.out.println(value);
    try {
        LocationEntity location = mapper.readValue(value, LocationEntity.class);
        assertSame(t1, location);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : StringWriter(java.io.StringWriter) LocationEntity(io.requery.test.model3.LocationEntity) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) EntityMapper(io.requery.jackson.EntityMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 EntityMapper (io.requery.jackson.EntityMapper)1 LocationEntity (io.requery.test.model3.LocationEntity)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 Test (org.junit.Test)1