use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method shouldWriteNullValueIfConfigured.
// DATAES-920
@Test
@DisplayName("should write null value if configured")
void shouldWriteNullValueIfConfigured() throws JSONException {
EntityWithNullField entity = new EntityWithNullField();
entity.setId("42");
String expected = //
"{\n" + //
" \"id\": \"42\",\n" + //
" \"saved\": null\n" + //
"}\n";
Document document = Document.create();
mappingElasticsearchConverter.write(entity, document);
assertEquals(expected, document.toJson(), false);
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method writeToMap.
private Map<String, Object> writeToMap(Object source) {
Document sink = Document.create();
mappingElasticsearchConverter.write(source, sink);
return sink;
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method readGenericMapMap.
// DATAES-530
@Test
public void readGenericMapMap() {
Document source = Document.create();
source.put("objectMap", Collections.singletonMap("inventory", Collections.singletonMap("glock19", gunAsMap)));
Skynet target = mappingElasticsearchConverter.read(Skynet.class, source);
assertThat(target.getObjectMap()).containsEntry("inventory", Collections.singletonMap("glock19", gun));
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method readGenericListList.
// DATAES-530
@Test
public void readGenericListList() {
Document source = Document.create();
source.put("objectList", Collections.singletonList(Arrays.asList(t800AsMap, gunAsMap)));
Skynet target = mappingElasticsearchConverter.read(Skynet.class, source);
assertThat(target.getObjectList()).containsExactly(Arrays.asList(t800, gun));
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class MappingElasticsearchConverterUnitTests method shouldNotWriteSeqNoPrimaryTermProperty.
// DATAES-799
@Test
void shouldNotWriteSeqNoPrimaryTermProperty() {
EntityWithSeqNoPrimaryTerm entity = new EntityWithSeqNoPrimaryTerm();
entity.seqNoPrimaryTerm = new SeqNoPrimaryTerm(1L, 2L);
Document document = Document.create();
mappingElasticsearchConverter.write(entity, document);
assertThat(document).doesNotContainKey("seqNoPrimaryTerm");
}
Aggregations