use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldParseDocumentFromJson.
// DATAES-628
@Test
public void shouldParseDocumentFromJson() {
Document document = Document.parse("{\"key\":\"value\"}");
assertThat(document).containsEntry("key", "value");
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldReturnContainsKey.
// DATAES-628
@Test
public void shouldReturnContainsKey() {
Document document = Document.create().append("string", "value").append("bool", true).append("int", 43).append("long", 42L);
assertThat(document.containsKey("string")).isTrue();
assertThat(document.containsKey("not-set")).isFalse();
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldRenderDocumentToJson.
// DATAES-628
@Test
public void shouldRenderDocumentToJson() {
Document document = Document.from(Collections.singletonMap("key", "value"));
assertThat(document.toJson()).isEqualTo("{\"key\":\"value\"}");
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldReturnTypedValueLong.
// DATAES-628
@Test
public void shouldReturnTypedValueLong() {
Document document = Document.create().append("string", "value").append("bool", true).append("int", 43).append("long", 42L);
assertThat(document.getLong("long")).isEqualTo(42);
assertThat(document.getLongOrDefault("not-set", 44)).isEqualTo(44);
assertThat(document.getLongOrDefault("not-set", () -> 44)).isEqualTo(44);
assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> document.getString("long"));
assertThatExceptionOfType(ClassCastException.class).isThrownBy(() -> document.get("long", String.class));
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class ResponseConverter method toAliasData.
public static AliasData toAliasData(AliasMetadata aliasMetaData) {
Document filter = null;
CompressedXContent aliasMetaDataFilter = aliasMetaData.getFilter();
if (aliasMetaDataFilter != null) {
filter = Document.parse(aliasMetaDataFilter.string());
}
return AliasData.of(aliasMetaData.alias(), filter, aliasMetaData.indexRouting(), aliasMetaData.getSearchRouting(), aliasMetaData.writeIndex(), aliasMetaData.isHidden());
}
Aggregations