From e4cddbdd091c363320ba221267631e4dde22e2fd Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Sat, 20 Mar 2021 18:04:12 +0100 Subject: [PATCH] Remove lombok. --- pom.xml | 22 + .../data/elasticsearch/NestedObjectTests.java | 269 ++++-- .../ComposableAnnotationsUnitTest.java | 52 +- ...veElasticsearchClientIntegrationTests.java | 2 - ...eNestedElasticsearchRepositoriesTests.java | 25 +- .../EnableElasticsearchRepositoriesTests.java | 196 +++- ...actElasticsearchTemplateCallbackTests.java | 54 +- .../core/ElasticsearchRestTemplateTests.java | 32 +- .../core/ElasticsearchTemplateTests.java | 837 ++++++++++++++--- .../ElasticsearchTransportTemplateTests.java | 50 +- .../core/EntityOperationsTest.java | 83 +- .../elasticsearch/core/InnerHitsTests.java | 114 ++- .../elasticsearch/core/LogEntityTests.java | 59 +- ...iveElasticsearchTemplateCallbackTests.java | 53 +- ...ElasticsearchTemplateIntegrationTests.java | 266 +++++- ...eactiveElasticsearchTemplateUnitTests.java | 105 ++- .../core/ReactiveIndexOperationsTest.java | 59 +- .../core/RequestFactoryTests.java | 56 +- .../core/SearchAsYouTypeTests.java | 92 +- .../core/SourceFilterIntegrationTests.java | 61 +- ...ElasticsearchTemplateAggregationTests.java | 75 +- ...appingElasticsearchConverterUnitTests.java | 851 +++++++++++++++--- ...archOperationsCallbackIntegrationTest.java | 50 +- .../geo/ElasticsearchTemplateGeoTests.java | 132 ++- .../elasticsearch/core/geo/GeoJsonEntity.java | 261 +++++- .../core/geo/GeoJsonIntegrationTest.java | 76 +- .../index/IndexOperationIntegrationTests.java | 15 +- .../index/MappingBuilderIntegrationTests.java | 637 ++++++++++--- .../core/index/MappingBuilderUnitTests.java | 656 +++++++++++--- .../SimpleElasticsearchDateMappingTests.java | 47 +- ...ntityCustomConversionIntegrationTests.java | 67 +- ...NamingStrategyIntegrationReactiveTest.java | 35 +- .../FieldNamingStrategyIntegrationTest.java | 32 +- ...sticsearchPersistentPropertyUnitTests.java | 65 +- .../ReactiveSearchAfterIntegrationTests.java | 61 +- .../SearchAfterIntegrationTests.java | 62 +- .../query/CriteriaQueryIntegrationTests.java | 85 +- .../DefaultRoutingResolverUnitTest.java | 94 +- .../ElasticsearchOperationsRoutingTests.java | 63 +- ...veElasticsearchOperationsRoutingTests.java | 63 +- .../ImmutableElasticsearchRepository.java | 24 - ...ImmutableElasticsearchRepositoryTests.java | 14 +- .../immutable/ImmutableEntity.java | 38 - .../repositories/cdi/CdiRepositoryTests.java | 264 ++++-- .../ComplexCustomMethodRepositoryTests.java | 37 +- ...stomMethodRepositoryManualWiringTests.java | 36 +- .../CustomMethodRepositoryBaseTests.java | 96 +- .../geo/SpringDataGeoRepositoryTests.java | 116 ++- .../nestedobject/InnerObjectTests.java | 73 +- .../synonym/SynonymRepositoryTests.java | 35 +- .../UUIDElasticsearchRepositoryTests.java | 147 ++- ...asticsearchRepositoriesRegistrarTests.java | 42 +- .../ElasticsearchQueryMethodUnitTests.java | 36 +- .../ElasticsearchStringQueryUnitTests.java | 97 +- ...tiveElasticsearchQueryMethodUnitTests.java | 96 +- ...tiveElasticsearchStringQueryUnitTests.java | 96 +- .../query/keywords/QueryKeywordsTests.java | 117 ++- ...asticsearchRepositoryIntegrationTests.java | 121 ++- ...eReactiveElasticsearchRepositoryTests.java | 273 +++--- .../lombok/999999/lombok-999999.jar | Bin 0 -> 425 bytes .../lombok/999999/lombok-999999.jar.md5 | 1 + .../lombok/999999/lombok-999999.jar.sha1 | 1 + .../lombok/999999/lombok-999999.pom | 8 + .../lombok/999999/lombok-999999.pom.md5 | 1 + .../lombok/999999/lombok-999999.pom.sha1 | 1 + .../projectlombok/lombok/maven-metadata.xml | 12 + .../lombok/maven-metadata.xml.md5 | 1 + .../lombok/maven-metadata.xml.sha1 | 1 + 68 files changed, 6005 insertions(+), 1693 deletions(-) delete mode 100644 src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepository.java delete mode 100644 src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableEntity.java create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.md5 create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.sha1 create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.md5 create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.sha1 create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.md5 create mode 100644 src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.sha1 diff --git a/pom.xml b/pom.xml index 191786d37..4e95887e5 100644 --- a/pom.xml +++ b/pom.xml @@ -226,6 +226,22 @@ test + + + org.projectlombok + lombok + 999999 + test + + org.apache.openwebbeans.test cditest-owb @@ -435,6 +451,12 @@ spring-libs-snapshot https://repo.spring.io/libs-snapshot + + + local-maven-repo + file:///${project.basedir}/src/test/resources/local-maven-repo + + diff --git a/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java b/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java index 905510aad..6cc24ff90 100644 --- a/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/NestedObjectTests.java @@ -19,10 +19,6 @@ import static org.elasticsearch.index.query.QueryBuilders.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.Data; -import lombok.Getter; -import lombok.Setter; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -53,6 +49,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -384,82 +381,238 @@ public void shouldIndexAndSearchMapAsNestedType() { assertThat(books.getSearchHit(0).getContent().getId()).isEqualTo(book2.getId()); } - @Setter - @Getter @Document(indexName = "test-index-book-nested-objects", replicas = 0, refreshInterval = "-1") static class Book { - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - @Data @Document(indexName = "test-index-person", replicas = 0, refreshInterval = "-1") static class Person { - - @Id private String id; - - private String name; - - @Field(type = FieldType.Nested) private List car; - - @Field(type = FieldType.Nested, includeInParent = true) private List books; + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Nested) private List car; + @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List books; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public List getCar() { + return car; + } + + public void setCar(@Nullable List car) { + this.car = car; + } + + @Nullable + public List getBooks() { + return books; + } + + public void setBooks(@Nullable List books) { + this.books = books; + } } - @Data static class Car { - - private String name; - private String model; + @Nullable private String name; + @Nullable private String model; + + @Nullable + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Nullable + public String getModel() { + return model; + } + + public void setModel(String model) { + this.model = model; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - */ - @Data @Document(indexName = "test-index-person-multiple-level-nested", replicas = 0, refreshInterval = "-1") static class PersonMultipleLevelNested { - - @Id private String id; - - private String name; - - @Field(type = FieldType.Nested) private List girlFriends; - - @Field(type = FieldType.Nested) private List cars; - - @Field(type = FieldType.Nested, includeInParent = true) private List bestCars; + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Nested) private List girlFriends; + @Nullable @Field(type = FieldType.Nested) private List cars; + @Nullable @Field(type = FieldType.Nested, includeInParent = true) private List bestCars; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public List getGirlFriends() { + return girlFriends; + } + + public void setGirlFriends(@Nullable List girlFriends) { + this.girlFriends = girlFriends; + } + + @Nullable + public List getCars() { + return cars; + } + + public void setCars(@Nullable List cars) { + this.cars = cars; + } + + @Nullable + public List getBestCars() { + return bestCars; + } + + public void setBestCars(@Nullable List bestCars) { + this.bestCars = bestCars; + } } - /** - * @author Mohsin Husen - */ - @Data static class GirlFriend { - - private String name; - - private String type; - - @Field(type = FieldType.Nested) private List cars; + @Nullable private String name; + @Nullable private String type; + @Nullable @Field(type = FieldType.Nested) private List cars; + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public List getCars() { + return cars; + } + + public void setCars(@Nullable List cars) { + this.cars = cars; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - */ - @Data static class Author { - - private String id; - private String name; + @Nullable private String id; + @Nullable private String name; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java b/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java index 645dfdeea..dc468eb90 100644 --- a/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/annotations/ComposableAnnotationsUnitTest.java @@ -18,10 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.skyscreamer.jsonassert.JSONAssert.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; @@ -41,6 +37,7 @@ import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchMappingContext; import org.springframework.data.elasticsearch.core.mapping.SimpleElasticsearchPersistentEntity; +import org.springframework.lang.Nullable; /** * @author Peter-Josef Meisch @@ -144,14 +141,47 @@ void shouldUseComposedFieldAnnotationsInMappingBuilder() throws JSONException { public @interface TextKeywordField { } - @Data - @NoArgsConstructor - @AllArgsConstructor @DocumentNoCreate(indexName = "test-no-create") static class ComposedAnnotationEntity { - @Id private String id; - @NullValueField(name = "null-value") private String nullValue; - @LocalDateField private LocalDate theDate; - @TextKeywordField private String multiField; + @Nullable @Id private String id; + @Nullable @NullValueField(name = "null-value") private String nullValue; + @Nullable @LocalDateField private LocalDate theDate; + @Nullable @TextKeywordField private String multiField; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getNullValue() { + return nullValue; + } + + public void setNullValue(@Nullable String nullValue) { + this.nullValue = nullValue; + } + + @Nullable + public LocalDate getTheDate() { + return theDate; + } + + public void setTheDate(@Nullable LocalDate theDate) { + this.theDate = theDate; + } + + @Nullable + public String getMultiField() { + return multiField; + } + + public void setMultiField(@Nullable String multiField) { + this.multiField = multiField; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java index d4aafe4e6..eea2e77a8 100644 --- a/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/client/reactive/ReactiveElasticsearchClientIntegrationTests.java @@ -17,7 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.SneakyThrows; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -1112,7 +1111,6 @@ private IndexRequest indexRequest() { .create(true); } - @SneakyThrows private String doIndex(Map source, String index) { return operations.save(source, IndexCoordinates.of(index)).block().get("id").toString(); } diff --git a/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java b/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java index 098e9d0d5..47a7d73a9 100644 --- a/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/config/nested/EnableNestedElasticsearchRepositoriesTests.java @@ -18,9 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Builder; -import lombok.Data; - import java.lang.Double; import java.lang.Long; @@ -41,6 +38,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.repository.Repository; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -75,20 +73,17 @@ public void hasNestedRepository() { assertThat(nestedRepository).isNotNull(); } - @Data - @Builder @Document(indexName = "test-index-sample-config-nested", replicas = 0, refreshInterval = "-1") static class SampleEntity { - - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @ScriptedField private Double scriptedRate; - private boolean available; - private String highlightedMessage; - private GeoPoint location; - @Version private Long version; + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Double scriptedRate; + @Nullable private boolean available; + @Nullable private String highlightedMessage; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; } interface SampleRepository extends Repository {} diff --git a/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java b/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java index 8e167a6ac..c089210c7 100644 --- a/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/config/notnested/EnableElasticsearchRepositoriesTests.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Data; - import java.lang.Double; import java.lang.Long; import java.util.UUID; @@ -122,33 +120,187 @@ public void hasNotNestedRepository() { assertThat(nestedRepository).isNull(); } - @Data @Document(indexName = "test-index-sample-config-not-nested", replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Double scriptedRate; + @Nullable private boolean available; + @Nullable private String highlightedMessage; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Double getScriptedRate() { + return scriptedRate; + } + + public void setScriptedRate(@Nullable java.lang.Double scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public String getHighlightedMessage() { + return highlightedMessage; + } + + public void setHighlightedMessage(@Nullable String highlightedMessage) { + this.highlightedMessage = highlightedMessage; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @ScriptedField private Double scriptedRate; - private boolean available; - private String highlightedMessage; - private GeoPoint location; - @Version private Long version; + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-uuid-keyed-config-not-nested", replicas = 0, refreshInterval = "-1") static class SampleEntityUUIDKeyed { + @Nullable @Id private UUID id; + @Nullable private String type; + @Nullable @Field(type = FieldType.Text, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Long scriptedRate; + @Nullable private boolean available; + @Nullable private String highlightedMessage; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + @Nullable + public UUID getId() { + return id; + } + + public void setId(@Nullable UUID id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Long getScriptedRate() { + return scriptedRate; + } + + public void setScriptedRate(@Nullable java.lang.Long scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public String getHighlightedMessage() { + return highlightedMessage; + } + + public void setHighlightedMessage(@Nullable String highlightedMessage) { + this.highlightedMessage = highlightedMessage; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } - @Id private UUID id; - private String type; - @Field(type = FieldType.Text, fielddata = true) private String message; - private int rate; - @ScriptedField private Long scriptedRate; - private boolean available; - private String highlightedMessage; - private GeoPoint location; - @Version private Long version; + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java b/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java index a4ea0314b..0131fb45d 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/AbstractElasticsearchTemplateCallbackTests.java @@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; @@ -443,13 +439,53 @@ void saveAllShouldInvokeBeforeConvertCallbacks() { assertThat(iterator.next().firstname).isEqualTo("before-convert"); } - @Data - @AllArgsConstructor - @NoArgsConstructor static class Person { + @Nullable @Id String id; + @Nullable String firstname; + + public Person(@Nullable String id, @Nullable String firstname) { + this.id = id; + this.firstname = firstname; + } + + public Person() { + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getFirstname() { + return firstname; + } + + public void setFirstname(@Nullable String firstname) { + this.firstname = firstname; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - @Id String id; - String firstname; + Person person = (Person) o; + + if (id != null ? !id.equals(person.id) : person.id != null) return false; + return firstname != null ? firstname.equals(person.firstname) : person.firstname == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (firstname != null ? firstname.hashCode() : 0); + return result; + } } static class ValueCapturingEntityCallback { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java index 513629edc..8e8ae9701 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchRestTemplateTests.java @@ -21,10 +21,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.Builder; -import lombok.Data; -import lombok.val; - import java.lang.Object; import java.time.Duration; import java.util.Collections; @@ -37,6 +33,7 @@ import org.elasticsearch.action.update.UpdateRequest; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.index.reindex.UpdateByQueryRequest; +import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.json.JSONException; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -49,6 +46,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -81,13 +79,29 @@ public void shouldThrowExceptionIfDocumentDoesNotExistWhileDoingPartialUpdate() .isInstanceOf(UncategorizedElasticsearchException.class); } - @Data - @Builder @Document(indexName = "test-index-sample-core-rest-template", replicas = 0, refreshInterval = "-1") static class SampleEntity { - - @Id private String id; + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } } @Test // DATAES-768 @@ -122,7 +136,7 @@ void shouldUseAllOptionsFromUpdateQuery() { assertThat(request.retryOnConflict()).isEqualTo(7); assertThat(request.timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test")); assertThat(request.waitForActiveShards()).isEqualTo(ActiveShardCount.ALL); - val fetchSourceContext = request.fetchSource(); + FetchSourceContext fetchSourceContext = request.fetchSource(); assertThat(fetchSourceContext).isNotNull(); assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl"); assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl"); diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java index 68fd8085b..b05df9b71 100755 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTemplateTests.java @@ -23,12 +23,6 @@ import static org.springframework.data.elasticsearch.utils.IdGenerator.*; import static org.springframework.data.elasticsearch.utils.IndexBuilder.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - import java.lang.Double; import java.lang.Integer; import java.lang.Long; @@ -65,8 +59,6 @@ import org.elasticsearch.script.ScriptType; import org.elasticsearch.search.fetch.subphase.FetchSourceContext; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; -import org.elasticsearch.search.rescore.QueryRescoreMode; -import org.elasticsearch.search.rescore.QueryRescorerBuilder; import org.elasticsearch.search.sort.FieldSortBuilder; import org.elasticsearch.search.sort.SortBuilders; import org.elasticsearch.search.sort.SortOrder; @@ -1989,8 +1981,11 @@ public void shouldIndexGteEntityWithVersionType() { // given String documentId = nextIdAsString(); - GTEVersionEntity entity = GTEVersionEntity.builder().id(documentId).name("FooBar") - .version(System.currentTimeMillis()).build(); + + GTEVersionEntity entity = new GTEVersionEntity(); + entity.setId(documentId); + entity.setName("FooBar"); + entity.setVersion(System.currentTimeMillis()); IndexQueryBuilder indexQueryBuilder = new IndexQueryBuilder().withId(documentId).withVersion(entity.getVersion()) .withObject(entity); @@ -3072,7 +3067,10 @@ public void shouldIncludeDefaultsOnGetIndexSettings() { @Test // DATAES-714 void shouldReturnSortFieldsInSearchHits() { IndexCoordinates index = IndexCoordinates.of("test-index-searchhits-entity-template"); - SearchHitsEntity entity = SearchHitsEntity.builder().id("1").number(1000L).keyword("thousands").build(); + SearchHitsEntity entity = new SearchHitsEntity(); + entity.setId("1"); + entity.setNumber(1000L); + entity.setKeyword("thousands"); IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build(); operations.index(indexQuery, index); operations.indexOps(index).refresh(); @@ -3107,10 +3105,9 @@ void shouldReturnSortFieldsInSearchHits() { @Test // DATAES-715 void shouldReturnHighlightFieldsInSearchHit() { IndexCoordinates index = IndexCoordinates.of("test-index-highlight-entity-template"); - HighlightEntity entity = HighlightEntity.builder().id("1") - .message("This message is a long text which contains the word to search for " - + "in two places, the first being near the beginning and the second near the end of the message") - .build(); + HighlightEntity entity = new HighlightEntity("1", + "This message is a long text which contains the word to search for " + + "in two places, the first being near the beginning and the second near the end of the message"); IndexQuery indexQuery = new IndexQueryBuilder().withId(entity.getId()).withObject(entity).build(); operations.index(indexQuery, index); operations.indexOps(index).refresh(); @@ -3140,16 +3137,14 @@ void shouldRunRescoreQueryInSearchQuery() { SampleEntity entity = SampleEntity.builder() // .id("1") // .message("some message") // - .rate(java.lang.Integer.MAX_VALUE) - .version(System.currentTimeMillis()) // + .rate(java.lang.Integer.MAX_VALUE).version(System.currentTimeMillis()) // .build(); // high score from rescore query SampleEntity entity2 = SampleEntity.builder() // .id("2") // .message("nothing") // - .rate(1) - .version(System.currentTimeMillis()) // + .rate(1).version(System.currentTimeMillis()) // .build(); List indexQueries = getIndexQueries(Arrays.asList(entity, entity2)); @@ -3158,26 +3153,15 @@ void shouldRunRescoreQueryInSearchQuery() { indexOperations.refresh(); NativeSearchQuery query = new NativeSearchQueryBuilder() // - .withQuery( - boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) // - .withRescorerQuery(new RescorerQuery( - new NativeSearchQueryBuilder().withQuery( - QueryBuilders.functionScoreQuery( - new FunctionScoreQueryBuilder.FilterFunctionBuilder[]{ - new FilterFunctionBuilder( - new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5) - .setWeight(1f)), - new FilterFunctionBuilder( - new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5) - .setWeight(100f))} - ) - .scoreMode(FunctionScoreQuery.ScoreMode.SUM) - .maxBoost(80f) - .boostMode(CombineFunction.REPLACE) - ).build() - ) - .withScoreMode(ScoreMode.Max) - .withWindowSize(100)) + .withQuery(boolQuery().filter(existsQuery("rate")).should(termQuery("message", "message"))) // + .withRescorerQuery( + new RescorerQuery(new NativeSearchQueryBuilder().withQuery(QueryBuilders + .functionScoreQuery(new FunctionScoreQueryBuilder.FilterFunctionBuilder[] { + new FilterFunctionBuilder(new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(1f)), + new FilterFunctionBuilder( + new GaussDecayFunctionBuilder("rate", 0, 10, null, 0.5).setWeight(100f)) }) + .scoreMode(FunctionScoreQuery.ScoreMode.SUM).maxBoost(80f).boostMode(CombineFunction.REPLACE)).build()) + .withScoreMode(ScoreMode.Max).withWindowSize(100)) .build(); SearchHits searchHits = operations.search(query, SampleEntity.class, index); @@ -3187,12 +3171,12 @@ void shouldRunRescoreQueryInSearchQuery() { SearchHit searchHit = searchHits.getSearchHit(0); assertThat(searchHit.getContent().getMessage()).isEqualTo("nothing"); - //score capped to 80 + // score capped to 80 assertThat(searchHit.getScore()).isEqualTo(80f); } @Test - // DATAES-738 + // DATAES-738 void shouldSaveEntityWithIndexCoordinates() { String id = "42"; SampleEntity entity = new SampleEntity(); @@ -3766,130 +3750,560 @@ void shouldReturnExplanationWhenRequested() { assertThat(explanation).isNotNull(); } - @Data - @NoArgsConstructor - @AllArgsConstructor - @EqualsAndHashCode(exclude = "score") - @Builder @Document(indexName = INDEX_NAME_SAMPLE_ENTITY, replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Double scriptedRate; + @Nullable private boolean available; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + static Builder builder() { + return new Builder(); + } + + static class Builder { + + @Nullable private String id; + @Nullable private String type; + @Nullable private String message; + @Nullable private Long version; + @Nullable private int rate; + @Nullable private GeoPoint location; + + public Builder id(String id) { + this.id = id; + return this; + } + + public Builder type(String type) { + this.type = type; + return this; + } + + public Builder message(String message) { + this.message = message; + return this; + } + + public Builder version(Long version) { + this.version = version; + return this; + } + + public Builder rate(int rate) { + this.rate = rate; + return this; + } + + public Builder location(GeoPoint location) { + this.location = location; + return this; + } + + public SampleEntity build() { + SampleEntity sampleEntity = new SampleEntity(); + sampleEntity.setId(id); + sampleEntity.setType(type); + sampleEntity.setMessage(message); + sampleEntity.setRate(rate); + sampleEntity.setVersion(version); + sampleEntity.setLocation(location); + return sampleEntity; + } + } + + public SampleEntity() {} + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Double getScriptedRate() { + return scriptedRate; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @ScriptedField private Double scriptedRate; - private boolean available; - private GeoPoint location; - @Version private Long version; + public void setScriptedRate(@Nullable java.lang.Double scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + SampleEntity that = (SampleEntity) o; + + if (rate != that.rate) + return false; + if (available != that.available) + return false; + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + if (message != null ? !message.equals(that.message) : that.message != null) + return false; + if (scriptedRate != null ? !scriptedRate.equals(that.scriptedRate) : that.scriptedRate != null) + return false; + if (location != null ? !location.equals(that.location) : that.location != null) + return false; + return version != null ? version.equals(that.version) : that.version == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (message != null ? message.hashCode() : 0); + result = 31 * result + rate; + result = 31 * result + (scriptedRate != null ? scriptedRate.hashCode() : 0); + result = 31 * result + (available ? 1 : 0); + result = 31 * result + (location != null ? location.hashCode() : 0); + result = 31 * result + (version != null ? version.hashCode() : 0); + return result; + } } - /** - * @author Gad Akuka - * @author Rizwan Idrees - * @author Mohsin Husen - */ - @Data - @AllArgsConstructor - @Builder @Document(indexName = "test-index-uuid-keyed-core-template", replicas = 0, refreshInterval = "-1") private static class SampleEntityUUIDKeyed { + @Nullable @Id private UUID id; + @Nullable private String type; + @Nullable @Field(type = FieldType.Text, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Long scriptedRate; + @Nullable private boolean available; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + @Nullable + public UUID getId() { + return id; + } + + public void setId(@Nullable UUID id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } - @Id private UUID id; - private String type; - @Field(type = FieldType.Text, fielddata = true) private String message; - private int rate; - @ScriptedField private Long scriptedRate; - private boolean available; - private GeoPoint location; - @Version private Long version; + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Long getScriptedRate() { + return scriptedRate; + } + public void setScriptedRate(@Nullable java.lang.Long scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data - @Builder - @AllArgsConstructor - @NoArgsConstructor @Document(indexName = "test-index-book-core-template", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + public Book(@Nullable String id, @Nullable String name, @Nullable Author author, + @Nullable Map> buckets, @Nullable String description) { + this.id = id; + this.name = name; + this.author = author; + this.buckets = buckets; + this.description = description; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } + + static Builder builder() { + return new Builder(); + } + + static class Builder { + @Nullable private String id; + @Nullable private String name; + @Nullable private Author author; + @Nullable private Map> buckets = new HashMap<>(); + @Nullable private String description; + + public Builder id(@Nullable String id) { + this.id = id; + return this; + } + + public Builder name(@Nullable String name) { + this.name = name; + return this; + } + + public Builder author(@Nullable Author author) { + this.author = author; + return this; + } + + public Builder buckets(@Nullable Map> buckets) { + this.buckets = buckets; + return this; + } + + public Builder description(@Nullable String description) { + this.description = description; + return this; + } + + Book build() { + return new Book(id, name, author, buckets, description); + } + } } - @Data static class Author { - private String id; - private String name; + @Nullable private String id; + @Nullable private String name; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } } - @Data - @Builder - @AllArgsConstructor - @NoArgsConstructor @Document(indexName = "test-index-version-core-template", replicas = 0, refreshInterval = "-1", versionType = VersionType.EXTERNAL_GTE) private static class GTEVersionEntity { + @Nullable @Version private Long version; + @Nullable @Id private String id; + @Nullable private String name; + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } + + @Nullable + public String getId() { + return id; + } - @Version private Long version; + public void setId(@Nullable String id) { + this.id = id; + } - @Id private String id; + @Nullable + public String getName() { + return name; + } - private String name; + public void setName(@Nullable String name) { + this.name = name; + } } - @Data @Document(indexName = "test-index-hetro1-core-template", replicas = 0) static class HetroEntity1 { - - @Id private String id; - private String firstName; - @Version private Long version; + @Nullable @Id private String id; + @Nullable private String firstName; + @Nullable @Version private Long version; HetroEntity1(String id, String firstName) { this.id = id; this.firstName = firstName; this.version = System.currentTimeMillis(); } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getFirstName() { + return firstName; + } + + public void setFirstName(@Nullable String firstName) { + this.firstName = firstName; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-hetro2-core-template", replicas = 0) static class HetroEntity2 { - @Id private String id; - private String lastName; - @Version private Long version; + @Nullable @Id private String id; + @Nullable private String lastName; + @Nullable @Version private Long version; HetroEntity2(String id, String lastName) { this.id = id; this.lastName = lastName; this.version = System.currentTimeMillis(); } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getLastName() { + return lastName; + } + + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-server-configuration", useServerConfiguration = true, shards = 10, replicas = 10, refreshInterval = "-1") private static class UseServerConfigurationEntity { - @Id private String id; - private String val; + @Nullable @Id private String id; + @Nullable private String val; + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getVal() { + return val; + } + + public void setVal(@Nullable String val) { + this.val = val; + } } - @Data @Document(indexName = "test-index-sample-mapping", replicas = 0, refreshInterval = "-1") static class SampleMappingEntity { - @Id private String id; + @Nullable @Id private String id; + @Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message; - @Field(type = Text, index = false, store = true, analyzer = "standard") private String message; + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } static class NestedEntity { @@ -3906,58 +4320,211 @@ public void setSomeField(String someField) { } } - @Data - @AllArgsConstructor - @Builder @Document(indexName = "test-index-searchhits-entity-template") static class SearchHitsEntity { - @Id private String id; - @Field(type = FieldType.Long) Long number; - @Field(type = FieldType.Keyword) String keyword; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Long) Long number; + @Nullable @Field(type = FieldType.Keyword) String keyword; + + public SearchHitsEntity() {} + + public SearchHitsEntity(@Nullable String id, @Nullable java.lang.Long number, @Nullable String keyword) { + this.id = id; + this.number = number; + this.keyword = keyword; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public java.lang.Long getNumber() { + return number; + } + + public void setNumber(@Nullable java.lang.Long number) { + this.number = number; + } + + @Nullable + public String getKeyword() { + return keyword; + } + + public void setKeyword(@Nullable String keyword) { + this.keyword = keyword; + } } - @Data - @AllArgsConstructor - @Builder @Document(indexName = "test-index-highlight-entity-template") static class HighlightEntity { - @Id private String id; - private String message; + @Nullable @Id private String id; + @Nullable private String message; + + public HighlightEntity(@Nullable String id, @Nullable String message) { + this.id = id; + this.message = message; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } } - @Data @Document(indexName = "test-index-optimistic-entity-template") static class OptimisticEntity { - @Id private String id; - private String message; - private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable @Id private String id; + @Nullable private String message; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } - @Data @Document(indexName = "test-index-optimistic-and-versioned-entity-template") static class OptimisticAndVersionedEntity { - @Id private String id; - private String message; - private SeqNoPrimaryTerm seqNoPrimaryTerm; - @Version private Long version; + @Nullable @Id private String id; + @Nullable private String message; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-versioned-entity-template") static class VersionedEntity { - @Id private String id; - @Version private Long version; + @Nullable @Id private String id; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = INDEX_NAME_JOIN_SAMPLE_ENTITY) static class SampleJoinEntity { - @Id @Field(type = Keyword) private String uuid; - @JoinTypeRelations(relations = { + @Nullable @Id @Field(type = Keyword) private String uuid; + @Nullable @JoinTypeRelations(relations = { @JoinTypeRelation(parent = "question", children = { "answer" }) }) private JoinField myJoinField; - @Field(type = Text) private String text; + @Nullable @Field(type = Text) private String text; + + @Nullable + public String getUuid() { + return uuid; + } + + public void setUuid(@Nullable String uuid) { + this.uuid = uuid; + } + + @Nullable + public JoinField getMyJoinField() { + return myJoinField; + } + + public void setMyJoinField(@Nullable JoinField myJoinField) { + this.myJoinField = myJoinField; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java index 864d58fe1..485e00575 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchTransportTemplateTests.java @@ -21,9 +21,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.Data; -import lombok.val; - import java.lang.Object; import java.time.Duration; import java.util.Collections; @@ -55,6 +52,7 @@ import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchTemplateConfiguration; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -108,18 +106,18 @@ void shouldUseAllOptionsFromUpdateQuery() { doc.put("message", "test"); org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document .from(doc); - UpdateQuery updateQuery = UpdateQuery.builder("1") // - .withDocument(document) // - .withIfSeqNo(42) // - .withIfPrimaryTerm(13) // - .withScript("script")// - .withLang("lang") // - .withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) // - .withRetryOnConflict(7) // - .withTimeout("4711s") // - .withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) // - .withFetchSourceExcludes(Collections.singletonList("excl")) // - .build(); + UpdateQuery updateQuery = UpdateQuery.builder("1") // + .withDocument(document) // + .withIfSeqNo(42) // + .withIfPrimaryTerm(13) // + .withScript("script")// + .withLang("lang") // + .withRefreshPolicy(RefreshPolicy.WAIT_UNTIL) // + .withRetryOnConflict(7) // + .withTimeout("4711s") // + .withWaitForActiveShards("all").withFetchSourceIncludes(Collections.singletonList("incl")) // + .withFetchSourceExcludes(Collections.singletonList("excl")) // + .build(); UpdateRequestBuilder request = getRequestFactory().updateRequestBuilderFor(client, updateQuery, IndexCoordinates.of("index")); @@ -133,7 +131,7 @@ void shouldUseAllOptionsFromUpdateQuery() { assertThat(request.request().retryOnConflict()).isEqualTo(7); assertThat(request.request().timeout()).isEqualByComparingTo(TimeValue.parseTimeValue("4711s", "test")); assertThat(request.request().waitForActiveShards()).isEqualTo(ActiveShardCount.ALL); - FetchSourceContext fetchSourceContext = request.request().fetchSource(); + FetchSourceContext fetchSourceContext = request.request().fetchSource(); assertThat(fetchSourceContext).isNotNull(); assertThat(fetchSourceContext.includes()).containsExactlyInAnyOrder("incl"); assertThat(fetchSourceContext.excludes()).containsExactlyInAnyOrder("excl"); @@ -197,11 +195,25 @@ void shouldUseAllOptionsFromUpdateByQuery() throws JSONException { assertThat(request.request().getScript().getType()).isEqualTo(org.elasticsearch.script.ScriptType.STORED); } - @Data @Document(indexName = "test-index-sample-core-transport-template", replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; + public void setType(String type) { + this.type = type; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java b/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java index 0f0fa40d5..cf266ab92 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/EntityOperationsTest.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Arrays; import java.util.HashSet; @@ -66,7 +61,9 @@ static void setUpAll() { @DisplayName("should return routing from DefaultRoutingAccessor") void shouldReturnRoutingFromDefaultRoutingAccessor() { - EntityWithRouting entity = EntityWithRouting.builder().id("42").routing("theRoute").build(); + EntityWithRouting entity = new EntityWithRouting(); + entity.setId("42"); + entity.setRouting("theRoute"); EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext)); @@ -79,8 +76,9 @@ void shouldReturnRoutingFromDefaultRoutingAccessor() { @DisplayName("should return routing from JoinField when routing value is null") void shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull() { - EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42") - .joinField(new JoinField<>("foo", "foo-routing")).build(); + EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField(); + entity.setId("42"); + entity.setJoinField(new JoinField<>("foo", "foo-routing")); EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext)); @@ -93,8 +91,10 @@ void shouldReturnRoutingFromJoinFieldWhenRoutingValueIsNull() { @Test // #1218 @DisplayName("should return routing from routing when JoinField is set") void shouldReturnRoutingFromRoutingWhenJoinFieldIsSet() { - EntityWithRoutingAndJoinField entity = EntityWithRoutingAndJoinField.builder().id("42").routing("theRoute") - .joinField(new JoinField<>("foo", "foo-routing")).build(); + EntityWithRoutingAndJoinField entity = new EntityWithRoutingAndJoinField(); + entity.setId("42"); + entity.setRouting("theRoute"); + entity.setJoinField(new JoinField<>("foo", "foo-routing")); EntityOperations.AdaptibleEntity adaptibleEntity = entityOperations.forEntity(entity, conversionService, new DefaultRoutingResolver(mappingContext)); @@ -104,26 +104,63 @@ void shouldReturnRoutingFromRoutingWhenJoinFieldIsSet() { assertThat(routing).isEqualTo("theRoute"); } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "entity-operations-test") @Routing("routing") static class EntityWithRouting { - @Id private String id; - private String routing; + @Nullable @Id private String id; + @Nullable private String routing; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getRouting() { + return routing; + } + + public void setRouting(@Nullable String routing) { + this.routing = routing; + } } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "entity-operations-test") @Routing("routing") static class EntityWithRoutingAndJoinField { - @Id private String id; - private String routing; - private JoinField joinField; + @Nullable @Id private String id; + @Nullable private String routing; + @Nullable private JoinField joinField; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getRouting() { + return routing; + } + + public void setRouting(@Nullable String routing) { + this.routing = routing; + } + + @Nullable + public JoinField getJoinField() { + return joinField; + } + + public void setJoinField(@Nullable JoinField joinField) { + this.joinField = joinField; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java b/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java index e4406b1e5..9bd1a1706 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/InnerHitsTests.java @@ -18,10 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.RequiredArgsConstructor; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -132,39 +128,103 @@ void shouldReturnInnerHits() { softly.assertAll(); } - @Data - @AllArgsConstructor - @RequiredArgsConstructor @Document(indexName = INDEX_NAME) static class City { - - @Id private String name; - + @Nullable @Id private String name; // NOTE: using a custom names here to cover property name matching - @Field(name = "hou-ses", type = FieldType.Nested) private Collection houses = new ArrayList<>(); + @Nullable @Field(name = "hou-ses", type = FieldType.Nested) private Collection houses = new ArrayList<>(); + + public City(@Nullable String name, @Nullable Collection houses) { + this.name = name; + this.houses = houses; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Collection getHouses() { + return houses; + } + + public void setHouses(@Nullable Collection houses) { + this.houses = houses; + } } - @Data - @AllArgsConstructor - @RequiredArgsConstructor static class House { - - @Field(type = FieldType.Text) private String street; - - @Field(type = FieldType.Text) private String streetNumber; - + @Nullable @Field(type = FieldType.Text) private String street; + @Nullable @Field(type = FieldType.Text) private String streetNumber; // NOTE: using a custom names here to cover property name matching - @Field(name = "in-habi-tants", type = FieldType.Nested) private List inhabitants = new ArrayList<>(); + @Nullable @Field(name = "in-habi-tants", + type = FieldType.Nested) private List inhabitants = new ArrayList<>(); + + public House(@Nullable String street, @Nullable String streetNumber, @Nullable List inhabitants) { + this.street = street; + this.streetNumber = streetNumber; + this.inhabitants = inhabitants; + } + + @Nullable + public String getStreet() { + return street; + } + + public void setStreet(@Nullable String street) { + this.street = street; + } + + @Nullable + public String getStreetNumber() { + return streetNumber; + } + + public void setStreetNumber(@Nullable String streetNumber) { + this.streetNumber = streetNumber; + } + + @Nullable + public List getInhabitants() { + return inhabitants; + } + + public void setInhabitants(@Nullable List inhabitants) { + this.inhabitants = inhabitants; + } } - @Data - @AllArgsConstructor - @RequiredArgsConstructor static class Inhabitant { // NOTE: using a custom names here to cover property name matching - - @Field(name = "first-name", type = FieldType.Text) private String firstName; - - @Field(name = "last-name", type = FieldType.Text) private String lastName; + @Nullable @Field(name = "first-name", type = FieldType.Text) private String firstName; + @Nullable @Field(name = "last-name", type = FieldType.Text) private String lastName; + + public Inhabitant(@Nullable String firstName, @Nullable String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + @Nullable + public String getFirstName() { + return firstName; + } + + public void setFirstName(@Nullable String firstName) { + this.firstName = firstName; + } + + @Nullable + public String getLastName() { + return lastName; + } + + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java b/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java index fb2d5be77..a54ca91ea 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/LogEntityTests.java @@ -19,8 +19,6 @@ import static org.elasticsearch.index.query.QueryBuilders.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Data; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -44,6 +42,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -133,28 +132,66 @@ public void shouldReturnLogsForGivenIPRanges() { /** * Simple type to test facets */ - @Data @Document(indexName = "test-index-log-core", replicas = 0, refreshInterval = "-1") static class LogEntity { private static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); - @Id private String id; - - private String action; + @Nullable @Id private String id; + @Nullable private String action; + @Nullable private long sequenceCode; + @Nullable @Field(type = Ip) private String ip; + @Nullable @Field(type = Date, format = DateFormat.date_time) private java.util.Date date; - private long sequenceCode; + private LogEntity() {} - @Field(type = Ip) private String ip; + public LogEntity(String id) { + this.id = id; + } - @Field(type = Date, format = DateFormat.date_time) private java.util.Date date; + public static SimpleDateFormat getFormat() { + return format; + } - private LogEntity() {} + public String getId() { + return id; + } - public LogEntity(String id) { + public void setId(String id) { this.id = id; } + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public long getSequenceCode() { + return sequenceCode; + } + + public void setSequenceCode(long sequenceCode) { + this.sequenceCode = sequenceCode; + } + + public String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + public java.util.Date getDate() { + return date; + } + + public void setDate(java.util.Date date) { + this.date = date; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java index bfff6f2f6..aaeb3bdd8 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateCallbackTests.java @@ -18,9 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import reactor.core.publisher.Flux; @@ -378,13 +375,53 @@ void saveAllShouldInvokeBeforeConvertCallbacks() { assertThat(saved.get(1).firstname).isEqualTo("before-convert"); } - @Data - @AllArgsConstructor - @NoArgsConstructor static class Person { + @Nullable @Id String id; + @Nullable String firstname; - @Id String id; - String firstname; + public Person() { + } + + public Person(@Nullable String id, @Nullable String firstname) { + this.id = id; + this.firstname = firstname; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getFirstname() { + return firstname; + } + + public void setFirstname(@Nullable String firstname) { + this.firstname = firstname; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Person person = (Person) o; + + if (id != null ? !id.equals(person.id) : person.id != null) return false; + return firstname != null ? firstname.equals(person.firstname) : person.firstname == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (firstname != null ? firstname.hashCode() : 0); + return result; + } } static class ValueCapturingEntityCallback { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java index ec8c25153..45e580f46 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateIntegrationTests.java @@ -20,11 +20,6 @@ import static org.elasticsearch.index.query.QueryBuilders.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -81,6 +76,7 @@ import org.springframework.data.elasticsearch.core.query.*; import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; /** @@ -179,7 +175,8 @@ public void insertWithIdShouldWork() { @Test // DATAES-504 public void insertWithAutogeneratedIdShouldUpdateEntityId() { - SampleEntity sampleEntity = SampleEntity.builder().message("wohoo").build(); + SampleEntity sampleEntity = new SampleEntity(); + sampleEntity.setMessage("wohoo"); template.save(sampleEntity) // .map(SampleEntity::getId) // @@ -1157,10 +1154,11 @@ void shouldReturnInformationListOfAllIndices() { // region Helper functions private SampleEntity randomEntity(String message) { - return SampleEntity.builder() // - .id(UUID.randomUUID().toString()) // - .message(StringUtils.hasText(message) ? message : "test message") // - .version(System.currentTimeMillis()).build(); + SampleEntity entity = new SampleEntity(); + entity.setId(UUID.randomUUID().toString()); + entity.setMessage(StringUtils.hasText(message) ? message : "test message"); + entity.setVersion(System.currentTimeMillis()); + return entity; } private IndexQuery getIndexQuery(SampleEntity sampleEntity) { @@ -1187,75 +1185,259 @@ private void index(SampleEntity... entities) { // endregion // region Entities - @Data @Document(indexName = "marvel") static class Person { - - private @Id String id; - private String name; - private int age; + @Nullable private @Id String id; + @Nullable private String name; + @Nullable private int age; public Person() {} public Person(String name, int age) { + this.name = name; + this.age = age; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + public void setName(@Nullable String name) { this.name = name; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { this.age = age; } } - @Data - @AllArgsConstructor - @NoArgsConstructor static class Message { + @Nullable String message; + + public Message(String message) { + this.message = message; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; - String message; + Message message1 = (Message) o; + + return message != null ? message.equals(message1.message) : message1.message == null; + } + + @Override + public int hashCode() { + return message != null ? message.hashCode() : 0; + } } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @EqualsAndHashCode(exclude = "score") @Document(indexName = DEFAULT_INDEX, replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SampleEntity that = (SampleEntity) o; - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @Version private Long version; + if (rate != that.rate) return false; + if (id != null ? !id.equals(that.id) : that.id != null) return false; + if (message != null ? !message.equals(that.message) : that.message != null) return false; + return version != null ? version.equals(that.version) : that.version == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (message != null ? message.hashCode() : 0); + result = 31 * result + rate; + result = 31 * result + (version != null ? version.hashCode() : 0); + return result; + } } - @Data @Document(indexName = "test-index-reactive-optimistic-entity-template") static class OptimisticEntity { - @Id private String id; - private String message; - private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable @Id private String id; + @Nullable private String message; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } - @Data @Document(indexName = "test-index-reactive-optimistic-and-versioned-entity-template") static class OptimisticAndVersionedEntity { - @Id private String id; - private String message; - private SeqNoPrimaryTerm seqNoPrimaryTerm; - @Version private Long version; + @Nullable @Id private String id; + @Nullable private String message; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-reactive-versioned-entity-template") static class VersionedEntity { - @Id private String id; - @Version private Long version; + @Nullable @Id private String id; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } - @Data @Document(indexName = "test-index-reactive-information-list", createIndex = false) @Setting(settingPath = "settings/test-settings.json") @Mapping(mappingPath = "mappings/test-mappings.json") private static class EntityWithSettingsAndMappingsReactive { - @Id String id; + @Nullable @Id String id; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } } // endregion diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java index fb467a144..98eb8dc65 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateUnitTests.java @@ -20,10 +20,6 @@ import static org.mockito.Mockito.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -62,6 +58,7 @@ import org.springframework.data.elasticsearch.core.query.CriteriaQuery; import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.core.query.StringQuery; +import org.springframework.lang.Nullable; /** * @author Christoph Strobl @@ -253,27 +250,89 @@ public void deleteByShouldApplyIndicesOptionsIfSet() { assertThat(captor.getValue().indicesOptions()).isEqualTo(IndicesOptions.LENIENT_EXPAND_OPEN); } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Chris White - * @author Sascha Woo - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-sample-core-reactive-template-Unit", replicas = 0, refreshInterval = "-1") static class SampleEntity { - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @ScriptedField private Double scriptedRate; - private boolean available; - private String highlightedMessage; - private GeoPoint location; - @Version private Long version; + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Double scriptedRate; + @Nullable private boolean available; + @Nullable private String highlightedMessage; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public java.lang.Double getScriptedRate() { + return scriptedRate; + } + + public void setScriptedRate(java.lang.Double scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + public String getHighlightedMessage() { + return highlightedMessage; + } + + public void setHighlightedMessage(String highlightedMessage) { + this.highlightedMessage = highlightedMessage; + } + + public GeoPoint getLocation() { + return location; + } + + public void setLocation(GeoPoint location) { + this.location = location; + } + + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(java.lang.Long version) { + this.version = version; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java index 01e6e9dd9..8348b98ef 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveIndexOperationsTest.java @@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.skyscreamer.jsonassert.JSONAssert.*; -import lombok.Data; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -506,27 +505,69 @@ void shouldDeleteTemplate() { assertThat(exists).isFalse(); } - @Data @Document(indexName = TESTINDEX, shards = 3, replicas = 2, refreshInterval = "4s") static class Entity { - @Id private String id; - @Field(type = FieldType.Text) private String text; - @Field(name = "publication-date", type = FieldType.Date, + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text) private String text; + @Nullable @Field(name = "publication-date", type = FieldType.Date, format = DateFormat.basic_date) private LocalDate publicationDate; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public LocalDate getPublicationDate() { + return publicationDate; + } + + public void setPublicationDate(@Nullable LocalDate publicationDate) { + this.publicationDate = publicationDate; + } } - @Data @Document(indexName = TESTINDEX, useServerConfiguration = true) static class EntityUseServerConfig { - @Id private String id; + @Nullable @Id private String id; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } } - @Data @Document(indexName = TESTINDEX) @Setting(settingPath = "/settings/test-settings.json") @Mapping(mappingPath = "/mappings/test-mappings.json") static class EntityWithAnnotatedSettingsAndMappings { - @Id private String id; + @Nullable @Id private String id; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } } @Document(indexName = "test-template", shards = 3, replicas = 2, refreshInterval = "5s") diff --git a/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java b/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java index b06b7edbf..ffc7ef184 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java @@ -20,11 +20,6 @@ import static org.mockito.Mockito.*; import static org.skyscreamer.jsonassert.JSONAssert.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.IOException; import java.util.Arrays; import java.util.HashSet; @@ -460,8 +455,7 @@ void shouldCreatePutIndexTemplateRequest() throws JSONException, IOException { @DisplayName("should set op_type INDEX if not specified") void shouldSetOpTypeIndexIfNotSpecifiedAndIdIsSet() { - IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(Person.builder().id("42").lastName("Smith")) - .build(); + IndexQuery indexQuery = new IndexQueryBuilder().withId("42").withObject(new Person("42", "Smith")).build(); IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype")); @@ -473,7 +467,7 @@ void shouldSetOpTypeIndexIfNotSpecifiedAndIdIsSet() { void shouldSetOpTypeCreateIfSpecified() { IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.CREATE).withId("42") - .withObject(Person.builder().id("42").lastName("Smith")).build(); + .withObject(new Person("42", "Smith")).build(); IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype")); @@ -485,7 +479,7 @@ void shouldSetOpTypeCreateIfSpecified() { void shouldSetOpTypeIndexIfSpecified() { IndexQuery indexQuery = new IndexQueryBuilder().withOpType(IndexQuery.OpType.INDEX).withId("42") - .withObject(Person.builder().id("42").lastName("Smith")).build(); + .withObject(new Person("42", "Smith")).build(); IndexRequest indexRequest = requestFactory.indexRequest(indexQuery, IndexCoordinates.of("optype")); @@ -601,14 +595,50 @@ void shouldBuildSearchWithRescorerQuery() throws JSONException { assertEquals(expected, searchRequest, false); } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor static class Person { @Nullable @Id String id; @Nullable @Field(name = "last-name") String lastName; @Nullable @Field(name = "current-location") GeoPoint location; + + public Person() {} + + public Person(@Nullable String id, @Nullable String lastName) { + this.id = id; + this.lastName = lastName; + } + + public Person(@Nullable String id, @Nullable String lastName, @Nullable GeoPoint location) { + this.id = id; + this.lastName = lastName; + this.location = location; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getLastName() { + return lastName; + } + + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } } static class EntityWithSeqNoPrimaryTerm { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java b/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java index c03c3cd94..c04c30879 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/SearchAsYouTypeTests.java @@ -17,12 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -76,10 +70,10 @@ void after() { private void loadEntities() { List indexQueries = new ArrayList<>(); - indexQueries.add(SearchAsYouTypeEntity.builder().id("1").name("test 1").suggest("test 1234").build().toIndex()); - indexQueries.add(SearchAsYouTypeEntity.builder().id("2").name("test 2").suggest("test 5678").build().toIndex()); - indexQueries.add(SearchAsYouTypeEntity.builder().id("3").name("test 3").suggest("asd 5678").build().toIndex()); - indexQueries.add(SearchAsYouTypeEntity.builder().id("4").name("test 4").suggest("not match").build().toIndex()); + indexQueries.add(new SearchAsYouTypeEntity("1", "test 1", "test 1234").toIndex()); + indexQueries.add(new SearchAsYouTypeEntity("2", "test 2", "test 5678").toIndex()); + indexQueries.add(new SearchAsYouTypeEntity("3", "test 3", "asd 5678").toIndex()); + indexQueries.add(new SearchAsYouTypeEntity("4", "test 4", "not match").toIndex()); IndexCoordinates index = IndexCoordinates.of("test-index-core-search-as-you-type"); operations.bulkIndex(indexQueries, index); operations.indexOps(SearchAsYouTypeEntity.class).refresh(); @@ -109,9 +103,8 @@ void shouldReturnCorrectResultsForTextString() { .collect(Collectors.toList()); // then - assertThat(result).hasSize(2); - assertThat(result).contains(new SearchAsYouTypeEntity("1")); - assertThat(result).contains(new SearchAsYouTypeEntity("2")); + List ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList()); + assertThat(ids).containsExactlyInAnyOrder("1", "2"); } @Test // DATAES-773 @@ -131,9 +124,8 @@ void shouldReturnCorrectResultsForNumQuery() { .collect(Collectors.toList()); // then - assertThat(result).hasSize(2); - assertThat(result).contains(new SearchAsYouTypeEntity("2")); - assertThat(result).contains(new SearchAsYouTypeEntity("3")); + List ids = result.stream().map(SearchAsYouTypeEntity::getId).collect(Collectors.toList()); + assertThat(ids).containsExactlyInAnyOrder("2", "3"); } @Test // DATAES-773 @@ -153,18 +145,12 @@ void shouldReturnCorrectResultsForNotMatchQuery() { .collect(Collectors.toList()); // then - assertThat(result).hasSize(1); - assertThat(result).contains(new SearchAsYouTypeEntity("4")); + assertThat(result.get(0).getId()).isEqualTo("4"); } /** * @author Aleksei Arsenev */ - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor - @EqualsAndHashCode(onlyExplicitlyIncluded = true) @Document(indexName = "test-index-core-search-as-you-type", replicas = 0, refreshInterval = "-1") static class SearchAsYouTypeEntity { @@ -172,17 +158,71 @@ public SearchAsYouTypeEntity(@Nonnull String id) { this.id = id; } - @NonNull @Id @EqualsAndHashCode.Include private String id; - + @Nullable @Id private String id; @Nullable private String name; - @Nullable @Field(type = FieldType.Search_As_You_Type, maxShingleSize = 4) private String suggest; + public SearchAsYouTypeEntity() { + } + + public SearchAsYouTypeEntity(String id, @Nullable String name, @Nullable String suggest) { + this.id = id; + this.name = name; + this.suggest = suggest; + } + public IndexQuery toIndex() { IndexQuery indexQuery = new IndexQuery(); indexQuery.setId(getId()); indexQuery.setObject(this); return indexQuery; } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getSuggest() { + return suggest; + } + + public void setSuggest(@Nullable String suggest) { + this.suggest = suggest; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + SearchAsYouTypeEntity that = (SearchAsYouTypeEntity) o; + + if (id != null ? !id.equals(that.id) : that.id != null) return false; + if (name != null ? !name.equals(that.name) : that.name != null) return false; + return suggest != null ? suggest.equals(that.suggest) : that.suggest == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (suggest != null ? suggest.hashCode() : 0); + return result; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java index abcc79998..0bd7f4a18 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/SourceFilterIntegrationTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Collections; import java.util.List; @@ -39,6 +34,7 @@ import org.springframework.data.elasticsearch.core.query.SourceFilter; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -57,7 +53,12 @@ void setUp() { indexOps.create(); indexOps.putMapping(); - operations.save(Entity.builder().id("42").field1("one").field2("two").field3("three").build()); + Entity entity = new Entity(); + entity.setId("42"); + entity.setField1("one"); + entity.setField2("two"); + entity.setField3("three"); + operations.save(entity); } @AfterEach @@ -201,15 +202,47 @@ public String[] getExcludes() { assertThat(entity.getField3()).isNull(); } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "sourcefilter-tests") public static class Entity { - @Id private String id; - @Field(type = FieldType.Text) private String field1; - @Field(type = FieldType.Text) private String field2; - @Field(type = FieldType.Text) private String field3; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text) private String field1; + @Nullable @Field(type = FieldType.Text) private String field2; + @Nullable @Field(type = FieldType.Text) private String field3; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getField1() { + return field1; + } + + public void setField1(@Nullable String field1) { + this.field1 = field1; + } + + @Nullable + public String getField2() { + return field2; + } + + public void setField2(@Nullable String field2) { + this.field2 = field2; + } + + @Nullable + public String getField3() { + return field3; + } + + public void setField3(@Nullable String field3) { + this.field3 = field3; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java index 7b88efb8b..c60c23bf9 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/aggregation/ElasticsearchTemplateAggregationTests.java @@ -21,8 +21,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.annotations.FieldType.Integer; -import lombok.Data; - import java.lang.Integer; import java.util.ArrayList; import java.util.List; @@ -50,6 +48,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -131,33 +130,79 @@ public void shouldReturnAggregatedResponseForGivenSearchQuery() { assertThat(searchHits.hasSearchHits()).isFalse(); } - /** - * Simple type to test facets - * - * @author Artur Konczak - * @author Mohsin Husen - */ - @Data @Document(indexName = "test-index-articles-core-aggregation", replicas = 0, refreshInterval = "-1") static class ArticleEntity { - @Id private String id; - private String title; - @Field(type = Text, fielddata = true) private String subject; + @Nullable @Id private String id; + @Nullable private String title; + @Nullable @Field(type = Text, fielddata = true) private String subject; - @MultiField(mainField = @Field(type = Text), + @Nullable @MultiField(mainField = @Field(type = Text), otherFields = { @InnerField(suffix = "untouched", type = Text, store = true, fielddata = true, analyzer = "keyword"), @InnerField(suffix = "sort", type = Text, store = true, analyzer = "keyword") }) private List authors = new ArrayList<>(); - @Field(type = Integer, store = true) private List publishedYears = new ArrayList<>(); + @Nullable @Field(type = Integer, store = true) private List publishedYears = new ArrayList<>(); - private int score; + @Nullable private int score; public ArticleEntity(String id) { this.id = id; } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getTitle() { + return title; + } + + public void setTitle(@Nullable String title) { + this.title = title; + } + + @Nullable + public String getSubject() { + return subject; + } + + public void setSubject(@Nullable String subject) { + this.subject = subject; + } + + @Nullable + public List getAuthors() { + return authors; + } + + public void setAuthors(@Nullable List authors) { + this.authors = authors; + } + + @Nullable + public List getPublishedYears() { + return publishedYears; + } + + public void setPublishedYears(@Nullable List publishedYears) { + this.publishedYears = publishedYears; + } + + public int getScore() { + return score; + } + + public void setScore(int score) { + this.score = score; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java index 8d20208a8..225102876 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverterUnitTests.java @@ -19,15 +19,6 @@ import static org.assertj.core.api.Assertions.*; import static org.skyscreamer.jsonassert.JSONAssert.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.RequiredArgsConstructor; -import lombok.Setter; - import java.time.LocalDate; import java.util.ArrayList; import java.util.Arrays; @@ -156,10 +147,10 @@ public void init() { observatoryRoad.location = new Point(-118.3026284D, 34.118347D); bigBunsCafe = new Place(); - bigBunsCafe.name = "Big Buns Cafe"; - bigBunsCafe.city = "Los Angeles"; - bigBunsCafe.street = "15 South Fremont Avenue"; - bigBunsCafe.location = new Point(-118.1545845D, 34.0945637D); + bigBunsCafe.setName("Big Buns Cafe"); + bigBunsCafe.setCity("Los Angeles"); + bigBunsCafe.setStreet("15 South Fremont Avenue"); + bigBunsCafe.setLocation(new Point(-118.1545845D, 34.0945637D)); sarahAsMap = Document.create(); sarahAsMap.put("id", "sarah"); @@ -258,13 +249,11 @@ public void shouldReturnDefaultConversionService() { @Test // DATAES-530 public void shouldMapObjectToJsonString() { - // Given - - // When - String jsonResult = mappingElasticsearchConverter.mapObject(Car.builder().model(CAR_MODEL).name(CAR_NAME).build()) - .toJson(); + Car car = new Car(); + car.setModel(CAR_MODEL); + car.setName(CAR_NAME); + String jsonResult = mappingElasticsearchConverter.mapObject(car).toJson(); - // Then assertThat(jsonResult).isEqualTo(JSON_STRING); } @@ -307,19 +296,14 @@ public void shouldMapGeoPointElasticsearchNames() throws JSONException { " ]\n" + // "}\n"; // - GeoEntity geoEntity = GeoEntity.builder().pointA(point).pointB(GeoPoint.fromPoint(point)).pointC(pointAsString) - .pointD(pointAsArray).build(); - // when + GeoEntity geoEntity = new GeoEntity(); + geoEntity.setPointA(point); + geoEntity.setPointB(GeoPoint.fromPoint(point)); + geoEntity.setPointC(pointAsString); + geoEntity.setPointD(pointAsArray); String jsonResult = mappingElasticsearchConverter.mapObject(geoEntity).toJson(); - // then - assertEquals(expected, jsonResult, false); - // assertThat(jsonResult).contains(pointTemplate("pointA", point)); - // assertThat(jsonResult).contains(pointTemplate("pointB", point)); - // assertThat(jsonResult).contains(String.format(Locale.ENGLISH, "\"%s\":\"%s\"", "pointC", pointAsString)); - // assertThat(jsonResult) - // .contains(String.format(Locale.ENGLISH, "\"%s\":[%.1f,%.1f]", "pointD", pointAsArray[0], pointAsArray[1])); } @Test // DATAES-530 @@ -327,10 +311,10 @@ public void ignoresReadOnlyProperties() { // given Sample sample = new Sample(); - sample.readOnly = "readOnly"; - sample.property = "property"; - sample.javaTransientProperty = "javaTransient"; - sample.annotatedTransientProperty = "transient"; + sample.setReadOnly("readOnly"); + sample.setProperty("property"); + sample.setJavaTransientProperty("javaTransient"); + sample.setAnnotatedTransientProperty("transient"); // when String result = mappingElasticsearchConverter.mapObject(sample).toJson(); @@ -360,8 +344,8 @@ public void writesNestedEntity() { public void writesConcreteList() { Person ginger = new Person(); - ginger.id = "ginger"; - ginger.gender = Gender.MAN; + ginger.setId("ginger"); + ginger.setGender(Gender.MAN); sarahConnor.coWorkers = Arrays.asList(kyleReese, ginger); @@ -630,9 +614,9 @@ public void readSubTypeCorrectly() { @Test // DATAES-716 void shouldWriteLocalDate() throws JSONException { Person person = new Person(); - person.id = "4711"; - person.firstName = "John"; - person.lastName = "Doe"; + person.setId("4711"); + person.setFirstName("John"); + person.setLastName("Doe"); person.birthDate = LocalDate.of(2000, 8, 22); person.gender = Gender.MAN; @@ -703,8 +687,8 @@ void shouldReadListOfLocalDate() { void writeEntityWithMapDataType() { Notification notification = new Notification(); - notification.fromEmail = "from@email.com"; - notification.toEmail = "to@email.com"; + notification.setFromEmail("from@email.com"); + notification.setToEmail("to@email.com"); Map data = new HashMap<>(); data.put("documentType", "abc"); data.put("content", null); @@ -920,23 +904,22 @@ void setup() { .of(Arrays.asList(GeoJsonPoint.of(12, 34), GeoJsonPolygon .of(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12), new Point(12, 34))))); - entity = GeoJsonEntity.builder() // - .id("42") // - .point1(GeoJsonPoint.of(12, 34)) // - .point2(GeoJsonPoint.of(56, 78)) // - .multiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) // - .multiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) // - .lineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) // - .lineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) // - .multiLineString1(multiLineString) // - .multiLineString2(multiLineString) // - .polygon1(geoJsonPolygon) // - .polygon2(geoJsonPolygon) // - .multiPolygon1(geoJsonMultiPolygon) // - .multiPolygon2(geoJsonMultiPolygon) // - .geometryCollection1(geoJsonGeometryCollection) // - .geometryCollection2(geoJsonGeometryCollection) // - .build(); + entity = new GeoJsonEntity(); + entity.setId("42"); + entity.setPoint1(GeoJsonPoint.of(12, 34)); + entity.setPoint2(GeoJsonPoint.of(56, 78)); + entity.setMultiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))); + entity.setMultiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))); + entity.setLineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))); + entity.setLineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))); + entity.setMultiLineString1(multiLineString); + entity.setMultiLineString2(multiLineString); + entity.setPolygon1(geoJsonPolygon); + entity.setPolygon2(geoJsonPolygon); + entity.setMultiPolygon1(geoJsonMultiPolygon); + entity.setMultiPolygon2(geoJsonMultiPolygon); + entity.setGeometryCollection1(geoJsonGeometryCollection); + entity.setGeometryCollection2(geoJsonGeometryCollection); } @Test // DATAES-930 @@ -1205,37 +1188,233 @@ private Map writeToMap(Object source) { } public static class Sample { - @Nullable public @ReadOnlyProperty String readOnly; @Nullable public @Transient String annotatedTransientProperty; @Nullable public transient String javaTransientProperty; @Nullable public String property; + + @Nullable + public String getReadOnly() { + return readOnly; + } + + public void setReadOnly(@Nullable String readOnly) { + this.readOnly = readOnly; + } + + @Nullable + public String getAnnotatedTransientProperty() { + return annotatedTransientProperty; + } + + public void setAnnotatedTransientProperty(@Nullable String annotatedTransientProperty) { + this.annotatedTransientProperty = annotatedTransientProperty; + } + + @Nullable + public String getJavaTransientProperty() { + return javaTransientProperty; + } + + public void setJavaTransientProperty(@Nullable String javaTransientProperty) { + this.javaTransientProperty = javaTransientProperty; + } + + @Nullable + public String getProperty() { + return property; + } + + public void setProperty(@Nullable String property) { + this.property = property; + } } - @Data static class Person { + @Nullable @Id String id; + @Nullable String name; + @Nullable @Field(name = "first-name") String firstName; + @Nullable @Field(name = "last-name") String lastName; + @Nullable @Field(name = "birth-date", type = FieldType.Date, format = {}, + pattern = "dd.MM.uuuu") LocalDate birthDate; + @Nullable Gender gender; + @Nullable Address address; + @Nullable List coWorkers; + @Nullable List inventoryList; + @Nullable Map shippingAddresses; + @Nullable Map inventoryMap; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getFirstName() { + return firstName; + } + + public void setFirstName(@Nullable String firstName) { + this.firstName = firstName; + } + + @Nullable + public String getLastName() { + return lastName; + } + + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } + + @Nullable + public LocalDate getBirthDate() { + return birthDate; + } + + public void setBirthDate(@Nullable LocalDate birthDate) { + this.birthDate = birthDate; + } + + @Nullable + public Gender getGender() { + return gender; + } + + public void setGender(@Nullable Gender gender) { + this.gender = gender; + } + + @Nullable + public Address getAddress() { + return address; + } + + public void setAddress(@Nullable Address address) { + this.address = address; + } + + @Nullable + public List getCoWorkers() { + return coWorkers; + } + + public void setCoWorkers(@Nullable List coWorkers) { + this.coWorkers = coWorkers; + } + + @Nullable + public List getInventoryList() { + return inventoryList; + } + + public void setInventoryList(@Nullable List inventoryList) { + this.inventoryList = inventoryList; + } + + @Nullable + public Map getShippingAddresses() { + return shippingAddresses; + } + + public void setShippingAddresses(@Nullable Map shippingAddresses) { + this.shippingAddresses = shippingAddresses; + } - @Id String id; - String name; - @Field(name = "first-name") String firstName; - @Field(name = "last-name") String lastName; - @Field(name = "birth-date", type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") LocalDate birthDate; - Gender gender; - Address address; + @Nullable + public Map getInventoryMap() { + return inventoryMap; + } + + public void setInventoryMap(@Nullable Map inventoryMap) { + this.inventoryMap = inventoryMap; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Person person = (Person) o; + + if (id != null ? !id.equals(person.id) : person.id != null) + return false; + if (name != null ? !name.equals(person.name) : person.name != null) + return false; + if (firstName != null ? !firstName.equals(person.firstName) : person.firstName != null) + return false; + if (lastName != null ? !lastName.equals(person.lastName) : person.lastName != null) + return false; + if (birthDate != null ? !birthDate.equals(person.birthDate) : person.birthDate != null) + return false; + if (gender != person.gender) + return false; + if (address != null ? !address.equals(person.address) : person.address != null) + return false; + if (coWorkers != null ? !coWorkers.equals(person.coWorkers) : person.coWorkers != null) + return false; + if (inventoryList != null ? !inventoryList.equals(person.inventoryList) : person.inventoryList != null) + return false; + if (shippingAddresses != null ? !shippingAddresses.equals(person.shippingAddresses) + : person.shippingAddresses != null) + return false; + return inventoryMap != null ? inventoryMap.equals(person.inventoryMap) : person.inventoryMap == null; + } - List coWorkers; - List inventoryList; - Map shippingAddresses; - Map inventoryMap; + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (firstName != null ? firstName.hashCode() : 0); + result = 31 * result + (lastName != null ? lastName.hashCode() : 0); + result = 31 * result + (birthDate != null ? birthDate.hashCode() : 0); + result = 31 * result + (gender != null ? gender.hashCode() : 0); + result = 31 * result + (address != null ? address.hashCode() : 0); + result = 31 * result + (coWorkers != null ? coWorkers.hashCode() : 0); + result = 31 * result + (inventoryList != null ? inventoryList.hashCode() : 0); + result = 31 * result + (shippingAddresses != null ? shippingAddresses.hashCode() : 0); + result = 31 * result + (inventoryMap != null ? inventoryMap.hashCode() : 0); + return result; + } } - @Data - @Getter - @Setter static class LocalDatesEntity { - @Id private String id; - @Field(name = "dates", type = FieldType.Date, format = DateFormat.custom, + @Nullable @Id private String id; + @Nullable @Field(name = "dates", type = FieldType.Date, format = DateFormat.custom, pattern = "dd.MM.uuuu") private List dates; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public List getDates() { + return dates; + } + + public void setDates(@Nullable List dates) { + this.dates = dates; + } } enum Gender { @@ -1258,89 +1437,314 @@ interface Inventory { String getLabel(); } - @Getter - @RequiredArgsConstructor - @EqualsAndHashCode static class Gun implements Inventory { - final String label; final int shotsPerMagazine; + public Gun(@Nullable String label, int shotsPerMagazine) { + this.label = label; + this.shotsPerMagazine = shotsPerMagazine; + } + @Override public String getLabel() { return label; } + + public int getShotsPerMagazine() { + return shotsPerMagazine; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Gun gun = (Gun) o; + + if (shotsPerMagazine != gun.shotsPerMagazine) + return false; + return label.equals(gun.label); + } + + @Override + public int hashCode() { + int result = label.hashCode(); + result = 31 * result + shotsPerMagazine; + return result; + } } - @RequiredArgsConstructor - @EqualsAndHashCode static class Grenade implements Inventory { - final String label; + public Grenade(String label) { + this.label = label; + } + @Override public String getLabel() { return label; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Grenade)) + return false; + + Grenade grenade = (Grenade) o; + + return label.equals(grenade.label); + } + + @Override + public int hashCode() { + return label.hashCode(); + } } @TypeAlias("rifle") - @EqualsAndHashCode - @RequiredArgsConstructor static class Rifle implements Inventory { final String label; final double weight; final int maxShotsPerMagazine; + public Rifle(String label, double weight, int maxShotsPerMagazine) { + this.label = label; + this.weight = weight; + this.maxShotsPerMagazine = maxShotsPerMagazine; + } + @Override public String getLabel() { return label; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Rifle)) + return false; + + Rifle rifle = (Rifle) o; + + if (Double.compare(rifle.weight, weight) != 0) + return false; + if (maxShotsPerMagazine != rifle.maxShotsPerMagazine) + return false; + return label.equals(rifle.label); + } + + @Override + public int hashCode() { + int result; + long temp; + result = label.hashCode(); + temp = Double.doubleToLongBits(weight); + result = 31 * result + (int) (temp ^ (temp >>> 32)); + result = 31 * result + maxShotsPerMagazine; + return result; + } } - @EqualsAndHashCode - @RequiredArgsConstructor static class ShotGun implements Inventory { - final String label; + private final String label; + + public ShotGun(String label) { + this.label = label; + } @Override public String getLabel() { return label; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof ShotGun)) + return false; + + ShotGun shotGun = (ShotGun) o; + + return label.equals(shotGun.label); + } + + @Override + public int hashCode() { + return label.hashCode(); + } } - @Data static class Address { + @Nullable private Point location; + @Nullable private String street; + @Nullable private String city; + + @Nullable + public Point getLocation() { + return location; + } + + public void setLocation(@Nullable Point location) { + this.location = location; + } - Point location; - String street; - String city; + @Nullable + public String getStreet() { + return street; + } + + public void setStreet(@Nullable String street) { + this.street = street; + } + + @Nullable + public String getCity() { + return city; + } + + public void setCity(@Nullable String city) { + this.city = city; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Address)) + return false; + + Address address = (Address) o; + + if (location != null ? !location.equals(address.location) : address.location != null) + return false; + if (street != null ? !street.equals(address.street) : address.street != null) + return false; + return city != null ? city.equals(address.city) : address.city == null; + } + + @Override + public int hashCode() { + int result = location != null ? location.hashCode() : 0; + result = 31 * result + (street != null ? street.hashCode() : 0); + result = 31 * result + (city != null ? city.hashCode() : 0); + return result; + } } - @EqualsAndHashCode(callSuper = true) - @Data static class Place extends Address { + @Nullable private String name; + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } - String name; + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Place)) + return false; + + Place place = (Place) o; + + return name != null ? name.equals(place.name) : place.name == null; + } + + @Override + public int hashCode() { + return name != null ? name.hashCode() : 0; + } } - @Data static class Skynet { + @Nullable private Object object; + @Nullable private List objectList; + @Nullable private Map objectMap; + + @Nullable + public Object getObject() { + return object; + } + + public void setObject(@Nullable Object object) { + this.object = object; + } + + @Nullable + public List getObjectList() { + return objectList; + } + + public void setObjectList(@Nullable List objectList) { + this.objectList = objectList; + } + + @Nullable + public Map getObjectMap() { + return objectMap; + } - Object object; - List objectList; - Map objectMap; + public void setObjectMap(@Nullable Map objectMap) { + this.objectMap = objectMap; + } } - @Data static class Notification { + @Nullable private Long id; + @Nullable private String fromEmail; + @Nullable private String toEmail; + @Nullable private Map params; + + @Nullable + public Long getId() { + return id; + } + + public void setId(@Nullable Long id) { + this.id = id; + } + + @Nullable + public String getFromEmail() { + return fromEmail; + } + + public void setFromEmail(@Nullable String fromEmail) { + this.fromEmail = fromEmail; + } + + @Nullable + public String getToEmail() { + return toEmail; + } + + public void setToEmail(@Nullable String toEmail) { + this.toEmail = toEmail; + } + + @Nullable + public Map getParams() { + return params; + } - Long id; - String fromEmail; - String toEmail; - Map params; + public void setParams(@Nullable Map params) { + this.params = params; + } } @WritingConverter @@ -1365,81 +1769,244 @@ public ShotGun convert(Map source) { } } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder static class Car { + @Nullable private String name; + @Nullable private String model; - private String name; - private String model; + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getModel() { + return model; + } + + public void setModel(@Nullable String model) { + this.model = model; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @org.springframework.data.elasticsearch.annotations.Document(indexName = "test-index-geo-core-entity-mapper", replicas = 0, refreshInterval = "-1") static class GeoEntity { + @Nullable @Id private String id; + // geo shape - Spring Data + @Nullable private Box box; + @Nullable private Circle circle; + @Nullable private Polygon polygon; + // geo point - Custom implementation + Spring Data + @Nullable @GeoPointField private Point pointA; + @Nullable private GeoPoint pointB; + @Nullable @GeoPointField private String pointC; + @Nullable @GeoPointField private double[] pointD; + + @Nullable + public String getId() { + return id; + } - @Id private String id; + public void setId(@Nullable String id) { + this.id = id; + } - // geo shape - Spring Data - private Box box; - private Circle circle; - private Polygon polygon; + @Nullable + public Box getBox() { + return box; + } - // geo point - Custom implementation + Spring Data - @GeoPointField private Point pointA; + public void setBox(@Nullable Box box) { + this.box = box; + } - private GeoPoint pointB; + @Nullable + public Circle getCircle() { + return circle; + } - @GeoPointField private String pointC; + public void setCircle(@Nullable Circle circle) { + this.circle = circle; + } + + @Nullable + public Polygon getPolygon() { + return polygon; + } + + public void setPolygon(@Nullable Polygon polygon) { + this.polygon = polygon; + } + + @Nullable + public Point getPointA() { + return pointA; + } + + public void setPointA(@Nullable Point pointA) { + this.pointA = pointA; + } + + @Nullable + public GeoPoint getPointB() { + return pointB; + } + + public void setPointB(@Nullable GeoPoint pointB) { + this.pointB = pointB; + } + + @Nullable + public String getPointC() { + return pointC; + } + + public void setPointC(@Nullable String pointC) { + this.pointC = pointC; + } + + @Nullable + public double[] getPointD() { + return pointD; + } - @GeoPointField private double[] pointD; + public void setPointD(@Nullable double[] pointD) { + this.pointD = pointD; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor static class SchemaLessObjectWrapper { + @Nullable private Map schemaLessObject; - private Map schemaLessObject; + @Nullable + public Map getSchemaLessObject() { + return schemaLessObject; + } + + public void setSchemaLessObject(@Nullable Map schemaLessObject) { + this.schemaLessObject = schemaLessObject; + } } - @Data @org.springframework.data.elasticsearch.annotations.Document( indexName = "test-index-entity-with-seq-no-primary-term-mapper") static class EntityWithSeqNoPrimaryTerm { - @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } - @Data static class EntityWithListProperty { - @Id private String id; + @Nullable @Id private String id; + @Nullable private List values; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } - private List values; + @Nullable + public List getValues() { + return values; + } + + public void setValues(@Nullable List values) { + this.values = values; + } } - @Data static class GeoPointListEntity { - @Id String id; - List locations; + @Nullable private @Id String id; + @Nullable private List locations; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public List getLocations() { + return locations; + } + + public void setLocations(@Nullable List locations) { + this.locations = locations; + } } - @Data static class EntityWithObject { - @Id private String id; - private Object content; + @Nullable @Id private String id; + @Nullable private Object content; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public Object getContent() { + return content; + } + + public void setContent(@Nullable Object content) { + this.content = content; + } } - @Data static class EntityWithNullField { - @Id private String id; - @Field(type = FieldType.Text) private String notSaved; - @Field(type = FieldType.Text, storeNullValue = true) private String saved; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text) private String notSaved; + @Nullable @Field(type = FieldType.Text, storeNullValue = true) private String saved; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getNotSaved() { + return notSaved; + } + + public void setNotSaved(@Nullable String notSaved) { + this.notSaved = notSaved; + } + + @Nullable + public String getSaved() { + return saved; + } + + public void setSaved(@Nullable String saved) { + this.saved = saved; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/event/ElasticsearchOperationsCallbackIntegrationTest.java b/src/test/java/org/springframework/data/elasticsearch/core/event/ElasticsearchOperationsCallbackIntegrationTest.java index 3b0c22eb9..6020d29e9 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/event/ElasticsearchOperationsCallbackIntegrationTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/event/ElasticsearchOperationsCallbackIntegrationTest.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.mockito.Mockito.*; -import lombok.Data; - import java.util.Collections; import java.util.List; @@ -216,20 +214,56 @@ void shouldApplyConversionResultToIndexQueryInBulkIndex() { assertThat(capturedIndexQuery.getPrimaryTerm()).isEqualTo(seqNoPrimaryTerm.getPrimaryTerm()); } - @Data @Document(indexName = INDEX) static class SampleEntity { - @Id private String id; - private String text; + @Nullable @Id private String id; + @Nullable private String text; - @JoinTypeRelations(relations = { @JoinTypeRelation(parent = "question", - children = { "answer" }) }) @Nullable private JoinField joinField; + @Nullable @JoinTypeRelations(relations = { @JoinTypeRelation(parent = "question", + children = { "answer" }) }) + private JoinField joinField; - private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; public SampleEntity(String id, String text) { this.id = id; this.text = text; } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public JoinField getJoinField() { + return joinField; + } + + public void setJoinField(@Nullable JoinField joinField) { + this.joinField = joinField; + } + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/geo/ElasticsearchTemplateGeoTests.java b/src/test/java/org/springframework/data/elasticsearch/core/geo/ElasticsearchTemplateGeoTests.java index fd59402ff..548bc6847 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/geo/ElasticsearchTemplateGeoTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/geo/ElasticsearchTemplateGeoTests.java @@ -17,13 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.util.ArrayList; import java.util.List; @@ -50,6 +43,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.utils.IndexInitializer; import org.springframework.data.geo.Point; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -106,23 +100,24 @@ private void loadAnnotationBaseEntities() { String latLonString = "51.000000, 0.100000"; String geohash = "u10j46mkfekr"; Geohash.stringEncode(0.100000, 51.000000); - LocationMarkerEntity location1 = LocationMarkerEntity.builder() // - .id("1").name("Artur Konczak") // - .locationAsString(latLonString) // - .locationAsArray(lonLatArray) // - .locationAsGeoHash(geohash).build(); - LocationMarkerEntity location2 = LocationMarkerEntity.builder() // - .id("2").name("Mohsin Husen") // - .locationAsString(geohash.substring(0, 8)) // - .locationAsArray(lonLatArray) // - .locationAsGeoHash(geohash.substring(0, 8)) // - .build(); - LocationMarkerEntity location3 = LocationMarkerEntity.builder() // - .id("3").name("Rizwan Idrees") // - .locationAsString(geohash) // - .locationAsArray(lonLatArray) // - .locationAsGeoHash(geohash) // - .build(); + LocationMarkerEntity location1 = new LocationMarkerEntity(); + location1.setId("1"); + location1.setName("Artur Konczak"); + location1.setLocationAsString(latLonString); + location1.setLocationAsArray(lonLatArray); + location1.setLocationAsGeoHash(geohash); + LocationMarkerEntity location2 = new LocationMarkerEntity(); + location2.setId("2"); + location2.setName("Mohsin Husen"); + location2.setLocationAsString(geohash.substring(0, 8)); + location2.setLocationAsArray(lonLatArray); + location2.setLocationAsGeoHash(geohash.substring(0, 8)); + LocationMarkerEntity location3 = new LocationMarkerEntity(); + location3.setId("3"); + location3.setName("Rizwan Idrees"); + location3.setLocationAsString(geohash); + location3.setLocationAsArray(lonLatArray); + location3.setLocationAsGeoHash(geohash); indexQueries.add(buildIndex(location1)); indexQueries.add(buildIndex(location2)); indexQueries.add(buildIndex(location3)); @@ -366,20 +361,44 @@ private IndexQuery buildIndex(LocationMarkerEntity result) { * @author Franck Marchand * @author Mohsin Husen */ - @Data @Document(indexName = "test-index-author-marker-core-geo", replicas = 0, refreshInterval = "-1") static class AuthorMarkerEntity { - - @Id private String id; - private String name; - - private GeoPoint location; + @Nullable @Id private String id; + @Nullable private String name; + @Nullable private GeoPoint location; private AuthorMarkerEntity() {} public AuthorMarkerEntity(String id) { this.id = id; } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } } /** @@ -417,25 +436,52 @@ public IndexQuery buildIndex() { } } - /** - * @author Franck Marchand - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-location-marker-core-geo", replicas = 0, refreshInterval = "-1") static class LocationMarkerEntity { + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @GeoPointField private String locationAsString; + @Nullable @GeoPointField private double[] locationAsArray; + @Nullable @GeoPointField private String locationAsGeoHash; + + public String getId() { + return id; + } - @Id private String id; - private String name; + public void setId(String id) { + this.id = id; + } - @GeoPointField private String locationAsString; + public String getName() { + return name; + } - @GeoPointField private double[] locationAsArray; + public void setName(String name) { + this.name = name; + } - @GeoPointField private String locationAsGeoHash; + public String getLocationAsString() { + return locationAsString; + } + public void setLocationAsString(String locationAsString) { + this.locationAsString = locationAsString; + } + + public double[] getLocationAsArray() { + return locationAsArray; + } + + public void setLocationAsArray(double[] locationAsArray) { + this.locationAsArray = locationAsArray; + } + + public String getLocationAsGeoHash() { + return locationAsGeoHash; + } + + public void setLocationAsGeoHash(String locationAsGeoHash) { + this.locationAsGeoHash = locationAsGeoHash; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonEntity.java b/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonEntity.java index 7e780cc98..dde990712 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonEntity.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonEntity.java @@ -15,33 +15,254 @@ */ package org.springframework.data.elasticsearch.core.geo; -import lombok.Builder; -import lombok.Data; - import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.geo.Point; +import org.springframework.lang.Nullable; /** * this class contains each GeoJson type as explicit type and as GeoJson interface. Used by several test classes */ -@Data -@Builder @Document(indexName = "geojson-index") public class GeoJsonEntity { - @Id private String id; - GeoJsonPoint point1; - GeoJson> point2; - GeoJsonMultiPoint multiPoint1; - GeoJson> multiPoint2; - GeoJsonLineString lineString1; - GeoJson> lineString2; - GeoJsonMultiLineString multiLineString1; - GeoJson> multiLineString2; - GeoJsonPolygon polygon1; - GeoJson> polygon2; - GeoJsonMultiPolygon multiPolygon1; - GeoJson> multiPolygon2; - GeoJsonGeometryCollection geometryCollection1; - GeoJson>> geometryCollection2; + @Nullable @Id private String id; + @Nullable private GeoJsonPoint point1; + @Nullable private GeoJson> point2; + @Nullable private GeoJsonMultiPoint multiPoint1; + @Nullable private GeoJson> multiPoint2; + @Nullable private GeoJsonLineString lineString1; + @Nullable private GeoJson> lineString2; + @Nullable private GeoJsonMultiLineString multiLineString1; + @Nullable private GeoJson> multiLineString2; + @Nullable private GeoJsonPolygon polygon1; + @Nullable private GeoJson> polygon2; + @Nullable private GeoJsonMultiPolygon multiPolygon1; + @Nullable private GeoJson> multiPolygon2; + @Nullable private GeoJsonGeometryCollection geometryCollection1; + @Nullable private GeoJson>> geometryCollection2; + + public GeoJsonEntity() {} + + public GeoJsonEntity(@Nullable String id, @Nullable GeoJsonPoint point1, + @Nullable GeoJson> point2, @Nullable GeoJsonMultiPoint multiPoint1, + @Nullable GeoJson> multiPoint2, @Nullable GeoJsonLineString lineString1, + @Nullable GeoJson> lineString2, @Nullable GeoJsonMultiLineString multiLineString1, + @Nullable GeoJson> multiLineString2, @Nullable GeoJsonPolygon polygon1, + @Nullable GeoJson> polygon2, @Nullable GeoJsonMultiPolygon multiPolygon1, + @Nullable GeoJson> multiPolygon2, + @Nullable GeoJsonGeometryCollection geometryCollection1, + @Nullable GeoJson>> geometryCollection2) { + this.id = id; + this.point1 = point1; + this.point2 = point2; + this.multiPoint1 = multiPoint1; + this.multiPoint2 = multiPoint2; + this.lineString1 = lineString1; + this.lineString2 = lineString2; + this.multiLineString1 = multiLineString1; + this.multiLineString2 = multiLineString2; + this.polygon1 = polygon1; + this.polygon2 = polygon2; + this.multiPolygon1 = multiPolygon1; + this.multiPolygon2 = multiPolygon2; + this.geometryCollection1 = geometryCollection1; + this.geometryCollection2 = geometryCollection2; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public GeoJsonPoint getPoint1() { + return point1; + } + + public void setPoint1(@Nullable GeoJsonPoint point1) { + this.point1 = point1; + } + + @Nullable + public GeoJson> getPoint2() { + return point2; + } + + public void setPoint2(@Nullable GeoJson> point2) { + this.point2 = point2; + } + + @Nullable + public GeoJsonMultiPoint getMultiPoint1() { + return multiPoint1; + } + + public void setMultiPoint1(@Nullable GeoJsonMultiPoint multiPoint1) { + this.multiPoint1 = multiPoint1; + } + + @Nullable + public GeoJson> getMultiPoint2() { + return multiPoint2; + } + + public void setMultiPoint2(@Nullable GeoJson> multiPoint2) { + this.multiPoint2 = multiPoint2; + } + + @Nullable + public GeoJsonLineString getLineString1() { + return lineString1; + } + + public void setLineString1(@Nullable GeoJsonLineString lineString1) { + this.lineString1 = lineString1; + } + + @Nullable + public GeoJson> getLineString2() { + return lineString2; + } + + public void setLineString2(@Nullable GeoJson> lineString2) { + this.lineString2 = lineString2; + } + + @Nullable + public GeoJsonMultiLineString getMultiLineString1() { + return multiLineString1; + } + + public void setMultiLineString1(@Nullable GeoJsonMultiLineString multiLineString1) { + this.multiLineString1 = multiLineString1; + } + + @Nullable + public GeoJson> getMultiLineString2() { + return multiLineString2; + } + + public void setMultiLineString2(@Nullable GeoJson> multiLineString2) { + this.multiLineString2 = multiLineString2; + } + + @Nullable + public GeoJsonPolygon getPolygon1() { + return polygon1; + } + + public void setPolygon1(@Nullable GeoJsonPolygon polygon1) { + this.polygon1 = polygon1; + } + + @Nullable + public GeoJson> getPolygon2() { + return polygon2; + } + + public void setPolygon2(@Nullable GeoJson> polygon2) { + this.polygon2 = polygon2; + } + + @Nullable + public GeoJsonMultiPolygon getMultiPolygon1() { + return multiPolygon1; + } + + public void setMultiPolygon1(@Nullable GeoJsonMultiPolygon multiPolygon1) { + this.multiPolygon1 = multiPolygon1; + } + + @Nullable + public GeoJson> getMultiPolygon2() { + return multiPolygon2; + } + + public void setMultiPolygon2(@Nullable GeoJson> multiPolygon2) { + this.multiPolygon2 = multiPolygon2; + } + + @Nullable + public GeoJsonGeometryCollection getGeometryCollection1() { + return geometryCollection1; + } + + public void setGeometryCollection1(@Nullable GeoJsonGeometryCollection geometryCollection1) { + this.geometryCollection1 = geometryCollection1; + } + + @Nullable + public GeoJson>> getGeometryCollection2() { + return geometryCollection2; + } + + public void setGeometryCollection2(@Nullable GeoJson>> geometryCollection2) { + this.geometryCollection2 = geometryCollection2; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof GeoJsonEntity)) + return false; + + GeoJsonEntity that = (GeoJsonEntity) o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + if (point1 != null ? !point1.equals(that.point1) : that.point1 != null) + return false; + if (point2 != null ? !point2.equals(that.point2) : that.point2 != null) + return false; + if (multiPoint1 != null ? !multiPoint1.equals(that.multiPoint1) : that.multiPoint1 != null) + return false; + if (multiPoint2 != null ? !multiPoint2.equals(that.multiPoint2) : that.multiPoint2 != null) + return false; + if (lineString1 != null ? !lineString1.equals(that.lineString1) : that.lineString1 != null) + return false; + if (lineString2 != null ? !lineString2.equals(that.lineString2) : that.lineString2 != null) + return false; + if (multiLineString1 != null ? !multiLineString1.equals(that.multiLineString1) : that.multiLineString1 != null) + return false; + if (multiLineString2 != null ? !multiLineString2.equals(that.multiLineString2) : that.multiLineString2 != null) + return false; + if (polygon1 != null ? !polygon1.equals(that.polygon1) : that.polygon1 != null) + return false; + if (polygon2 != null ? !polygon2.equals(that.polygon2) : that.polygon2 != null) + return false; + if (multiPolygon1 != null ? !multiPolygon1.equals(that.multiPolygon1) : that.multiPolygon1 != null) + return false; + if (multiPolygon2 != null ? !multiPolygon2.equals(that.multiPolygon2) : that.multiPolygon2 != null) + return false; + if (geometryCollection1 != null ? !geometryCollection1.equals(that.geometryCollection1) + : that.geometryCollection1 != null) + return false; + return geometryCollection2 != null ? geometryCollection2.equals(that.geometryCollection2) + : that.geometryCollection2 == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (point1 != null ? point1.hashCode() : 0); + result = 31 * result + (point2 != null ? point2.hashCode() : 0); + result = 31 * result + (multiPoint1 != null ? multiPoint1.hashCode() : 0); + result = 31 * result + (multiPoint2 != null ? multiPoint2.hashCode() : 0); + result = 31 * result + (lineString1 != null ? lineString1.hashCode() : 0); + result = 31 * result + (lineString2 != null ? lineString2.hashCode() : 0); + result = 31 * result + (multiLineString1 != null ? multiLineString1.hashCode() : 0); + result = 31 * result + (multiLineString2 != null ? multiLineString2.hashCode() : 0); + result = 31 * result + (polygon1 != null ? polygon1.hashCode() : 0); + result = 31 * result + (polygon2 != null ? polygon2.hashCode() : 0); + result = 31 * result + (multiPolygon1 != null ? multiPolygon1.hashCode() : 0); + result = 31 * result + (multiPolygon2 != null ? multiPolygon2.hashCode() : 0); + result = 31 * result + (geometryCollection1 != null ? geometryCollection1.hashCode() : 0); + result = 31 * result + (geometryCollection2 != null ? geometryCollection2.hashCode() : 0); + return result; + } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonIntegrationTest.java b/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonIntegrationTest.java index 19fc54c6a..faf75ed9c 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonIntegrationTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/geo/GeoJsonIntegrationTest.java @@ -17,9 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Builder; -import lombok.Data; - import java.util.Arrays; import org.junit.jupiter.api.AfterEach; @@ -38,6 +35,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.geo.Point; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -60,7 +58,7 @@ class GeoJsonIntegrationTest { new Point(20, 20), // new Point(10, 20), // new Point(10, 10)); - private final Area area10To20 = Area.builder().id("area10To20").area(geoShape10To20) /**/.build(); + private final Area area10To20 = new Area("area10To20", geoShape10To20); private final GeoJsonPolygon geoShape5To35 = GeoJsonPolygon.of( // new Point(5, 5), // @@ -68,7 +66,7 @@ class GeoJsonIntegrationTest { new Point(35, 35), // new Point(5, 35), // new Point(5, 5)); - private final Area area5To35 = Area.builder().id("area5To35").area(geoShape5To35).build(); + private final Area area5To35 = new Area("area5To35", geoShape5To35); private final GeoJsonPolygon geoShape15To25 = GeoJsonPolygon.of( // new Point(15, 15), // @@ -76,7 +74,7 @@ class GeoJsonIntegrationTest { new Point(25, 25), // new Point(15, 25), // new Point(15, 15)); - private final Area area15To25 = Area.builder().id("area15To25").area(geoShape15To25).build(); + private final Area area15To25 = new Area("area15To25", geoShape15To25); private final GeoJsonPolygon geoShape30To40 = GeoJsonPolygon.of( // new Point(30, 30), // @@ -84,7 +82,7 @@ class GeoJsonIntegrationTest { new Point(40, 40), // new Point(30, 40), // new Point(30, 30)); - private final Area area30To40 = Area.builder().id("area30To40").area(geoShape30To40).build(); + private final Area area30To40 = new Area("area30To40",geoShape30To40); private final GeoJsonPolygon geoShape32To37 = GeoJsonPolygon.of( // new Point(32, 32), // @@ -92,7 +90,7 @@ class GeoJsonIntegrationTest { new Point(37, 37), // new Point(32, 37), // new Point(32, 32)); - private final Area area32To37 = Area.builder().id("area32To37").area(geoShape30To40).build(); + private final Area area32To37 = new Area("area32To37",geoShape30To40); // endregion // region setup @@ -137,23 +135,22 @@ void shouldWriteAndReadAnEntityWithGeoJsonProperties() { .of(Arrays.asList(GeoJsonPoint.of(12, 34), GeoJsonPolygon .of(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12), new Point(12, 34))))); - GeoJsonEntity entity = GeoJsonEntity.builder() // - .id("42") // - .point1(GeoJsonPoint.of(12, 34)) // - .point2(GeoJsonPoint.of(56, 78)) // - .multiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) // - .multiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) // - .lineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))) // - .lineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))) // - .multiLineString1(multiLineString) // - .multiLineString2(multiLineString) // - .polygon1(geoJsonPolygon) // - .polygon2(geoJsonPolygon) // - .multiPolygon1(geoJsonMultiPolygon) // - .multiPolygon2(geoJsonMultiPolygon) // - .geometryCollection1(geoJsonGeometryCollection) // - .geometryCollection2(geoJsonGeometryCollection) // - .build(); // + GeoJsonEntity entity = new GeoJsonEntity(); + entity.setId("42"); + entity.setPoint1(GeoJsonPoint.of(12, 34)); + entity.setPoint2(GeoJsonPoint.of(56, 78)); + entity.setMultiPoint1(GeoJsonMultiPoint.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))); + entity.setMultiPoint2(GeoJsonMultiPoint.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))); + entity.setLineString1(GeoJsonLineString.of(new Point(12, 34), new Point(56, 78), new Point(90, 12))); + entity.setLineString2(GeoJsonLineString.of(new Point(90, 12), new Point(56, 78), new Point(12, 34))); + entity.setMultiLineString1(multiLineString); + entity.setMultiLineString2(multiLineString); + entity.setPolygon1(geoJsonPolygon); + entity.setPolygon2(geoJsonPolygon); + entity.setMultiPolygon1(geoJsonMultiPolygon); + entity.setMultiPolygon2(geoJsonMultiPolygon); + entity.setGeometryCollection1(geoJsonGeometryCollection); + entity.setGeometryCollection2(geoJsonGeometryCollection); operations.save(entity); indexOps.refresh(); @@ -209,12 +206,33 @@ void shouldFindContainsObjectsWithCriteriaQuery() { // endregion // region test classes - @Data - @Builder @Document(indexName = "areas") static class Area { - @Id private String id; - @Field(name = "the_area") private GeoJsonPolygon area; + @Nullable @Id private String id; + @Nullable @Field(name = "the_area") private GeoJsonPolygon area; + + public Area(@Nullable String id, @Nullable GeoJsonPolygon area) { + this.id = id; + this.area = area; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public GeoJsonPolygon getArea() { + return area; + } + + public void setArea(@Nullable GeoJsonPolygon area) { + this.area = area; + } } // endregion diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/IndexOperationIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/IndexOperationIntegrationTests.java index 3d69f9c54..e5e284a3b 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/IndexOperationIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/IndexOperationIntegrationTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; - import java.util.List; import org.json.JSONException; @@ -36,6 +34,7 @@ import org.springframework.data.elasticsearch.core.IndexOperations; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -98,11 +97,19 @@ void shouldReturnInformationList() throws JSONException { JSONAssert.assertEquals(expectedMappings, indexInformation.getMapping().toJson(), false); } - @Data @Document(indexName = INDEX_NAME) @Setting(settingPath = "settings/test-settings.json") @Mapping(mappingPath = "mappings/test-mappings.json") protected static class EntityWithSettingsAndMappings { - @Id String id; + @Nullable private @Id String id; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java index 9abd53802..9223499ad 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderIntegrationTests.java @@ -22,13 +22,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.Object; import static org.springframework.data.elasticsearch.utils.IndexBuilder.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.lang.Integer; import java.lang.Object; import java.math.BigDecimal; @@ -128,11 +121,11 @@ public void shouldAddStockPriceDocumentToIndex() { String id = "abc"; IndexCoordinates index = IndexCoordinates.of("test-index-stock-mapping-builder"); - operations.index(buildIndex(StockPrice.builder() // - .id(id) // - .symbol(symbol) // - .price(BigDecimal.valueOf(price)) // - .build()), index); + StockPrice stockPrice = new StockPrice(); // + stockPrice.setId(id); + stockPrice.setSymbol(symbol); + stockPrice.setPrice(BigDecimal.valueOf(price)); + operations.index(buildIndex(stockPrice), index); operations.indexOps(StockPrice.class).refresh(); NativeSearchQuery searchQuery = new NativeSearchQueryBuilder().withQuery(matchAllQuery()).build(); @@ -303,17 +296,28 @@ void shouldWriteMappingForDisabledProperty() { indexOps.delete(); } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "ignore-above-index") static class IgnoreAboveEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message; - @Id private String id; + @Nullable + public String getId() { + return id; + } - @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message; + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } } static class FieldNameEntity { @@ -380,64 +384,165 @@ static class MultiFieldEntity { } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-mapping-builder", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - @Data @Document(indexName = "test-index-simple-recursive-mapping-builder", replicas = 0, refreshInterval = "-1") static class SimpleRecursiveEntity { - @Nullable @Id private String id; @Nullable @Field(type = FieldType.Object, ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public SimpleRecursiveEntity getCircularObject() { + return circularObject; + } + + public void setCircularObject(@Nullable SimpleRecursiveEntity circularObject) { + this.circularObject = circularObject; + } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-copy-to-mapping-builder", replicas = 0, refreshInterval = "-1") static class CopyToEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String firstName; + @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String lastName; + @Nullable @Field(type = FieldType.Keyword) private String name; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } - @Id private String id; + @Nullable + public String getFirstName() { + return firstName; + } + + public void setFirstName(@Nullable String firstName) { + this.firstName = firstName; + } - @Field(type = FieldType.Keyword, copyTo = "name") private String firstName; + @Nullable + public String getLastName() { + return lastName; + } - @Field(type = FieldType.Keyword, copyTo = "name") private String lastName; + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } - @Field(type = FieldType.Keyword) private String name; + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-normalizer-mapping-builder", replicas = 0, refreshInterval = "-1") @Setting(settingPath = "/settings/test-normalizer.json") static class NormalizerEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name; + @Nullable @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case", + type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description; - @Id private String id; + @Nullable + public String getId() { + return id; + } - @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name; + public void setId(@Nullable String id) { + this.id = id; + } - @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case", - type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description; + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } static class Author { @@ -510,71 +615,163 @@ public IndexQuery buildIndex() { } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-stock-mapping-builder", replicas = 0, refreshInterval = "-1") static class StockPrice { + @Nullable @Id private String id; + @Nullable private String symbol; + @Nullable @Field(type = FieldType.Double) private BigDecimal price; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getSymbol() { + return symbol; + } - @Id private String id; + public void setSymbol(@Nullable String symbol) { + this.symbol = symbol; + } - private String symbol; + @Nullable + public BigDecimal getPrice() { + return price; + } - @Field(type = FieldType.Double) private BigDecimal price; + public void setPrice(@Nullable BigDecimal price) { + this.price = price; + } } static class AbstractInheritedEntity { - @Nullable @Id private String id; - @Nullable @Field(type = FieldType.Date, format = DateFormat.date_time, index = false) private Date createdDate; - - @Nullable - public String getId() { + @Nullable public String getId() { return id; } - public void setId(String id) { this.id = id; } - - @Nullable - public Date getCreatedDate() { + @Nullable public Date getCreatedDate() { return createdDate; } - public void setCreatedDate(Date createdDate) { this.createdDate = createdDate; } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-geo-mapping-builder", replicas = 0, refreshInterval = "-1") static class GeoEntity { +@Nullable @Id private String id; +// geo shape - Spring Data +@Nullable private Box box; +@Nullable private Circle circle; +@Nullable private Polygon polygon; +// geo point - Custom implementation + Spring Data +@Nullable @GeoPointField private Point pointA; +@Nullable private GeoPoint pointB; +@Nullable @GeoPointField private String pointC; +@Nullable @GeoPointField private double[] pointD; + // geo shape, until e have the classes for this, us a strng +@Nullable @GeoShapeField private String shape1; +@Nullable @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false, + orientation = GeoShapeField.Orientation.clockwise) private String shape2; - @Id private String id; + @Nullable + public String getId() { + return id; + } - // geo shape - Spring Data - private Box box; - private Circle circle; - private Polygon polygon; + public void setId(@Nullable String id) { + this.id = id; + } - // geo point - Custom implementation + Spring Data - @GeoPointField private Point pointA; - private GeoPoint pointB; - @GeoPointField private String pointC; - @GeoPointField private double[] pointD; + @Nullable + public Box getBox() { + return box; + } - // geo shape, until e have the classes for this, us a strng - @GeoShapeField private String shape1; - @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false, - orientation = GeoShapeField.Orientation.clockwise) private String shape2; + public void setBox(@Nullable Box box) { + this.box = box; + } + + @Nullable + public Circle getCircle() { + return circle; + } + + public void setCircle(@Nullable Circle circle) { + this.circle = circle; + } + + @Nullable + public Polygon getPolygon() { + return polygon; + } + + public void setPolygon(@Nullable Polygon polygon) { + this.polygon = polygon; + } + + @Nullable + public Point getPointA() { + return pointA; + } + + public void setPointA(@Nullable Point pointA) { + this.pointA = pointA; + } + + @Nullable + public GeoPoint getPointB() { + return pointB; + } + + public void setPointB(@Nullable GeoPoint pointB) { + this.pointB = pointB; + } + + @Nullable + public String getPointC() { + return pointC; + } + + public void setPointC(@Nullable String pointC) { + this.pointC = pointC; + } + + @Nullable + public double[] getPointD() { + return pointD; + } + + public void setPointD(@Nullable double[] pointD) { + this.pointD = pointD; + } + + @Nullable + public String getShape1() { + return shape1; + } + + public void setShape1(@Nullable String shape1) { + this.shape1 = shape1; + } + + @Nullable + public String getShape2() { + return shape2; + } + + public void setShape2(@Nullable String shape2) { + this.shape2 = shape2; + } } @Document(indexName = "test-index-user-mapping-builder") @@ -604,76 +801,278 @@ public String getValue() { } } - @Getter - @Setter @Document(indexName = "completion") static class CompletionDocument { - @Id private String id; - - @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO, + @Nullable @Id private String id; + @Nullable @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO, path = "proppath") }) private Completion suggest; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public Completion getSuggest() { + return suggest; + } + + public void setSuggest(@Nullable Completion suggest) { + this.suggest = suggest; + } } - @Data @Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder") static class EntityWithSeqNoPrimaryTerm { + @Nullable @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm; - @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } - @Data static class RankFeatureEntity { - @Id private String id; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Rank_Feature) private Integer pageRank; + @Nullable @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength; + @Nullable @Field(type = FieldType.Rank_Features) private Map topics; - @Field(type = FieldType.Rank_Feature) private Integer pageRank; + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public java.lang.Integer getPageRank() { + return pageRank; + } - @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength; + public void setPageRank(@Nullable java.lang.Integer pageRank) { + this.pageRank = pageRank; + } + + @Nullable + public java.lang.Integer getUrlLength() { + return urlLength; + } + + public void setUrlLength(@Nullable java.lang.Integer urlLength) { + this.urlLength = urlLength; + } - @Field(type = FieldType.Rank_Features) private Map topics; + @Nullable + public Map getTopics() { + return topics; + } + + public void setTopics(@Nullable Map topics) { + this.topics = topics; + } } - @Data @Document(indexName = "termvectors-test") static class TermVectorFieldEntity { - @Id private String id; - @Field(type = FieldType.Text, termVector = TermVector.no) private String no; - @Field(type = FieldType.Text, termVector = TermVector.yes) private String yes; - @Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions; - @Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets; - @Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets) private String with_positions_offsets; - @Field(type = FieldType.Text, + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.no) private String no; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.yes) private String yes; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions) private String with_positions; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_offsets) private String with_offsets; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets) private String with_positions_offsets; + @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions_payloads) private String with_positions_payloads; - @Field(type = FieldType.Text, + @Nullable @Field(type = FieldType.Text, termVector = TermVector.with_positions_offsets_payloads) private String with_positions_offsets_payloads; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getNo() { + return no; + } + + public void setNo(@Nullable String no) { + this.no = no; + } + + @Nullable + public String getYes() { + return yes; + } + + public void setYes(@Nullable String yes) { + this.yes = yes; + } + + @Nullable + public String getWith_positions() { + return with_positions; + } + + public void setWith_positions(@Nullable String with_positions) { + this.with_positions = with_positions; + } + + @Nullable + public String getWith_offsets() { + return with_offsets; + } + + public void setWith_offsets(@Nullable String with_offsets) { + this.with_offsets = with_offsets; + } + + @Nullable + public String getWith_positions_offsets() { + return with_positions_offsets; + } + + public void setWith_positions_offsets(@Nullable String with_positions_offsets) { + this.with_positions_offsets = with_positions_offsets; + } + + @Nullable + public String getWith_positions_payloads() { + return with_positions_payloads; + } + + public void setWith_positions_payloads(@Nullable String with_positions_payloads) { + this.with_positions_payloads = with_positions_payloads; + } + + @Nullable + public String getWith_positions_offsets_payloads() { + return with_positions_offsets_payloads; + } + + public void setWith_positions_offsets_payloads(@Nullable String with_positions_offsets_payloads) { + this.with_positions_offsets_payloads = with_positions_offsets_payloads; + } } - @Data @Document(indexName = "wildcard-test") static class WildcardEntity { @Nullable @Field(type = Wildcard) private String wildcardWithoutParams; @Nullable @Field(type = Wildcard, nullValue = "WILD", ignoreAbove = 42) private String wildcardWithParams; + + @Nullable + public String getWildcardWithoutParams() { + return wildcardWithoutParams; + } + + public void setWildcardWithoutParams(@Nullable String wildcardWithoutParams) { + this.wildcardWithoutParams = wildcardWithoutParams; + } + + @Nullable + public String getWildcardWithParams() { + return wildcardWithParams; + } + + public void setWildcardWithParams(@Nullable String wildcardWithParams) { + this.wildcardWithParams = wildcardWithParams; + } } - @Data @Document(indexName = "disabled-entity-mapping") @Mapping(enabled = false) static class DisabledMappingEntity { - @Id private String id; - @Field(type = Text) private String text; + @Nullable @Id private String id; + @Nullable @Field(type = Text) private String text; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } } - @Data @Document(indexName = "disabled-property-mapping") static class DisabledMappingProperty { - @Id private String id; - @Field(type = Text) private String text; - @Mapping(enabled = false) @Field(type = Object) private Object object; + @Nullable @Id private String id; + @Nullable @Field(type = Text) private String text; + @Nullable @Mapping(enabled = false) @Field(type = Object) private Object object; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public java.lang.Object getObject() { + return object; + } + + public void setObject(@Nullable java.lang.Object object) { + this.object = object; + } } - @Data @Document(indexName = "densevector-test") static class DenseVectorEntity { - @Id private String id; - @Field(type = Dense_Vector, dims = 3) private float[] dense_vector; + @Nullable @Id private String id; + @Nullable @Field(type = Dense_Vector, dims = 3) private float[] dense_vector; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public float[] getDense_vector() { + return dense_vector; + } + + public void setDense_vector(@Nullable float[] dense_vector) { + this.dense_vector = dense_vector; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java index fc92ec0d6..66c1d57a0 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderUnitTests.java @@ -21,13 +21,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.annotations.FieldType.Object; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.lang.Boolean; import java.lang.Double; import java.lang.Integer; @@ -649,19 +642,31 @@ void shouldMapAccordingToTheAnnotatedProperties() throws JSONException { assertEquals(expected, mapping, false); } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "ignore-above-index") static class IgnoreAboveEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message; - @Id private String id; + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } - @Field(type = FieldType.Keyword, ignoreAbove = 10) private String message; + public void setMessage(@Nullable String message) { + this.message = message; + } } + static class FieldNameEntity { @Document(indexName = "fieldname-index") @@ -726,68 +731,168 @@ static class MultiFieldEntity { } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-mapping-builder", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - @Data @Document(indexName = "test-index-simple-recursive-mapping-builder", replicas = 0, refreshInterval = "-1") static class SimpleRecursiveEntity { - @Nullable @Id private String id; @Nullable @Field(type = FieldType.Object, ignoreFields = { "circularObject" }) private SimpleRecursiveEntity circularObject; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public SimpleRecursiveEntity getCircularObject() { + return circularObject; + } + + public void setCircularObject(@Nullable SimpleRecursiveEntity circularObject) { + this.circularObject = circularObject; + } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-copy-to-mapping-builder", replicas = 0, refreshInterval = "-1") static class CopyToEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String firstName; + @Nullable @Field(type = FieldType.Keyword, copyTo = "name") private String lastName; + @Nullable @Field(type = FieldType.Keyword) private String name; - @Id private String id; + @Nullable + public String getId() { + return id; + } - @Field(type = FieldType.Keyword, copyTo = "name") private String firstName; + public void setId(@Nullable String id) { + this.id = id; + } - @Field(type = FieldType.Keyword, copyTo = "name") private String lastName; + @Nullable + public String getFirstName() { + return firstName; + } - @Field(type = FieldType.Keyword) private String name; + public void setFirstName(@Nullable String firstName) { + this.firstName = firstName; + } + + @Nullable + public String getLastName() { + return lastName; + } + + public void setLastName(@Nullable String lastName) { + this.lastName = lastName; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-normalizer-mapping-builder", replicas = 0, refreshInterval = "-1") @Setting(settingPath = "/settings/test-normalizer.json") static class NormalizerEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name; + @Nullable @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case", + type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description; + + @Nullable + public String getId() { + return id; + } - @Id private String id; + public void setId(@Nullable String id) { + this.id = id; + } - @Field(type = FieldType.Keyword, normalizer = "lower_case_normalizer") private String name; + @Nullable + public String getName() { + return name; + } - @MultiField(mainField = @Field(type = FieldType.Text), otherFields = { @InnerField(suffix = "lower_case", - type = FieldType.Keyword, normalizer = "lower_case_normalizer") }) private String description; + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } static class Author { - @Nullable private String id; @Nullable private String name; @@ -825,19 +930,38 @@ public void setMessage(String message) { } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-stock-mapping-builder", replicas = 0, refreshInterval = "-1") static class StockPrice { + @Nullable @Id private String id; + @Nullable private String symbol; + @Nullable @Field(type = FieldType.Double) private BigDecimal price; - @Id private String id; + @Nullable + public String getId() { + return id; + } - private String symbol; + public void setId(@Nullable String id) { + this.id = id; + } - @Field(type = FieldType.Double) private BigDecimal price; + @Nullable + public String getSymbol() { + return symbol; + } + + public void setSymbol(@Nullable String symbol) { + this.symbol = symbol; + } + + @Nullable + public BigDecimal getPrice() { + return price; + } + + public void setPrice(@Nullable BigDecimal price) { + this.price = price; + } } static class AbstractInheritedEntity { @@ -916,31 +1040,112 @@ public void setSomething(Boolean something) { } } - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-geo-mapping-builder", replicas = 0, refreshInterval = "-1") static class GeoEntity { - - @Id private String id; - + @Nullable @Id private String id; // geo shape - Spring Data - private Box box; - private Circle circle; - private Polygon polygon; - + @Nullable private Box box; + @Nullable private Circle circle; + @Nullable private Polygon polygon; // geo point - Custom implementation + Spring Data - @GeoPointField private Point pointA; - private GeoPoint pointB; - @GeoPointField private String pointC; - @GeoPointField private double[] pointD; - + @Nullable @GeoPointField private Point pointA; + @Nullable private GeoPoint pointB; + @Nullable @GeoPointField private String pointC; + @Nullable @GeoPointField private double[] pointD; // geo shape, until e have the classes for this, us a strng - @GeoShapeField private String shape1; - @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false, + @Nullable @GeoShapeField private String shape1; + @Nullable @GeoShapeField(coerce = true, ignoreMalformed = true, ignoreZValue = false, orientation = GeoShapeField.Orientation.clockwise) private String shape2; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public Box getBox() { + return box; + } + + public void setBox(@Nullable Box box) { + this.box = box; + } + + @Nullable + public Circle getCircle() { + return circle; + } + + public void setCircle(@Nullable Circle circle) { + this.circle = circle; + } + + @Nullable + public Polygon getPolygon() { + return polygon; + } + + public void setPolygon(@Nullable Polygon polygon) { + this.polygon = polygon; + } + + @Nullable + public Point getPointA() { + return pointA; + } + + public void setPointA(@Nullable Point pointA) { + this.pointA = pointA; + } + + @Nullable + public GeoPoint getPointB() { + return pointB; + } + + public void setPointB(@Nullable GeoPoint pointB) { + this.pointB = pointB; + } + + @Nullable + public String getPointC() { + return pointC; + } + + public void setPointC(@Nullable String pointC) { + this.pointC = pointC; + } + + @Nullable + public double[] getPointD() { + return pointD; + } + + public void setPointD(@Nullable double[] pointD) { + this.pointD = pointD; + } + + @Nullable + public String getShape1() { + return shape1; + } + + public void setShape1(@Nullable String shape1) { + this.shape1 = shape1; + } + + @Nullable + public String getShape2() { + return shape2; + } + + public void setShape2(@Nullable String shape2) { + this.shape2 = shape2; + } } @Document(indexName = "test-index-field-mapping-parameters") @@ -1022,94 +1227,309 @@ static class ValueDoc { @Nullable @Field(type = Text) private ValueObject valueObject; } - @Getter - @Setter @Document(indexName = "completion") static class CompletionDocument { - @Id private String id; - - @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO, + @Nullable @Id private String id; + @Nullable @CompletionField(contexts = { @CompletionContext(name = "location", type = ContextMapping.Type.GEO, path = "proppath") }) private Completion suggest; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public Completion getSuggest() { + return suggest; + } + + public void setSuggest(@Nullable Completion suggest) { + this.suggest = suggest; + } } - @Data @Document(indexName = "test-index-entity-with-seq-no-primary-term-mapping-builder") static class EntityWithSeqNoPrimaryTerm { - @Field(type = Object) private SeqNoPrimaryTerm seqNoPrimaryTerm; + + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } } - @Data static class RankFeatureEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Rank_Feature) private Integer pageRank; + @Nullable @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength; + @Nullable @Field(type = FieldType.Rank_Features) private Map topics; - @Id private String id; - @Field(type = FieldType.Rank_Feature) private Integer pageRank; - @Field(type = FieldType.Rank_Feature, positiveScoreImpact = false) private Integer urlLength; - @Field(type = FieldType.Rank_Features) private Map topics; + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public java.lang.Integer getPageRank() { + return pageRank; + } + + public void setPageRank(@Nullable java.lang.Integer pageRank) { + this.pageRank = pageRank; + } + + @Nullable + public java.lang.Integer getUrlLength() { + return urlLength; + } + + public void setUrlLength(@Nullable java.lang.Integer urlLength) { + this.urlLength = urlLength; + } + + @Nullable + public Map getTopics() { + return topics; + } + + public void setTopics(@Nullable Map topics) { + this.topics = topics; + } } - @Data static class DenseVectorEntity { + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Dense_Vector, dims = 16) private float[] my_vector; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } - @Id private String id; - @Field(type = FieldType.Dense_Vector, dims = 16) private float[] my_vector; + @Nullable + public float[] getMy_vector() { + return my_vector; + } + + public void setMy_vector(@Nullable float[] my_vector) { + this.my_vector = my_vector; + } } - @Data @Mapping(enabled = false) static class DisabledMappingEntity { - @Id private String id; - @Field(type = Text) private String text; + @Nullable @Id private String id; + @Nullable @Field(type = Text) private String text; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } } - @Data static class InvalidDisabledMappingProperty { - @Id private String id; - @Mapping(enabled = false) @Field(type = Text) private String text; + @Nullable @Id private String id; + @Nullable @Mapping(enabled = false) @Field(type = Text) private String text; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } } - @Data static class DisabledMappingProperty { - @Id private String id; - @Field(type = Text) private String text; - @Mapping(enabled = false) @Field(type = Object) private Object object; + @Nullable @Id private String id; + @Nullable @Field(type = Text) private String text; + @Nullable @Mapping(enabled = false) @Field(type = Object) private Object object; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public java.lang.Object getObject() { + return object; + } + + public void setObject(@Nullable java.lang.Object object) { + this.object = object; + } } - @Data - @AllArgsConstructor - @NoArgsConstructor static class TypeHintEntity { - @Id @Field(type = Keyword) private String id; + @Nullable @Id @Field(type = Keyword) private String id; + @Nullable @Field(type = Nested) private NestedEntity nestedEntity; + @Nullable @Field(type = Object) private ObjectEntity objectEntity; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public NestedEntity getNestedEntity() { + return nestedEntity; + } + + public void setNestedEntity(@Nullable NestedEntity nestedEntity) { + this.nestedEntity = nestedEntity; + } - @Field(type = Nested) private NestedEntity nestedEntity; + @Nullable + public ObjectEntity getObjectEntity() { + return objectEntity; + } - @Field(type = Object) private ObjectEntity objectEntity; + public void setObjectEntity(@Nullable ObjectEntity objectEntity) { + this.objectEntity = objectEntity; + } - @Data static class NestedEntity { - @Field(type = Text) private String nestedField; + @Nullable @Field(type = Text) private String nestedField; + + @Nullable + public String getNestedField() { + return nestedField; + } + + public void setNestedField(@Nullable String nestedField) { + this.nestedField = nestedField; + } } - @Data static class ObjectEntity { - @Field(type = Text) private String objectField; + @Nullable @Field(type = Text) private String objectField; + + @Nullable + public String getObjectField() { + return objectField; + } + + public void setObjectField(@Nullable String objectField) { + this.objectField = objectField; + } } } - @Data - @AllArgsConstructor - @NoArgsConstructor static class DateFormatsEntity { - @Id private String id; - @Field(type = FieldType.Date) private LocalDateTime field1; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Date) private LocalDateTime field1; + @Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime field2; + @Nullable @Field(type = FieldType.Date, format = { DateFormat.basic_date, DateFormat.basic_time }) private LocalDateTime field3; + @Nullable @Field(type = FieldType.Date, pattern = "dd.MM.uuuu") private LocalDateTime field4; + @Nullable @Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") private LocalDateTime field5; - @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime field2; + @Nullable + public String getId() { + return id; + } - @Field(type = FieldType.Date, - format = { DateFormat.basic_date, DateFormat.basic_time }) private LocalDateTime field3; + public void setId(@Nullable String id) { + this.id = id; + } - @Field(type = FieldType.Date, pattern = "dd.MM.uuuu") private LocalDateTime field4; + @Nullable + public LocalDateTime getField1() { + return field1; + } - @Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") private LocalDateTime field5; + public void setField1(@Nullable LocalDateTime field1) { + this.field1 = field1; + } + + @Nullable + public LocalDateTime getField2() { + return field2; + } + + public void setField2(@Nullable LocalDateTime field2) { + this.field2 = field2; + } + + @Nullable + public LocalDateTime getField3() { + return field3; + } + + public void setField3(@Nullable LocalDateTime field3) { + this.field3 = field3; + } + + @Nullable + public LocalDateTime getField4() { + return field4; + } + + public void setField4(@Nullable LocalDateTime field4) { + this.field4 = field4; + } + + @Nullable + public LocalDateTime getField5() { + return field5; + } + + public void setField5(@Nullable LocalDateTime field5) { + this.field5 = field5; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/SimpleElasticsearchDateMappingTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/SimpleElasticsearchDateMappingTests.java index f8ab2aed0..e974e76bd 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/SimpleElasticsearchDateMappingTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/SimpleElasticsearchDateMappingTests.java @@ -18,8 +18,6 @@ import static org.skyscreamer.jsonassert.JSONAssert.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Data; - import java.time.LocalDateTime; import org.json.JSONException; @@ -30,6 +28,7 @@ import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.core.MappingContextBaseTests; +import org.springframework.lang.Nullable; /** * @author Jakub Vavrik @@ -52,19 +51,47 @@ public void testCorrectDateMappings() throws JSONException { assertEquals(EXPECTED_MAPPING, mapping, false); } - /** - * @author Jakub Vavrik - */ - @Data @Document(indexName = "test-index-date-mapping-core", replicas = 0, refreshInterval = "-1") static class SampleDateMappingEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, index = false, store = true, analyzer = "standard") private String message; + @Nullable @Field(type = Date, format = {}, pattern = "dd.MM.uuuu hh:mm") private LocalDateTime customFormatDate; + @Nullable @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime basicFormatDate; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } - @Id private String id; + @Nullable + public LocalDateTime getCustomFormatDate() { + return customFormatDate; + } - @Field(type = Text, index = false, store = true, analyzer = "standard") private String message; + public void setCustomFormatDate(@Nullable LocalDateTime customFormatDate) { + this.customFormatDate = customFormatDate; + } - @Field(type = Date, format = {}, pattern = "dd.MM.uuuu hh:mm") private LocalDateTime customFormatDate; + @Nullable + public LocalDateTime getBasicFormatDate() { + return basicFormatDate; + } - @Field(type = FieldType.Date, format = DateFormat.basic_date) private LocalDateTime basicFormatDate; + public void setBasicFormatDate(@Nullable LocalDateTime basicFormatDate) { + this.basicFormatDate = basicFormatDate; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/EntityCustomConversionIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/EntityCustomConversionIntegrationTests.java index 900af4ac4..c64b2d597 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/EntityCustomConversionIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/EntityCustomConversionIntegrationTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Arrays; import java.util.LinkedHashMap; import java.util.Map; @@ -45,6 +40,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -84,10 +80,9 @@ void tearDown() { @DisplayName("should use CustomConversions on entity") void shouldUseCustomConversionsOnEntity() { - Entity entity = Entity.builder() // - .value("hello") // - .location(GeoJsonPoint.of(8.0, 42.7)) // - .build(); + Entity entity = new Entity(); + entity.setValue("hello"); // + entity.setLocation(GeoJsonPoint.of(8.0, 42.7)); org.springframework.data.elasticsearch.core.document.Document document = org.springframework.data.elasticsearch.core.document.Document .create(); @@ -102,10 +97,9 @@ void shouldUseCustomConversionsOnEntity() { @DisplayName("should store and load entity from Elasticsearch") void shouldStoreAndLoadEntityFromElasticsearch() { - Entity entity = Entity.builder() // - .value("hello") // - .location(GeoJsonPoint.of(8.0, 42.7)) // - .build(); + Entity entity = new Entity(); + entity.setValue("hello"); // + entity.setLocation(GeoJsonPoint.of(8.0, 42.7)); Entity savedEntity = operations.save(entity); @@ -115,14 +109,49 @@ void shouldStoreAndLoadEntityFromElasticsearch() { assertThat(foundEntity).isEqualTo(entity); } - @Data - @Builder - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "entity-with-custom-conversions") static class Entity { - private String value; - private GeoJsonPoint location; + @Nullable private String value; + @Nullable private GeoJsonPoint location; + + @Nullable + public String getValue() { + return value; + } + + public void setValue(@Nullable String value) { + this.value = value; + } + + @Nullable + public GeoJsonPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoJsonPoint location) { + this.location = location; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Entity)) + return false; + + Entity entity = (Entity) o; + + if (value != null ? !value.equals(entity.value) : entity.value != null) + return false; + return location != null ? location.equals(entity.location) : entity.location == null; + } + + @Override + public int hashCode() { + int result = value != null ? value.hashCode() : 0; + result = 31 * result + (location != null ? location.hashCode() : 0); + return result; + } } @WritingConverter diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationReactiveTest.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationReactiveTest.java index 2fc442696..510c7734b 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationReactiveTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationReactiveTest.java @@ -15,11 +15,9 @@ */ package org.springframework.data.elasticsearch.core.mapping; -import static org.assertj.core.api.Assertions.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import lombok.Builder; -import lombok.Data; +import reactor.test.StepVerifier; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -32,15 +30,14 @@ import org.springframework.data.elasticsearch.annotations.FieldType; import org.springframework.data.elasticsearch.core.ReactiveElasticsearchOperations; import org.springframework.data.elasticsearch.core.ReactiveIndexOperations; -import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.mapping.model.FieldNamingStrategy; import org.springframework.data.mapping.model.SnakeCaseFieldNamingStrategy; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; -import reactor.test.StepVerifier; /** * @author Peter-Josef Meisch @@ -73,7 +70,9 @@ void setUp() { @DisplayName("should use configured FieldNameStrategy") void shouldUseConfiguredFieldNameStrategy() { - Entity entity = new Entity.EntityBuilder().id("42").someText("the text to be searched").build(); + Entity entity = new Entity(); + entity.setId("42"); + entity.setSomeText("the text to be searched"); operations.save(entity).block(); // use a native query here to prevent automatic property name matching @@ -84,11 +83,27 @@ void shouldUseConfiguredFieldNameStrategy() { .verifyComplete(); } - @Data - @Builder @Document(indexName = "field-naming-strategy-test") static class Entity { - @Id private String id; - @Field(type = FieldType.Text) private String someText; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text) private String someText; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getSomeText() { + return someText; + } + + public void setSomeText(@Nullable String someText) { + this.someText = someText; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationTest.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationTest.java index cbb589a78..9690ebb82 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/FieldNamingStrategyIntegrationTest.java @@ -18,9 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import lombok.Builder; -import lombok.Data; - import org.elasticsearch.client.RestHighLevelClient; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -42,6 +39,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.mapping.model.FieldNamingStrategy; import org.springframework.data.mapping.model.SnakeCaseFieldNamingStrategy; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -81,7 +79,9 @@ void setUp() { @DisplayName("should use configured FieldNameStrategy") void shouldUseConfiguredFieldNameStrategy() { - Entity entity = new Entity.EntityBuilder().id("42").someText("the text to be searched").build(); + Entity entity = new Entity(); + entity.setId("42"); + entity.setSomeText("the text to be searched"); operations.save(entity); // use a native query here to prevent automatic property name matching @@ -91,11 +91,27 @@ void shouldUseConfiguredFieldNameStrategy() { assertThat(searchHits.getTotalHits()).isEqualTo(1); } - @Data - @Builder @Document(indexName = "field-naming-strategy-test") static class Entity { - @Id private String id; - @Field(type = FieldType.Text) private String someText; + @Nullable @Id private String id; + @Nullable @Field(type = FieldType.Text) private String someText; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getSomeText() { + return someText; + } + + public void setSomeText(@Nullable String someText) { + this.someText = someText; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java index 46f529aba..fd9a76092 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; - import java.time.LocalDate; import java.time.LocalDateTime; import java.time.ZoneId; @@ -264,30 +262,61 @@ static class DatesProperty { @Nullable @Field(type = FieldType.Date, format = {}, pattern = "dd.MM.uuuu") List localDateList; } - @Data static class SeqNoPrimaryTermProperty { - SeqNoPrimaryTerm seqNoPrimaryTerm; - String string; - } - - @Data - static class DateFieldWithNoFormat { - @Field(type = FieldType.Date) LocalDateTime datetime; + @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; + @Nullable private String string; + + @Nullable + public SeqNoPrimaryTerm getSeqNoPrimaryTerm() { + return seqNoPrimaryTerm; + } + + public void setSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) { + this.seqNoPrimaryTerm = seqNoPrimaryTerm; + } + + @Nullable + public String getString() { + return string; + } + + public void setString(@Nullable String string) { + this.string = string; + } } - @Data static class DateFieldWithCustomFormatAndNoPattern { - @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "") LocalDateTime datetime; - } + @Nullable private @Field(type = FieldType.Date, format = DateFormat.custom, pattern = "") LocalDateTime datetime; + + @Nullable + public LocalDateTime getDatetime() { + return datetime; + } - @Data - static class DateNanosFieldWithNoFormat { - @Field(type = FieldType.Date_Nanos) LocalDateTime datetime; + public void setDatetime(@Nullable LocalDateTime datetime) { + this.datetime = datetime; + } } - @Data static class FieldNamingStrategyEntity { - private String withoutCustomFieldName; + @Nullable private String withoutCustomFieldName; @Field(name = "CUStomFIEldnAME") private String withCustomFieldName; + + @Nullable + public String getWithoutCustomFieldName() { + return withoutCustomFieldName; + } + + public void setWithoutCustomFieldName(@Nullable String withoutCustomFieldName) { + this.withoutCustomFieldName = withoutCustomFieldName; + } + + public String getWithCustomFieldName() { + return withCustomFieldName; + } + + public void setWithCustomFieldName(String withCustomFieldName) { + this.withCustomFieldName = withCustomFieldName; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/paginating/ReactiveSearchAfterIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/paginating/ReactiveSearchAfterIntegrationTests.java index 43c2ba1ae..08809d1b9 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/paginating/ReactiveSearchAfterIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/paginating/ReactiveSearchAfterIntegrationTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; import reactor.core.publisher.Mono; import java.util.ArrayList; @@ -42,6 +38,7 @@ import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -57,8 +54,8 @@ public class ReactiveSearchAfterIntegrationTests { @DisplayName("should read pages with search_after") void shouldReadPagesWithSearchAfter() { - List entities = IntStream.rangeClosed(1, 10) - .mapToObj(i -> Entity.builder().id((long) i).message("message " + i).build()).collect(Collectors.toList()); + List entities = IntStream.rangeClosed(1, 10).mapToObj(i -> new Entity((long) i, "message " + i)) + .collect(Collectors.toList()); operations.saveAll(Mono.just(entities), Entity.class).blockLast(); Query query = Query.findAll(); @@ -87,14 +84,54 @@ void shouldReadPagesWithSearchAfter() { assertThat(foundEntities).containsExactlyElementsOf(entities); } - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder @Document(indexName = "test-search-after") private static class Entity { - @Id private Long id; - @Field(type = FieldType.Text) private String message; + @Nullable @Id private Long id; + @Nullable @Field(type = FieldType.Text) private String message; + + public Entity(@Nullable Long id, @Nullable String message) { + this.id = id; + this.message = message; + } + + @Nullable + public Long getId() { + return id; + } + + public void setId(@Nullable Long id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Entity)) + return false; + + Entity entity = (Entity) o; + + if (id != null ? !id.equals(entity.id) : entity.id != null) + return false; + return message != null ? message.equals(entity.message) : entity.message == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (message != null ? message.hashCode() : 0); + return result; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/paginating/SearchAfterIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/paginating/SearchAfterIntegrationTests.java index 120d2bf54..8894954a2 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/paginating/SearchAfterIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/paginating/SearchAfterIntegrationTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -41,6 +36,7 @@ import org.springframework.data.elasticsearch.core.query.Query; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -56,8 +52,8 @@ public class SearchAfterIntegrationTests { @DisplayName("should read pages with search_after") void shouldReadPagesWithSearchAfter() { - List entities = IntStream.rangeClosed(1, 10) - .mapToObj(i -> Entity.builder().id((long) i).message("message " + i).build()).collect(Collectors.toList()); + List entities = IntStream.rangeClosed(1, 10).mapToObj(i -> new Entity((long) i, "message " + i)) + .collect(Collectors.toList()); operations.save(entities); Query query = Query.findAll(); @@ -86,13 +82,53 @@ void shouldReadPagesWithSearchAfter() { assertThat(foundEntities).containsExactlyElementsOf(entities); } - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder @Document(indexName = "test-search-after") private static class Entity { - @Id private Long id; - @Field(type = FieldType.Text) private String message; + @Nullable @Id private Long id; + @Nullable @Field(type = FieldType.Text) private String message; + + public Entity(@Nullable Long id, @Nullable String message) { + this.id = id; + this.message = message; + } + + @Nullable + public Long getId() { + return id; + } + + public void setId(@Nullable Long id) { + this.id = id; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof Entity)) + return false; + + Entity entity = (Entity) o; + + if (id != null ? !id.equals(entity.id) : entity.id != null) + return false; + return message != null ? message.equals(entity.message) : entity.message == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (message != null ? message.hashCode() : 0); + return result; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryIntegrationTests.java index 19fdf6cb0..67c0199a2 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/query/CriteriaQueryIntegrationTests.java @@ -20,12 +20,6 @@ import static org.springframework.data.elasticsearch.utils.IdGenerator.*; import static org.springframework.data.elasticsearch.utils.IndexBuilder.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.lang.Long; import java.util.ArrayList; import java.util.List; @@ -47,6 +41,7 @@ import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.junit.jupiter.ElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -761,23 +756,18 @@ public void shouldPerformBoostOperation() { @Test public void shouldReturnDocumentAboveMinimalScoreGivenCriteria() { - // given List indexQueries = new ArrayList<>(); - - indexQueries.add(buildIndex(SampleEntity.builder().id("1").message("ab").build())); - indexQueries.add(buildIndex(SampleEntity.builder().id("2").message("bc").build())); - indexQueries.add(buildIndex(SampleEntity.builder().id("3").message("ac").build())); - + indexQueries.add(buildIndex(new SampleEntity("1", "ab"))); + indexQueries.add(buildIndex(new SampleEntity("2", "bc"))); + indexQueries.add(buildIndex(new SampleEntity("3", "ac"))); operations.bulkIndex(indexQueries, index); indexOperations.refresh(); - // when CriteriaQuery criteriaQuery = new CriteriaQuery( new Criteria("message").contains("a").or(new Criteria("message").contains("b"))); criteriaQuery.setMinScore(2.0F); SearchHits searchHits = operations.search(criteriaQuery, SampleEntity.class, index); - // then assertThat(searchHits.getTotalHits()).isEqualTo(1); assertThat(searchHits.getSearchHit(0).getContent().getMessage()).isEqualTo("ab"); } @@ -807,18 +797,65 @@ public void shouldEscapeValue() { assertThat(sampleEntity1).isNotNull(); } - @Builder - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "test-index-sample-core-query", replicas = 0, refreshInterval = "-1") static class SampleEntity { - + @Nullable @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - @Version private Long version; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @Version private Long version; + + public SampleEntity() { + } + + public SampleEntity(@Nullable String id, @Nullable String message) { + this.id = id; + this.message = message; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/routing/DefaultRoutingResolverUnitTest.java b/src/test/java/org/springframework/data/elasticsearch/core/routing/DefaultRoutingResolverUnitTest.java index e34f6367c..707da7b3d 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/routing/DefaultRoutingResolverUnitTest.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/routing/DefaultRoutingResolverUnitTest.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -94,34 +90,94 @@ void shouldReturnRoutingFromSpElExpression() { assertThat(routing).isEqualTo("route 42"); } - @Data - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "routing-resolver-test") @Routing("theRouting") static class ValidRoutingEntity { - @Id private String id; - private String theRouting; + @Nullable @Id private String id; + @Nullable private String theRouting; + + public ValidRoutingEntity(@Nullable String id, @Nullable String theRouting) { + this.id = id; + this.theRouting = theRouting; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getTheRouting() { + return theRouting; + } + + public void setTheRouting(@Nullable String theRouting) { + this.theRouting = theRouting; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "routing-resolver-test") @Routing(value = "@spelRouting.getRouting(#entity)") static class ValidSpelRoutingEntity { - @Id private String id; - private String theRouting; + @Nullable @Id private String id; + @Nullable private String theRouting; + + public ValidSpelRoutingEntity(@Nullable String id, @Nullable String theRouting) { + this.id = id; + this.theRouting = theRouting; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getTheRouting() { + return theRouting; + } + + public void setTheRouting(@Nullable String theRouting) { + this.theRouting = theRouting; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor @Document(indexName = "routing-resolver-test") @Routing("unknownProperty") static class InvalidRoutingEntity { - @Id private String id; - private String theRouting; + @Nullable @Id private String id; + @Nullable private String theRouting; + + public InvalidRoutingEntity(@Nullable String id, @Nullable String theRouting) { + this.id = id; + this.theRouting = theRouting; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getTheRouting() { + return theRouting; + } + + public void setTheRouting(@Nullable String theRouting) { + this.theRouting = theRouting; + } } static class SpelRouting { diff --git a/src/test/java/org/springframework/data/elasticsearch/core/routing/ElasticsearchOperationsRoutingTests.java b/src/test/java/org/springframework/data/elasticsearch/core/routing/ElasticsearchOperationsRoutingTests.java index 06b16ae2e..db6f99a1c 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/routing/ElasticsearchOperationsRoutingTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/routing/ElasticsearchOperationsRoutingTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.function.Function; import org.elasticsearch.cluster.routing.Murmur3HashFunction; @@ -86,7 +81,7 @@ void setUp() { @DisplayName("should store data with different routing and be able to get it") void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity); indexOps.refresh(); @@ -99,7 +94,7 @@ void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() { @DisplayName("should store data with different routing and be able to delete it") void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity); indexOps.refresh(); @@ -112,7 +107,7 @@ void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() { @DisplayName("should store data with different routing and get the routing in the search result") void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity); indexOps.refresh(); @@ -122,14 +117,54 @@ void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() { assertThat(searchHits.getSearchHit(0).getRouting()).isEqualTo(ID_2); } - @Data - @Builder - @AllArgsConstructor - @NoArgsConstructor @Document(indexName = INDEX, shards = 5) @Routing("routing") static class RoutingEntity { - @Id private String id; - private String routing; + @Nullable @Id private String id; + @Nullable private String routing; + + public RoutingEntity(@Nullable String id, @Nullable String routing) { + this.id = id; + this.routing = routing; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getRouting() { + return routing; + } + + public void setRouting(@Nullable String routing) { + this.routing = routing; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof RoutingEntity)) + return false; + + RoutingEntity that = (RoutingEntity) o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + return routing != null ? routing.equals(that.routing) : that.routing == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (routing != null ? routing.hashCode() : 0); + return result; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/routing/ReactiveElasticsearchOperationsRoutingTests.java b/src/test/java/org/springframework/data/elasticsearch/core/routing/ReactiveElasticsearchOperationsRoutingTests.java index 6ed02cb8c..84ae0b713 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/routing/ReactiveElasticsearchOperationsRoutingTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/routing/ReactiveElasticsearchOperationsRoutingTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.List; import java.util.function.Function; @@ -84,7 +79,7 @@ void setUp() { @DisplayName("should store data with different routing and be able to get it") void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity).then(indexOps.refresh()).block(); RoutingEntity savedEntity = operations.withRouting(RoutingResolver.just(ID_2)).get(entity.id, RoutingEntity.class) @@ -97,7 +92,7 @@ void shouldStoreDataWithDifferentRoutingAndBeAbleToGetIt() { @DisplayName("should store data with different routing and be able to delete it") void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity).then(indexOps.refresh()).block(); String deletedId = operations.withRouting(RoutingResolver.just(ID_2)).delete(entity.id, IndexCoordinates.of(INDEX)) @@ -110,7 +105,7 @@ void shouldStoreDataWithDifferentRoutingAndBeAbleToDeleteIt() { @DisplayName("should store data with different routing and get the routing in the search result") void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() { - RoutingEntity entity = RoutingEntity.builder().id(ID_1).routing(ID_2).build(); + RoutingEntity entity = new RoutingEntity(ID_1, ID_2); operations.save(entity).then(indexOps.refresh()).block(); List> searchHits = operations.search(Query.findAll(), RoutingEntity.class).collectList() @@ -120,14 +115,54 @@ void shouldStoreDataWithDifferentRoutingAndGetTheRoutingInTheSearchResult() { assertThat(searchHits.get(0).getRouting()).isEqualTo(ID_2); } - @Data - @Builder - @AllArgsConstructor - @NoArgsConstructor @Document(indexName = INDEX, shards = 5) @Routing("routing") static class RoutingEntity { - @Id private String id; - private String routing; + @Nullable @Id private String id; + @Nullable private String routing; + + public RoutingEntity(@Nullable String id, @Nullable String routing) { + this.id = id; + this.routing = routing; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getRouting() { + return routing; + } + + public void setRouting(@Nullable String routing) { + this.routing = routing; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof RoutingEntity)) + return false; + + RoutingEntity that = (RoutingEntity) o; + + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + return routing != null ? routing.equals(that.routing) : that.routing == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (routing != null ? routing.hashCode() : 0); + return result; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepository.java b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepository.java deleted file mode 100644 index 1655a4f50..000000000 --- a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepository.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2016-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.elasticsearch.immutable; - -import org.springframework.data.repository.CrudRepository; - -/** - * @author Young Gu - * @author Oliver Gierke - */ -public interface ImmutableElasticsearchRepository extends CrudRepository {} diff --git a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java index 07fae2322..1f1b15666 100644 --- a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableElasticsearchRepositoryTests.java @@ -17,9 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Getter; -import lombok.NoArgsConstructor; - import java.util.Optional; import org.junit.jupiter.api.AfterEach; @@ -95,16 +92,21 @@ public void shouldSaveAndFindImmutableDocument() { * @author Oliver Gierke */ @Document(indexName = "test-index-immutable") - @NoArgsConstructor(force = true) - @Getter static class ImmutableEntity { private final String id, name; public ImmutableEntity(String name) { - this.id = null; this.name = name; } + + public String getId() { + return id; + } + + public String getName() { + return name; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableEntity.java b/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableEntity.java deleted file mode 100644 index 3746397fd..000000000 --- a/src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableEntity.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2013-2021 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.data.elasticsearch.immutable; - -import lombok.Getter; -import lombok.NoArgsConstructor; - -import org.springframework.data.elasticsearch.annotations.Document; - -/** - * @author Young Gu - * @author Oliver Gierke - */ -@Document(indexName = "test-index-immutable") -@NoArgsConstructor(force = true) -@Getter -public class ImmutableEntity { - private final String id, name; - - public ImmutableEntity(String name) { - - this.id = null; - this.name = name; - } -} diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/CdiRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/CdiRepositoryTests.java index 53ec4aa9d..f23ac8158 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/CdiRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/cdi/CdiRepositoryTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -157,39 +152,129 @@ public void returnOneFromCustomImpl() { * @author Mohsin Husen * @author Artur Konczak */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-product-cdi-repository", replicas = 0, refreshInterval = "-1") static class Product { - - @Id private String id; - - private List title; - - private String name; - - private String description; - - private String text; - - private List categories; - - private Float weight; - - @Field(type = FieldType.Float) private Float price; - - private Integer popularity; - - private boolean available; - - private String location; - - private Date lastModified; + @Nullable @Id private String id; + @Nullable private List title; + @Nullable private String name; + @Nullable private String description; + @Nullable private String text; + @Nullable private List categories; + @Nullable private Float weight; + @Nullable @Field(type = FieldType.Float) private Float price; + @Nullable private Integer popularity; + @Nullable private boolean available; + @Nullable private String location; + @Nullable private Date lastModified; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public List getTitle() { + return title; + } + + public void setTitle(@Nullable List title) { + this.title = title; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public List getCategories() { + return categories; + } + + public void setCategories(@Nullable List categories) { + this.categories = categories; + } + + @Nullable + public Float getWeight() { + return weight; + } + + public void setWeight(@Nullable Float weight) { + this.weight = weight; + } + + @Nullable + public Float getPrice() { + return price; + } + + public void setPrice(@Nullable Float price) { + this.price = price; + } + + @Nullable + public Integer getPopularity() { + return popularity; + } + + public void setPopularity(@Nullable Integer popularity) { + this.popularity = popularity; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public String getLocation() { + return location; + } + + public void setLocation(@Nullable String location) { + this.location = location; + } + + @Nullable + public Date getLastModified() { + return lastModified; + } + + public void setLastModified(@Nullable Date lastModified) { + this.lastModified = lastModified; + } } - @Data @Document(indexName = "test-index-person-cdi-repository", replicas = 0, refreshInterval = "-1") static class Person { @@ -203,37 +288,106 @@ static class Person { } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-cdi-repository", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder static class Car { - - private String name; - private String model; + @Nullable private String name; + @Nullable private String model; + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getModel() { + return model; + } + + public void setModel(@Nullable String model) { + this.model = model; + } } - @Data static class Author { - - private String id; - private String name; + @Nullable private String id; + @Nullable private String name; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java index 4126a2c83..b5b0015b5 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/autowiring/ComplexCustomMethodRepositoryTests.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Data; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,6 +33,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -80,14 +79,40 @@ public void shouldExecuteComplexCustomMethod() { assertThat(result).isEqualTo("2+2=4"); } - @Data @Document(indexName = "test-index-sample-repositories-complex-custommethod-autowiring", replicas = 0, refreshInterval = "-1") static class SampleEntity { - + @Nullable @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexCustomMethodRepositoryManualWiringTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexCustomMethodRepositoryManualWiringTests.java index 75c46a4e6..9a68942f0 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexCustomMethodRepositoryManualWiringTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/complex/custommethod/manualwiring/ComplexCustomMethodRepositoryManualWiringTests.java @@ -18,8 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.Data; - import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -35,6 +33,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -78,12 +77,37 @@ public void shouldExecuteComplexCustomMethod() { assertThat(result).isEqualTo("3+3=6"); } - @Data @Document(indexName = "test-index-sample-repository-manual-wiring", replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; + public void setMessage(@Nullable String message) { + this.message = message; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java index 3eecaf2b5..e8fe1d60c 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/custommethod/CustomMethodRepositoryBaseTests.java @@ -19,11 +19,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.lang.Long; import java.util.ArrayList; import java.util.Arrays; @@ -66,6 +61,7 @@ import org.springframework.data.geo.Distance; import org.springframework.data.geo.Metrics; import org.springframework.data.geo.Point; +import org.springframework.lang.Nullable; /** * @author Rizwan Idrees @@ -1635,21 +1631,87 @@ void shouldStreamSearchHitsWithQueryAnnotatedMethod() { assertThat(count).isEqualTo(20); } - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-sample-repositories-custom-method", replicas = 0, refreshInterval = "-1") static class SampleEntity { - + @Nullable @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - @Field(type = Keyword) private String keyword; - private int rate; - private boolean available; - private GeoPoint location; - @Version private Long version; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable @Field(type = Keyword) private String keyword; + @Nullable private int rate; + @Nullable private boolean available; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + @Nullable + public String getKeyword() { + return keyword; + } + + public void setKeyword(@Nullable String keyword) { + this.keyword = keyword; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java index fe395861f..6bda75c78 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/geo/SpringDataGeoRepositoryTests.java @@ -17,12 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.util.Locale; import java.util.Optional; @@ -47,6 +41,7 @@ import org.springframework.data.geo.Circle; import org.springframework.data.geo.Point; import org.springframework.data.geo.Polygon; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -84,8 +79,11 @@ public void shouldSaveAndLoadGeoPoints() { // given Point point = new Point(15, 25); - GeoEntity entity = GeoEntity.builder().pointA(point).pointB(new GeoPoint(point.getX(), point.getY())) - .pointC(toGeoString(point)).pointD(toGeoArray(point)).build(); + GeoEntity entity = new GeoEntity(); + entity.setPointA(point); + entity.setPointB(new GeoPoint(point.getX(), point.getY())); + entity.setPointC(toGeoString(point)); + entity.setPointD(toGeoArray(point)); // when GeoEntity saved = repository.save(entity); @@ -112,32 +110,90 @@ private double[] toGeoArray(Point point) { return new double[] { point.getX(), point.getY() }; } - /** - * @author Artur Konczak - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-geo-repository", replicas = 0, refreshInterval = "-1") static class GeoEntity { - - @Id private String id; - + @Nullable @Id private String id; // geo shape - Spring Data - private Box box; - private Circle circle; - private Polygon polygon; - + @Nullable private Box box; + @Nullable private Circle circle; + @Nullable private Polygon polygon; // geo point - Custom implementation + Spring Data - @GeoPointField private Point pointA; - - private GeoPoint pointB; - - @GeoPointField private String pointC; - - @GeoPointField private double[] pointD; + @Nullable @GeoPointField private Point pointA; + @Nullable private GeoPoint pointB; + @Nullable @GeoPointField private String pointC; + @Nullable @GeoPointField private double[] pointD; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public Box getBox() { + return box; + } + + public void setBox(@Nullable Box box) { + this.box = box; + } + + @Nullable + public Circle getCircle() { + return circle; + } + + public void setCircle(@Nullable Circle circle) { + this.circle = circle; + } + + @Nullable + public Polygon getPolygon() { + return polygon; + } + + public void setPolygon(@Nullable Polygon polygon) { + this.polygon = polygon; + } + + @Nullable + public Point getPointA() { + return pointA; + } + + public void setPointA(@Nullable Point pointA) { + this.pointA = pointA; + } + + @Nullable + public GeoPoint getPointB() { + return pointB; + } + + public void setPointB(@Nullable GeoPoint pointB) { + this.pointB = pointB; + } + + @Nullable + public String getPointC() { + return pointC; + } + + public void setPointC(@Nullable String pointC) { + this.pointC = pointC; + } + + @Nullable + public double[] getPointD() { + return pointD; + } + + public void setPointD(@Nullable double[] pointD) { + this.pointD = pointD; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/nestedobject/InnerObjectTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/nestedobject/InnerObjectTests.java index 2ae1e9d1b..6d826c3a3 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/nestedobject/InnerObjectTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/nestedobject/InnerObjectTests.java @@ -19,12 +19,6 @@ import static org.assertj.core.api.Assertions.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -48,6 +42,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -101,26 +96,60 @@ public void shouldIndexInnerObject() { assertThat(bookRepository.findById(id)).isNotNull(); } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Nordine Bittich - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } public interface SampleElasticSearchBookRepository extends ElasticsearchRepository {} diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/synonym/SynonymRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/synonym/SynonymRepositoryTests.java index af44a9c1c..91e7a6219 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/synonym/SynonymRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/synonym/SynonymRepositoryTests.java @@ -17,8 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.Data; - import org.elasticsearch.index.query.QueryBuilders; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -40,6 +38,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -95,23 +94,31 @@ public void shouldDo() { assertThat(synonymEntities).hasSize(1); } - /** - * @author Mohsin Husen - */ - @Data @Document(indexName = "test-index-synonym") @Setting(settingPath = "/synonyms/settings.json") @Mapping(mappingPath = "/synonyms/mappings.json") static class SynonymEntity { - - @Id private String id; - private String text; + @Nullable @Id private String id; + @Nullable private String text; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } } - /** - * SynonymRepository - * - * @author Artur Konczak - */ interface SynonymRepository extends ElasticsearchRepository {} } diff --git a/src/test/java/org/springframework/data/elasticsearch/repositories/uuidkeyed/UUIDElasticsearchRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repositories/uuidkeyed/UUIDElasticsearchRepositoryTests.java index 365203a6f..916ea2af6 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repositories/uuidkeyed/UUIDElasticsearchRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repositories/uuidkeyed/UUIDElasticsearchRepositoryTests.java @@ -18,11 +18,6 @@ import static org.assertj.core.api.Assertions.*; import static org.elasticsearch.index.query.QueryBuilders.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -55,6 +50,7 @@ import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -549,24 +545,139 @@ private static List createSampleEntitiesWithMessage(Strin return sampleEntities; } - @NoArgsConstructor - @AllArgsConstructor - @Builder - @Data @Document(indexName = "test-index-uuid-keyed", replicas = 0, refreshInterval = "-1") static class SampleEntityUUIDKeyed { + @Nullable @Id private UUID id; + @Nullable private String type; + @Nullable @Field(type = FieldType.Text, fielddata = true) private String message; + @Nullable private int rate; + @Nullable @ScriptedField private Long scriptedRate; + @Nullable private boolean available; + @Nullable private String highlightedMessage; + @Nullable private GeoPoint location; + @Nullable @Version private Long version; + + @Nullable + public UUID getId() { + return id; + } + + public void setId(@Nullable UUID id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } - @Id private UUID id; - private String type; - @Field(type = FieldType.Text, fielddata = true) private String message; - private int rate; - @ScriptedField private Long scriptedRate; - private boolean available; - private String highlightedMessage; + public void setType(@Nullable String type) { + this.type = type; + } - private GeoPoint location; + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } - @Version private Long version; + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + @Nullable + public Long getScriptedRate() { + return scriptedRate; + } + + public void setScriptedRate(@Nullable Long scriptedRate) { + this.scriptedRate = scriptedRate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public String getHighlightedMessage() { + return highlightedMessage; + } + + public void setHighlightedMessage(@Nullable String highlightedMessage) { + this.highlightedMessage = highlightedMessage; + } + + @Nullable + public GeoPoint getLocation() { + return location; + } + + public void setLocation(@Nullable GeoPoint location) { + this.location = location; + } + + @Nullable + public Long getVersion() { + return version; + } + + public void setVersion(@Nullable Long version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof SampleEntityUUIDKeyed)) + return false; + + SampleEntityUUIDKeyed that = (SampleEntityUUIDKeyed) o; + + if (rate != that.rate) + return false; + if (available != that.available) + return false; + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + if (message != null ? !message.equals(that.message) : that.message != null) + return false; + if (scriptedRate != null ? !scriptedRate.equals(that.scriptedRate) : that.scriptedRate != null) + return false; + if (highlightedMessage != null ? !highlightedMessage.equals(that.highlightedMessage) + : that.highlightedMessage != null) + return false; + if (location != null ? !location.equals(that.location) : that.location != null) + return false; + return version != null ? version.equals(that.version) : that.version == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (message != null ? message.hashCode() : 0); + result = 31 * result + rate; + result = 31 * result + (scriptedRate != null ? scriptedRate.hashCode() : 0); + result = 31 * result + (available ? 1 : 0); + result = 31 * result + (highlightedMessage != null ? highlightedMessage.hashCode() : 0); + result = 31 * result + (location != null ? location.hashCode() : 0); + result = 31 * result + (version != null ? version.hashCode() : 0); + return result; + } } /** diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/config/ReactiveElasticsearchRepositoriesRegistrarTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/config/ReactiveElasticsearchRepositoriesRegistrarTests.java index 7f03144f8..30a0d51ac 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/config/ReactiveElasticsearchRepositoriesRegistrarTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/config/ReactiveElasticsearchRepositoriesRegistrarTests.java @@ -17,11 +17,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +29,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.ReactiveElasticsearchRestTemplateConfiguration; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.ReactiveElasticsearchRepository; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -62,15 +58,37 @@ public void testConfiguration() { interface ReactiveSampleEntityRepository extends ReactiveElasticsearchRepository {} - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-sample-reactive-repositories-registrar", replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; + public void setMessage(@Nullable String message) { + this.message = message; + } } } diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/ElasticsearchQueryMethodUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/ElasticsearchQueryMethodUnitTests.java index 3325cd54c..725e84645 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/query/ElasticsearchQueryMethodUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/ElasticsearchQueryMethodUnitTests.java @@ -17,10 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.lang.reflect.Method; import java.util.List; @@ -80,13 +76,37 @@ interface PersonRepository extends Repository books) { } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Nordine Bittich - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-query-unittest", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder static class Car { + @Nullable private String name; + @Nullable private String model; - private String name; - private String model; - + @Nullable public String getName() { return name; } - public void setName(String name) { + public void setName(@Nullable String name) { this.name = name; } + @Nullable public String getModel() { return model; } - public void setModel(String model) { + public void setModel(@Nullable String model) { this.model = model; } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - */ static class Author { @Nullable private String id; diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchQueryMethodUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchQueryMethodUnitTests.java index b7c3ab193..bc549926c 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchQueryMethodUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchQueryMethodUnitTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -220,64 +215,85 @@ public void setBooks(List books) { } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Nordine Bittich - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-reactive-repository-query", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder static class Car { + @Nullable private String name; + @Nullable private String model; - private String name; - private String model; - + @Nullable public String getName() { return name; } - public void setName(String name) { + public void setName(@Nullable String name) { this.name = name; } + @Nullable public String getModel() { return model; } - public void setModel(String model) { + public void setModel(@Nullable String model) { this.model = model; } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - */ static class Author { @Nullable private String id; diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchStringQueryUnitTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchStringQueryUnitTests.java index c6ff792f1..cb45584c7 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchStringQueryUnitTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/ReactiveElasticsearchStringQueryUnitTests.java @@ -17,11 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -224,64 +219,85 @@ public void setBooks(List books) { } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Nordine Bittich - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-book-reactive-repository-string-query", replicas = 0, refreshInterval = "-1") static class Book { - - @Id private String id; - private String name; - @Field(type = FieldType.Object) private Author author; - @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); - @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Object) private Author author; + @Nullable @Field(type = FieldType.Nested) private Map> buckets = new HashMap<>(); + @Nullable @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "whitespace"), otherFields = { @InnerField(suffix = "prefix", type = FieldType.Text, analyzer = "stop", searchAnalyzer = "standard") }) private String description; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public Author getAuthor() { + return author; + } + + public void setAuthor(@Nullable Author author) { + this.author = author; + } + + @Nullable + public Map> getBuckets() { + return buckets; + } + + public void setBuckets(@Nullable Map> buckets) { + this.buckets = buckets; + } + + @Nullable + public String getDescription() { + return description; + } + + public void setDescription(@Nullable String description) { + this.description = description; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Artur Konczak - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder static class Car { + @Nullable private String name; + @Nullable private String model; - private String name; - private String model; - + @Nullable public String getName() { return name; } - public void setName(String name) { + public void setName(@Nullable String name) { this.name = name; } + @Nullable public String getModel() { return model; } - public void setModel(String model) { + public void setModel(@Nullable String model) { this.model = model; } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - */ static class Author { @Nullable private String id; diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java index 91ed60ad6..5033a2ff7 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/query/keywords/QueryKeywordsTests.java @@ -17,12 +17,6 @@ import static org.assertj.core.api.Assertions.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -76,18 +70,12 @@ public void before() { indexOperations = operations.indexOps(Product.class); IndexInitializer.init(indexOperations); - Product product1 = Product.builder().id("1").name("Sugar").text("Cane sugar").price(1.0f).available(false) - .sortName("sort5").build(); - Product product2 = Product.builder().id("2").name("Sugar").text("Cane sugar").price(1.2f).available(true) - .sortName("sort4").build(); - Product product3 = Product.builder().id("3").name("Sugar").text("Beet sugar").price(1.1f).available(true) - .sortName("sort3").build(); - Product product4 = Product.builder().id("4").name("Salt").text("Rock salt").price(1.9f).available(true) - .sortName("sort2").build(); - Product product5 = Product.builder().id("5").name("Salt").text("Sea salt").price(2.1f).available(false) - .sortName("sort1").build(); - Product product6 = Product.builder().id("6").name(null).text("no name").price(3.4f).available(false) - .sortName("sort0").build(); + Product product1 = new Product("1", "Sugar", "Cane sugar", 1.0f, false, "sort5"); + Product product2 = new Product("2", "Sugar", "Cane sugar", 1.2f, true, "sort4"); + Product product3 = new Product("3", "Sugar", "Beet sugar", 1.1f, true, "sort3"); + Product product4 = new Product("4", "Salt", "Rock salt", 1.9f, true, "sort2"); + Product product5 = new Product("5", "Salt", "Sea salt", 2.1f, false, "sort1"); + Product product6 = new Product("6", null, "no name", 3.4f, false, "sort0"); repository.saveAll(Arrays.asList(product1, product2, product3, product4, product5, product6)); } @@ -285,34 +273,79 @@ void shouldReturnEmptyListOnDerivedMethodWithEmptyInputList() { assertThat(products).isEmpty(); } - /** - * @author Mohsin Husen - * @author Artur Konczak - */ - @Setter - @Getter - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-product-query-keywords", replicas = 0, refreshInterval = "-1") static class Product { - - @Id private String id; - - private String name; - - @Field(type = FieldType.Keyword) private String text; - - @Field(type = FieldType.Float) private Float price; - - private boolean available; - - @Field(name = "sort-name", type = FieldType.Keyword) private String sortName; + @Nullable @Id private String id; + @Nullable private String name; + @Nullable @Field(type = FieldType.Keyword) private String text; + @Nullable @Field(type = FieldType.Float) private Float price; + @Nullable private boolean available; + @Nullable @Field(name = "sort-name", type = FieldType.Keyword) private String sortName; + + public Product(@Nullable String id, @Nullable String name, @Nullable String text, @Nullable Float price, + boolean available, @Nullable String sortName) { + this.id = id; + this.name = name; + this.text = text; + this.price = price; + this.available = available; + this.sortName = sortName; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getName() { + return name; + } + + public void setName(@Nullable String name) { + this.name = name; + } + + @Nullable + public String getText() { + return text; + } + + public void setText(@Nullable String text) { + this.text = text; + } + + @Nullable + public Float getPrice() { + return price; + } + + public void setPrice(@Nullable Float price) { + this.price = price; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public String getSortName() { + return sortName; + } + + public void setSortName(@Nullable String sortName) { + this.sortName = sortName; + } } - /** - * Created by akonczak on 04/09/15. - */ interface ProductRepository extends ElasticsearchRepository { List findByName(@Nullable String name); diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepositoryIntegrationTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepositoryIntegrationTests.java index 103b590fb..72bb7ff7c 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepositoryIntegrationTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleElasticsearchRepositoryIntegrationTests.java @@ -20,13 +20,9 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.utils.IdGenerator.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.io.IOException; import java.lang.Long; +import java.lang.Object; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -59,6 +55,7 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.data.elasticsearch.utils.IndexInitializer; import org.springframework.data.util.StreamUtils; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -76,8 +73,7 @@ class SimpleElasticsearchRepositoryIntegrationTests { @Configuration @Import({ ElasticsearchRestTemplateConfiguration.class }) - @EnableElasticsearchRepositories( - basePackages = { "org.springframework.data.elasticsearch.repository.support" }, + @EnableElasticsearchRepositories(basePackages = { "org.springframework.data.elasticsearch.repository.support" }, considerNestedRepositories = true) static class Config {} @@ -681,32 +677,101 @@ private static List createSampleEntitiesWithMessage(String message return sampleEntities; } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Chris White - * @author Sascha Woo - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = "test-index-sample-simple-repository", replicas = 0, refreshInterval = "-1") static class SampleEntity { + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable private boolean available; + @Nullable @Version private Long version; + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - private boolean available; - @Version private Long version; + public void setRate(int rate) { + this.rate = rate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + SampleEntity that = (SampleEntity) o; + + if (rate != that.rate) + return false; + if (available != that.available) + return false; + if (id != null ? !id.equals(that.id) : that.id != null) + return false; + if (type != null ? !type.equals(that.type) : that.type != null) + return false; + if (message != null ? !message.equals(that.message) : that.message != null) + return false; + return version != null ? version.equals(that.version) : that.version == null; + } + + @Override + public int hashCode() { + int result = id != null ? id.hashCode() : 0; + result = 31 * result + (type != null ? type.hashCode() : 0); + result = 31 * result + (message != null ? message.hashCode() : 0); + result = 31 * result + rate; + result = 31 * result + (available ? 1 : 0); + result = 31 * result + (version != null ? version.hashCode() : 0); + return result; + } } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Christoph Strobl - */ interface SampleElasticsearchRepository extends ElasticsearchRepository { long deleteSampleEntityById(String id); diff --git a/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleReactiveElasticsearchRepositoryTests.java b/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleReactiveElasticsearchRepositoryTests.java index b71e4cbd0..7076c0829 100644 --- a/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleReactiveElasticsearchRepositoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/repository/support/SimpleReactiveElasticsearchRepositoryTests.java @@ -19,11 +19,6 @@ import static org.springframework.data.elasticsearch.annotations.FieldType.*; import static org.springframework.data.elasticsearch.core.query.Query.*; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.springframework.data.elasticsearch.core.query.ByQueryResponse; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; import reactor.test.StepVerifier; @@ -63,6 +58,7 @@ import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.data.elasticsearch.repository.config.EnableReactiveElasticsearchRepositories; import org.springframework.data.repository.reactive.ReactiveCrudRepository; +import org.springframework.lang.Nullable; import org.springframework.test.context.ContextConfiguration; /** @@ -97,7 +93,7 @@ void after() { @Test // DATAES-519 void saveShouldSaveSingleEntity() { - repository.save(SampleEntity.builder().build()) // + repository.save(new SampleEntity()) // .map(SampleEntity::getId) // .flatMap(this::documentWithIdExistsInIndex) // .as(StepVerifier::create) // @@ -111,10 +107,8 @@ private Mono documentWithIdExistsInIndex(String id) { @Test // DATAES-519 void saveShouldComputeMultipleEntities() { - repository - .saveAll(Arrays.asList(SampleEntity.builder().build(), SampleEntity.builder().build(), - SampleEntity.builder().build())) // - .map(SampleEntity::getId) // + repository.saveAll(Arrays.asList(new SampleEntity(), new SampleEntity(), new SampleEntity())) + /**/.map(SampleEntity::getId) // .flatMap(this::documentWithIdExistsInIndex) // .as(StepVerifier::create) // .expectNext(true) // @@ -133,9 +127,9 @@ void findByIdShouldErrorIfIndexDoesNotExist() { @Test // DATAES-519 void findShouldRetrieveSingleEntityById() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build(), // - SampleEntity.builder().id("id-three").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two"), // + new SampleEntity("id-three")) // .block(); repository.findById("id-two").as(StepVerifier::create)// @@ -146,9 +140,9 @@ void findShouldRetrieveSingleEntityById() { @Test // DATAES-519 void findByIdShouldCompleteIfNothingFound() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build(), // - SampleEntity.builder().id("id-three").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two"), // + new SampleEntity("id-three")) // .block(); repository.findById("does-not-exist").as(StepVerifier::create) // @@ -160,7 +154,7 @@ void findAllShouldReturnAllElements() { // make sure to be above the default page size of the Query interface int count = DEFAULT_PAGE_SIZE * 2; bulkIndex(IntStream.range(1, count + 1) // - .mapToObj(it -> SampleEntity.builder().id(String.valueOf(it)).build()) // + .mapToObj(it -> new SampleEntity(String.valueOf(it))) // .toArray(SampleEntity[]::new)) // .block(); @@ -178,9 +172,9 @@ void findAllByIdByIdShouldCompleteIfIndexDoesNotExist() { @Test // DATAES-519 void findAllByIdShouldRetrieveMatchingDocuments() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build(), // - SampleEntity.builder().id("id-three").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two"), // + new SampleEntity("id-three")) // .block(); repository.findAllById(Arrays.asList("id-one", "id-two")) // @@ -193,9 +187,9 @@ void findAllByIdShouldRetrieveMatchingDocuments() { @Test // DATAES-519 void findAllByIdShouldCompleteWhenNothingFound() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build(), // - SampleEntity.builder().id("id-three").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two"), // + new SampleEntity("id-three")) // .block(); repository.findAllById(Arrays.asList("can't", "touch", "this")) // @@ -206,9 +200,9 @@ void findAllByIdShouldCompleteWhenNothingFound() { @Test // DATAES-717 void shouldReturnFluxOfSearchHit() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("message").build(), // - SampleEntity.builder().id("id-three").message("message").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "message"), // + new SampleEntity("id-three", "message")) // .block(); repository.queryAllByMessage("message") // @@ -221,9 +215,9 @@ void shouldReturnFluxOfSearchHit() { @Test // DATAES-717 void shouldReturnFluxOfSearchHitForStringQuery() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("message").build(), // - SampleEntity.builder().id("id-three").message("message").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "message"), // + new SampleEntity("id-three", "message")) // .block(); repository.queryByMessageWithString("message") // @@ -236,9 +230,9 @@ void shouldReturnFluxOfSearchHitForStringQuery() { @Test // DATAES-372 void shouldReturnHighlightsOnAnnotatedMethod() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("message").build(), // - SampleEntity.builder().id("id-three").message("message").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "message"), // + new SampleEntity("id-three", "message")) // .block(); repository.queryAllByMessage("message") // @@ -254,9 +248,9 @@ void shouldReturnHighlightsOnAnnotatedMethod() { @Test // DATAES-372 void shouldReturnHighlightsOnAnnotatedStringQueryMethod() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("message").build(), // - SampleEntity.builder().id("id-three").message("message").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "message"), // + new SampleEntity("id-three", "message")) // .block(); repository.queryByMessageWithString("message") // @@ -279,8 +273,8 @@ void countShouldErrorWhenIndexDoesNotExist() { @Test // DATAES-519 void countShouldCountDocuments() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two")) // .block(); repository.count().as(StepVerifier::create).expectNext(2L).verifyComplete(); @@ -289,9 +283,9 @@ void countShouldCountDocuments() { @Test // DATAES-519 void existsByIdShouldReturnTrueIfExists() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.existsById("id-two") // @@ -303,9 +297,9 @@ void existsByIdShouldReturnTrueIfExists() { @Test // DATAES-519 void existsByIdShouldReturnFalseIfNotExists() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.existsById("wrecking ball") // @@ -317,9 +311,9 @@ void existsByIdShouldReturnFalseIfNotExists() { @Test // DATAES-519 void countShouldCountMatchingDocuments() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()).block(); + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")).block(); repository.countAllByMessage("test") // .as(StepVerifier::create) // @@ -331,9 +325,9 @@ void countShouldCountMatchingDocuments() { @DisplayName("should count with string query") void shouldCountWithStringQuery() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()).block(); + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")).block(); repository.retrieveCountByText("test") // .as(StepVerifier::create) // @@ -344,9 +338,9 @@ void shouldCountWithStringQuery() { @Test // DATAES-519 void existsShouldReturnTrueIfExists() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.existsAllByMessage("message") // @@ -358,9 +352,9 @@ void existsShouldReturnTrueIfExists() { @Test // DATAES-519 void existsShouldReturnFalseIfNotExists() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.existsAllByMessage("these days") // @@ -372,8 +366,8 @@ void existsShouldReturnFalseIfNotExists() { @Test // DATAES-519 void deleteByIdShouldCompleteIfNothingDeleted() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two")) // .block(); repository.deleteById("does-not-exist").as(StepVerifier::create).verifyComplete(); @@ -389,8 +383,8 @@ void deleteByIdShouldCompleteWhenIndexDoesNotExist() { @Test // DATAES-519 void deleteByIdShouldDeleteEntry() { - SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build(); - bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) // + SampleEntity toBeDeleted = new SampleEntity("id-two"); + bulkIndex(new SampleEntity("id-one"), toBeDeleted) // .block(); repository.deleteById(toBeDeleted.getId()).as(StepVerifier::create).verifyComplete(); @@ -401,8 +395,8 @@ void deleteByIdShouldDeleteEntry() { @Test // DATAES-976 void deleteAllByIdShouldDeleteEntry() { - SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build(); - bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) // + SampleEntity toBeDeleted = new SampleEntity("id-two"); + bulkIndex(new SampleEntity("id-one"), toBeDeleted) // .block(); repository.deleteAllById(Collections.singletonList(toBeDeleted.getId())).as(StepVerifier::create).verifyComplete(); @@ -413,8 +407,8 @@ void deleteAllByIdShouldDeleteEntry() { @Test // DATAES-519 void deleteShouldDeleteEntry() { - SampleEntity toBeDeleted = SampleEntity.builder().id("id-two").build(); - bulkIndex(SampleEntity.builder().id("id-one").build(), toBeDeleted) // + SampleEntity toBeDeleted = new SampleEntity("id-two"); + bulkIndex(new SampleEntity("id-one"), toBeDeleted) // .block(); repository.delete(toBeDeleted).as(StepVerifier::create).verifyComplete(); @@ -425,9 +419,9 @@ void deleteShouldDeleteEntry() { @Test // DATAES-519 void deleteAllShouldDeleteGivenEntries() { - SampleEntity toBeDeleted = SampleEntity.builder().id("id-one").build(); - SampleEntity hangInThere = SampleEntity.builder().id("id-two").build(); - SampleEntity toBeDeleted2 = SampleEntity.builder().id("id-three").build(); + SampleEntity toBeDeleted = new SampleEntity("id-one"); + SampleEntity hangInThere = new SampleEntity("id-two"); + SampleEntity toBeDeleted2 = new SampleEntity("id-three"); bulkIndex(toBeDeleted, hangInThere, toBeDeleted2) // .block(); @@ -442,9 +436,9 @@ void deleteAllShouldDeleteGivenEntries() { @Test // DATAES-519 void deleteAllShouldDeleteAllEntries() { - bulkIndex(SampleEntity.builder().id("id-one").build(), // - SampleEntity.builder().id("id-two").build(), // - SampleEntity.builder().id("id-three").build()) // + bulkIndex(new SampleEntity("id-one"), // + new SampleEntity("id-two"), // + new SampleEntity("id-three")) // .block(); repository.deleteAll().as(StepVerifier::create).verifyComplete(); @@ -458,9 +452,9 @@ void deleteAllShouldDeleteAllEntries() { @Test // DATAES-519 void derivedFinderMethodShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.findAllByMessageLike("test") // @@ -472,9 +466,9 @@ void derivedFinderMethodShouldBeExecutedCorrectly() { @Test // DATAES-519 void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.findAllByMessage(Mono.just("test")) // @@ -486,9 +480,9 @@ void derivedFinderMethodShouldBeExecutedCorrectlyWhenGivenPublisher() { @Test // DATAES-519 void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), // - SampleEntity.builder().id("id-two").message("test test").rate(1).build(), // - SampleEntity.builder().id("id-three").message("test test").rate(2).build()) // + bulkIndex(new SampleEntity("id-one", "test", 3), // + new SampleEntity("id-two", "test test", 1), // + new SampleEntity("id-three", "test test", 2)) // .block(); repository.findAllByMessageLikeOrderByRate("test") // @@ -502,9 +496,9 @@ void derivedFinderWithDerivedSortMethodShouldBeExecutedCorrectly() { @Test // DATAES-519 void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), // - SampleEntity.builder().id("id-two").message("test test").rate(1).build(), // - SampleEntity.builder().id("id-three").message("test test").rate(2).build()) // + bulkIndex(new SampleEntity("id-one", "test", 3), // + new SampleEntity("id-two", "test test", 1), // + new SampleEntity("id-three", "test test", 2)) // .block(); repository.findAllByMessage("test", Sort.by(Order.asc("rate"))) // @@ -518,9 +512,9 @@ void derivedFinderMethodWithSortParameterShouldBeExecutedCorrectly() { @Test // DATAES-519 void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("test").rate(3).build(), // - SampleEntity.builder().id("id-two").message("test test").rate(1).build(), // - SampleEntity.builder().id("id-three").message("test test").rate(2).build()) // + bulkIndex(new SampleEntity("id-one", "test", 3), // + new SampleEntity("id-two", "test test", 1), // + new SampleEntity("id-three", "test test", 2)) // .block(); repository.findAllByMessage("test", PageRequest.of(0, 2, Sort.by(Order.asc("rate")))) // @@ -533,9 +527,9 @@ void derivedFinderMethodWithPageableParameterShouldBeExecutedCorrectly() { @Test // DATAES-519 void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.findFirstByMessageLike("test") // @@ -547,9 +541,9 @@ void derivedFinderMethodReturningMonoShouldBeExecutedCorrectly() { @Test // DATAES-519 void annotatedFinderMethodShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.findAllViaAnnotatedQueryByMessageLike("test") // @@ -561,9 +555,9 @@ void annotatedFinderMethodShouldBeExecutedCorrectly() { @Test // DATAES-519 void derivedDeleteMethodShouldBeExecutedCorrectly() { - bulkIndex(SampleEntity.builder().id("id-one").message("message").build(), // - SampleEntity.builder().id("id-two").message("test message").build(), // - SampleEntity.builder().id("id-three").message("test test").build()) // + bulkIndex(new SampleEntity("id-one", "message"), // + new SampleEntity("id-two", "test message"), // + new SampleEntity("id-three", "test test")) // .block(); repository.deleteAllByMessage("message") // @@ -614,25 +608,82 @@ interface ReactiveSampleEntityRepository extends ReactiveCrudRepository retrieveCountByText(String message); } - /** - * @author Rizwan Idrees - * @author Mohsin Husen - * @author Chris White - * @author Sascha Woo - */ - @Data - @NoArgsConstructor - @AllArgsConstructor - @Builder @Document(indexName = INDEX, replicas = 0, refreshInterval = "-1") static class SampleEntity { - - @Id private String id; - @Field(type = Text, store = true, fielddata = true) private String type; - @Field(type = Text, store = true, fielddata = true) private String message; - private int rate; - private boolean available; - @Version private Long version; - + @Nullable @Id private String id; + @Nullable @Field(type = Text, store = true, fielddata = true) private String type; + @Nullable @Field(type = Text, store = true, fielddata = true) private String message; + @Nullable private int rate; + @Nullable private boolean available; + @Nullable @Version private Long version; + + public SampleEntity() {} + + public SampleEntity(@Nullable String id) { + this.id = id; + } + + public SampleEntity(@Nullable String id, @Nullable String message) { + this.id = id; + this.message = message; + } + + public SampleEntity(@Nullable String id, @Nullable String message, int rate) { + this.id = id; + this.message = message; + this.rate = rate; + } + + @Nullable + public String getId() { + return id; + } + + public void setId(@Nullable String id) { + this.id = id; + } + + @Nullable + public String getType() { + return type; + } + + public void setType(@Nullable String type) { + this.type = type; + } + + @Nullable + public String getMessage() { + return message; + } + + public void setMessage(@Nullable String message) { + this.message = message; + } + + public int getRate() { + return rate; + } + + public void setRate(int rate) { + this.rate = rate; + } + + public boolean isAvailable() { + return available; + } + + public void setAvailable(boolean available) { + this.available = available; + } + + @Nullable + public java.lang.Long getVersion() { + return version; + } + + public void setVersion(@Nullable java.lang.Long version) { + this.version = version; + } } } diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar new file mode 100644 index 0000000000000000000000000000000000000000..f11c867c5059f6179c26a131960899f58de3d64c GIT binary patch literal 425 zcmWIWW@Zs#;Nak3_*7FG#DD}i8CV#6T|*poJ^kGD|D9rBU}gyLX6FE@V1gDtA_7e=7P|#0a)pXWGOjOQ69PKn${)i-7^?oTnJ>W?)FoEhwqf zE2$_6@MdHZVL7XxlrB23r;WFonl Rl?^1t41`;N^nDPA0RX@NP|5%R literal 0 HcmV?d00001 diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.md5 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.md5 new file mode 100644 index 000000000..48ea84335 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.md5 @@ -0,0 +1 @@ +f6bbf833798e7af0055b94865a46440e \ No newline at end of file diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.sha1 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.sha1 new file mode 100644 index 000000000..f6cee39f7 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.jar.sha1 @@ -0,0 +1 @@ +59ddfc2b714be7918808eacecc5739b8d277e60e \ No newline at end of file diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom new file mode 100644 index 000000000..3f9fa7a19 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom @@ -0,0 +1,8 @@ + + + 4.0.0 + org.projectlombok + lombok + 999999 + diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.md5 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.md5 new file mode 100644 index 000000000..788bc4133 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.md5 @@ -0,0 +1 @@ +63317ccd46b6663ff35cb142e05dce10 \ No newline at end of file diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.sha1 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.sha1 new file mode 100644 index 000000000..f1cddaef2 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/999999/lombok-999999.pom.sha1 @@ -0,0 +1 @@ +db353983c68ade94ae7e08acfacc0fc21ed8b64b \ No newline at end of file diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml new file mode 100644 index 000000000..8ddcc39a8 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml @@ -0,0 +1,12 @@ + + + org.projectlombok + lombok + + 999999 + + 999999 + + 20210321155422 + + diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.md5 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.md5 new file mode 100644 index 000000000..8c58c1d52 --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.md5 @@ -0,0 +1 @@ +998d3b8876980a3ef5a90adc982cc727 \ No newline at end of file diff --git a/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.sha1 b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.sha1 new file mode 100644 index 000000000..ec41ca43b --- /dev/null +++ b/src/test/resources/local-maven-repo/org/projectlombok/lombok/maven-metadata.xml.sha1 @@ -0,0 +1 @@ +f4090a49c6eec680c075130b68bf8ee48aac4e94 \ No newline at end of file