use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentAdaptersUnitTests method shouldAdaptGetResponseSource.
// DATAES-628, DATAES-848
@Test
public void shouldAdaptGetResponseSource() {
BytesArray source = new BytesArray("{\"field\":\"value\"}");
GetResult getResult = new GetResult("index", "type", "my-id", 1, 2, 42, true, source, Collections.emptyMap(), null);
GetResponse response = new GetResponse(getResult);
Document document = DocumentAdapters.from(response);
assertThat(document.getIndex()).isEqualTo("index");
assertThat(document.hasId()).isTrue();
assertThat(document.getId()).isEqualTo("my-id");
assertThat(document.hasVersion()).isTrue();
assertThat(document.getVersion()).isEqualTo(42);
assertThat(document.get("field")).isEqualTo("value");
assertThat(document.hasSeqNo()).isTrue();
assertThat(document.getSeqNo()).isEqualTo(1);
assertThat(document.hasPrimaryTerm()).isTrue();
assertThat(document.getPrimaryTerm()).isEqualTo(2);
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldReturnContainsValue.
// DATAES-628
@Test
public void shouldReturnContainsValue() {
Document document = Document.create().append("string", "value").append("bool", Arrays.asList(true, true, false)).append("int", 43).append("long", 42L);
assertThat(document.containsValue("value")).isTrue();
assertThat(document.containsValue(43)).isTrue();
assertThat(document.containsValue(44)).isFalse();
assertThat(document.containsValue(Arrays.asList(true, true, false))).isTrue();
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldSetId.
// DATAES-628
@Test
public void shouldSetId() {
Document document = Document.create();
assertThat(document.hasId()).isFalse();
assertThatIllegalStateException().isThrownBy(document::getId);
document.setId("foo");
assertThat(document.getId()).isEqualTo("foo");
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldApplyTransformer.
// DATAES-628
@Test
public void shouldApplyTransformer() {
Document document = Document.create();
document.setId("value");
assertThat(document.transform(Document::getId)).isEqualTo("value");
}
use of org.springframework.data.elasticsearch.core.document.Document in project spring-data-elasticsearch by spring-projects.
the class DocumentUnitTests method shouldSetVersion.
// DATAES-628
@Test
public void shouldSetVersion() {
Document document = Document.create();
assertThat(document.hasVersion()).isFalse();
assertThatIllegalStateException().isThrownBy(document::getVersion);
document.setVersion(14);
assertThat(document.getVersion()).isEqualTo(14);
}
Aggregations