ModelMapper { public Map<?, ?> map(Object obj) { Map<?, ?> map = mapper.convertValue(obj, Map.class); map.forEach((k, v) -> reconstructGeoObjects(map, k, v)); return map; } ModelMapper(); Map<?, ?> map(Object obj); T map(Map<?, ?> map, Class<T> clazz);  }
@Test public void modelToMap_ReqlPointPreserved() { final TestModel model = new TestModel(); model.id = "test"; model.geo = new ReqlPoint(20.1, 30.0); Map result = modelMapper.map(model); assertThat(result.get("geo")).isEqualTo(model.geo); }
@Test public void modelToMap_ReqlLinePreserved() { final TestModel model = new TestModel(); model.id = "test"; model.geo = new ReqlLine(new ReqlPoint(20.1, 30.0), new ReqlPoint(22.1, 33.0)); Map result = modelMapper.map(model); assertThat(result.get("geo")).isEqualTo(model.geo); }
@Test public void modelToMap_ReqlPolygonPreserved() { final TestModel model = new TestModel(); model.id = "test"; model.geo = new ReqlPolygon(new ReqlPoint(20.1, 30.0), new ReqlPoint(22.1, 33.0), new ReqlPoint(24.1, 35.0)); Map result = modelMapper.map(model); assertThat(result.get("geo")).isEqualTo(model.geo); }