Polishing.

Use synchronous API for ES test data setup to avoid threading during the bean container startup.

See #636
This commit is contained in:
Mark Paluch
2022-04-26 11:48:37 +02:00
committed by Greg L. Turnquist
parent 13c0dea55c
commit 83cd9e2d5a
5 changed files with 32 additions and 43 deletions

View File

@@ -17,6 +17,9 @@ package example.springdata.elasticsearch.conference;
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
import lombok.Builder;
import lombok.Data;
import java.util.List;
import org.springframework.data.annotation.Id;
@@ -24,9 +27,6 @@ import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import lombok.Builder;
import lombok.Data;
/**
* @author Artur Konczak
* @author Oliver Gierke
@@ -43,16 +43,4 @@ public class Conference {
private GeoPoint location;
private List<String> keywords;
// do not remove it
public Conference() {}
// do not remove it - work around for lombok generated constructor for all params
public Conference(String id, String name, String date, GeoPoint location, List<String> keywords) {
this.id = id;
this.name = name;
this.date = date;
this.location = location;
this.keywords = keywords;
}
}

View File

@@ -74,7 +74,7 @@ class ElasticsearchOperationsTest {
var query = new CriteriaQuery(
new Criteria("keywords").contains(expectedWord).and(new Criteria("date").greaterThanEqual(expectedDate)));
var result = operations.search(query, Conference.class, IndexCoordinates.of("conference-index"));
var result = operations.search(query, Conference.class);
assertThat(result).hasSize(3);