DATAES-865 - Polishing.

This commit is contained in:
Peter-Josef Meisch
2020-06-16 18:57:38 +02:00
parent 1de1aeb2c7
commit 92f16846ab
2 changed files with 33 additions and 1 deletions

View File

@@ -789,6 +789,30 @@ public class MappingElasticsearchConverterUnitTests {
assertThat(entity.locations).containsExactly(new GeoPoint(12.34, 23.45), new GeoPoint(34.56, 45.67));
}
@Test // DATAES-865
void shouldWriteEntityWithMapAsObject() throws JSONException {
Map<String, Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EntityWithObject entity = new EntityWithObject();
entity.setId("42");
entity.setContent(map);
String expected = "{\n" + //
" \"id\": \"42\",\n" + //
" \"content\": {\n" + //
" \"foo\": \"bar\"\n" + //
" }\n" + //
"}\n"; //
Document document = Document.create();
mappingElasticsearchConverter.write(entity, document);
assertEquals(expected, document.toJson(), false);
}
private String pointTemplate(String name, Point point) {
return String.format(Locale.ENGLISH, "\"%s\":{\"lat\":%.1f,\"lon\":%.1f}", name, point.getX(), point.getY());
}
@@ -1016,4 +1040,10 @@ public class MappingElasticsearchConverterUnitTests {
@Id String id;
List<GeoPoint> locations;
}
@Data
static class EntityWithObject {
@Id private String id;
private Object content;
}
}