From 15f51c5151fe20213cfb79c8c904ec22aee7f1d5 Mon Sep 17 00:00:00 2001 From: Peter-Josef Meisch Date: Wed, 29 Apr 2020 20:30:09 +0200 Subject: [PATCH] DATAES-799 - Polishing. --- .../ElasticsearchExceptionTranslator.java | 3 +- .../elasticsearch/core/EntityOperations.java | 3 +- .../elasticsearch/core/RequestFactory.java | 3 +- .../MappingElasticsearchConverter.java | 14 ++++- .../elasticsearch/core/document/Document.java | 8 +-- .../core/document/DocumentAdapters.java | 23 ++++---- .../core/index/MappingBuilder.java | 2 +- .../ElasticsearchPersistentEntity.java | 13 ++--- .../ElasticsearchPersistentProperty.java | 4 +- .../core/query/SeqNoPrimaryTerm.java | 40 +++++++------- ...ElasticsearchExceptionTranslatorTests.java | 8 ++- .../ReactiveElasticsearchTemplateTests.java | 54 +++++++++---------- .../core/RequestFactoryTests.java | 4 +- ...appingElasticsearchConverterUnitTests.java | 5 +- .../core/index/MappingBuilderTests.java | 2 +- ...pleElasticsearchPersistentEntityTests.java | 15 +++--- .../core/query/SeqNoPrimaryTermTests.java | 2 +- 17 files changed, 106 insertions(+), 97 deletions(-) diff --git a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslator.java b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslator.java index 77a8de10d..bf4738c64 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslator.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslator.java @@ -79,8 +79,7 @@ public class ElasticsearchExceptionTranslator implements PersistenceExceptionTra if (exception instanceof ElasticsearchStatusException) { ElasticsearchStatusException statusException = (ElasticsearchStatusException) exception; - return statusException.status() == RestStatus.CONFLICT - && statusException.getMessage() != null + return statusException.status() == RestStatus.CONFLICT && statusException.getMessage() != null && statusException.getMessage().contains("type=version_conflict_engine_exception") && statusException.getMessage().contains("version conflict, required seqNo"); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java b/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java index 65467ec0d..4f8b45102 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/EntityOperations.java @@ -272,7 +272,8 @@ class EntityOperations { * * @return SeqNoPrimaryTerm, may be {@literal null} */ - @Nullable SeqNoPrimaryTerm getSeqNoPrimaryTerm(); + @Nullable + SeqNoPrimaryTerm getSeqNoPrimaryTerm(); } /** diff --git a/src/main/java/org/springframework/data/elasticsearch/core/RequestFactory.java b/src/main/java/org/springframework/data/elasticsearch/core/RequestFactory.java index c4361cf32..4d1a5c3e6 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/RequestFactory.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/RequestFactory.java @@ -709,7 +709,8 @@ class RequestFactory { return false; } - ElasticsearchPersistentEntity entity = elasticsearchConverter.getMappingContext().getRequiredPersistentEntity(entityClass); + ElasticsearchPersistentEntity entity = elasticsearchConverter.getMappingContext() + .getRequiredPersistentEntity(entityClass); return entity.hasSeqNoPrimaryTermProperty(); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java b/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java index 9e196a273..034fca418 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java @@ -15,8 +15,17 @@ */ package org.springframework.data.elasticsearch.core.convert; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; import org.springframework.beans.BeansException; import org.springframework.beans.factory.InitializingBean; @@ -297,7 +306,8 @@ public class MappingElasticsearchConverter if (value instanceof List) { target.add(readValue(value, property, property.getTypeInformation().getActualType())); } else if (value instanceof Map) { - target.add(readMapValue((Map) value, property, property.getTypeInformation().getActualType())); + target + .add(readMapValue((Map) value, property, property.getTypeInformation().getActualType())); } else { target.add(readEntity(computeGenericValueTypeForRead(property, value), (Map) value)); } diff --git a/src/main/java/org/springframework/data/elasticsearch/core/document/Document.java b/src/main/java/org/springframework/data/elasticsearch/core/document/Document.java index c6311ed75..59af552de 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/document/Document.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/document/Document.java @@ -182,8 +182,8 @@ public interface Document extends Map { * {@link #hasSeqNo()} prior to calling this method. * * @return the seq_no associated with this {@link Document}. - * @throws IllegalStateException if the underlying implementation supports seq_no's but no seq_no was yet - * associated with the document. + * @throws IllegalStateException if the underlying implementation supports seq_no's but no seq_no was yet associated + * with the document. */ default long getSeqNo() { throw new UnsupportedOperationException(); @@ -214,8 +214,8 @@ public interface Document extends Map { * {@link #hasPrimaryTerm()} prior to calling this method. * * @return the primary_term associated with this {@link Document}. - * @throws IllegalStateException if the underlying implementation supports primary_term's but no primary_term was - * yet associated with the document. + * @throws IllegalStateException if the underlying implementation supports primary_term's but no primary_term was yet + * associated with the document. */ default long getPrimaryTerm() { throw new UnsupportedOperationException(); diff --git a/src/main/java/org/springframework/data/elasticsearch/core/document/DocumentAdapters.java b/src/main/java/org/springframework/data/elasticsearch/core/document/DocumentAdapters.java index 0dbc7aed9..95cf06c37 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/document/DocumentAdapters.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/document/DocumentAdapters.java @@ -77,8 +77,8 @@ public class DocumentAdapters { } if (source.isSourceEmpty()) { - return fromDocumentFields(source, source.getId(), source.getVersion(), - source.getSeqNo(), source.getPrimaryTerm()); + return fromDocumentFields(source, source.getId(), source.getVersion(), source.getSeqNo(), + source.getPrimaryTerm()); } Document document = Document.from(source.getSourceAsMap()); @@ -108,8 +108,8 @@ public class DocumentAdapters { } if (source.isSourceEmpty()) { - return fromDocumentFields(source, source.getId(), source.getVersion(), - source.getSeqNo(), source.getPrimaryTerm()); + return fromDocumentFields(source, source.getId(), source.getVersion(), source.getSeqNo(), + source.getPrimaryTerm()); } Document document = Document.from(source.getSource()); @@ -157,8 +157,7 @@ public class DocumentAdapters { if (sourceRef == null || sourceRef.length() == 0) { return new SearchDocumentAdapter(source.getScore(), source.getSortValues(), source.getFields(), highlightFields, - fromDocumentFields(source, source.getId(), source.getVersion(), - source.getSeqNo(), source.getPrimaryTerm())); + fromDocumentFields(source, source.getId(), source.getVersion(), source.getSeqNo(), source.getPrimaryTerm())); } Document document = Document.from(source.getSourceAsMap()); @@ -180,8 +179,8 @@ public class DocumentAdapters { * @param documentFields the {@link DocumentField}s backing the {@link Document}. * @return the adapted {@link Document}. */ - public static Document fromDocumentFields(Iterable documentFields, String id, long version, - long seqNo, long primaryTerm) { + public static Document fromDocumentFields(Iterable documentFields, String id, long version, long seqNo, + long primaryTerm) { if (documentFields instanceof Collection) { return new DocumentFieldAdapter((Collection) documentFields, id, version, seqNo, primaryTerm); @@ -204,8 +203,8 @@ public class DocumentAdapters { private final long seqNo; private final long primaryTerm; - DocumentFieldAdapter(Collection documentFields, String id, long version, - long seqNo, long primaryTerm) { + DocumentFieldAdapter(Collection documentFields, String id, long version, long seqNo, + long primaryTerm) { this.documentFields = documentFields; this.id = id; this.version = version; @@ -618,7 +617,7 @@ public class DocumentAdapters { public void setVersion(long version) { delegate.setVersion(version); } - + /* * (non-Javadoc) * @see org.springframework.data.elasticsearch.core.document.Document#hasSeqNo() @@ -645,7 +644,7 @@ public class DocumentAdapters { public void setSeqNo(long seqNo) { delegate.setSeqNo(seqNo); } - + /* * (non-Javadoc) * @see org.springframework.data.elasticsearch.core.document.Document#hasPrimaryTerm() diff --git a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java index 2eea93ca9..69e0ca806 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/index/MappingBuilder.java @@ -170,7 +170,7 @@ public class MappingBuilder { if (property.isSeqNoPrimaryTermProperty()) { if (property.isAnnotationPresent(Field.class)) { logger.warn("Property {} of {} is annotated for inclusion in mapping, but its type is " + // - "SeqNoPrimaryTerm that is never mapped, so it is skipped", // + "SeqNoPrimaryTerm that is never mapped, so it is skipped", // property.getFieldName(), entity.getType()); } return; diff --git a/src/main/java/org/springframework/data/elasticsearch/core/mapping/ElasticsearchPersistentEntity.java b/src/main/java/org/springframework/data/elasticsearch/core/mapping/ElasticsearchPersistentEntity.java index 9e2c0d959..bc7fed013 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/mapping/ElasticsearchPersistentEntity.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/mapping/ElasticsearchPersistentEntity.java @@ -60,7 +60,8 @@ public interface ElasticsearchPersistentEntity extends PersistentEntity extends PersistentEntity extends PersistentEntitypotential score property of the owning * {@link ElasticsearchPersistentEntity}. This method is mainly used by {@link ElasticsearchPersistentEntity} * implementation to discover score property candidates on {@link ElasticsearchPersistentEntity} creation you should - * rather call {@link ElasticsearchPersistentEntity#getScoreProperty()} to determine whether the - * current property is the score property of that {@link ElasticsearchPersistentEntity} under consideration. + * rather call {@link ElasticsearchPersistentEntity#getScoreProperty()} to determine whether the current property is + * the score property of that {@link ElasticsearchPersistentEntity} under consideration. * * @return * @since 3.1 diff --git a/src/main/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTerm.java b/src/main/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTerm.java index c7bf434d0..10e7fbf8b 100644 --- a/src/main/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTerm.java +++ b/src/main/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTerm.java @@ -18,21 +18,25 @@ package org.springframework.data.elasticsearch.core.query; import java.util.Objects; /** - *

A container for seq_no and primary_term values. When an entity class contains a field of this type, - * it will be automatically filled with SeqNoPrimaryTerm instance on read operations (like get or search), - * and also, when the SeqNoPrimaryTerm is not {@literal null} and filled with seq_no and primary_term, - * they will be sent to Elasticsearch when indexing such an entity. + *

+ * A container for seq_no and primary_term values. When an entity class contains a field of this type, it will be + * automatically filled with SeqNoPrimaryTerm instance on read operations (like get or search), and also, when the + * SeqNoPrimaryTerm is not {@literal null} and filled with seq_no and primary_term, they will be sent to Elasticsearch + * when indexing such an entity. *

- *

This allows to implement optimistic locking pattern for full-update scenario, when an entity is first - * read from Elasticsearch and then gets reindexed with new _content. - * Index operations will throw an {@link org.springframework.dao.OptimisticLockingFailureException} if the - * seq_no + primary_term pair already has different values for the given document. See Elasticsearch documentation - * for more information: https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html + *

+ * This allows to implement optimistic locking pattern for full-update scenario, when an entity is first read from + * Elasticsearch and then gets reindexed with new _content. Index operations will throw an + * {@link org.springframework.dao.OptimisticLockingFailureException} if the seq_no + primary_term pair already has + * different values for the given document. See Elasticsearch documentation for more information: + * https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html *

- *

A property of this type is implicitly @{@link org.springframework.data.annotation.Transient} and never gets included + *

+ * A property of this type is implicitly @{@link org.springframework.data.annotation.Transient} and never gets included * into a mapping at Elasticsearch side. *

- *

A SeqNoPrimaryTerm instance cannot contain an invalid or unassigned seq_no or primary_term. + *

+ * A SeqNoPrimaryTerm instance cannot contain an invalid or unassigned seq_no or primary_term. *

* * @author Roman Puchkovskiy @@ -44,11 +48,11 @@ public final class SeqNoPrimaryTerm { /** * Creates an instance of SeqNoPrimaryTerm with the given seq_no and primary_term. The passed values are validated: - * sequenceNumber must be non-negative, primaryTerm must be positive. If validation fails, - * an IllegalArgumentException is thrown. + * sequenceNumber must be non-negative, primaryTerm must be positive. If validation fails, an IllegalArgumentException + * is thrown. * * @param sequenceNumber seq_no, must not be negative - * @param primaryTerm primary_term, must be positive + * @param primaryTerm primary_term, must be positive * @throws IllegalArgumentException if seq_no or primary_term is not valid */ public SeqNoPrimaryTerm(long sequenceNumber, long primaryTerm) { @@ -73,10 +77,7 @@ public final class SeqNoPrimaryTerm { @Override public String toString() { - return "SeqNoPrimaryTerm{" + - "sequenceNumber=" + sequenceNumber + - ", primaryTerm=" + primaryTerm + - '}'; + return "SeqNoPrimaryTerm{" + "sequenceNumber=" + sequenceNumber + ", primaryTerm=" + primaryTerm + '}'; } @Override @@ -88,8 +89,7 @@ public final class SeqNoPrimaryTerm { return false; } SeqNoPrimaryTerm that = (SeqNoPrimaryTerm) o; - return sequenceNumber == that.sequenceNumber && - primaryTerm == that.primaryTerm; + return sequenceNumber == that.sequenceNumber && primaryTerm == that.primaryTerm; } @Override diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslatorTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslatorTests.java index 4f2ec1339..c2ba997e7 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslatorTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchExceptionTranslatorTests.java @@ -25,8 +25,6 @@ import org.junit.jupiter.api.Test; import org.springframework.dao.DataAccessException; import org.springframework.dao.OptimisticLockingFailureException; -import java.util.UUID; - /** * @author Roman Puchkovskiy */ @@ -48,8 +46,8 @@ class ElasticsearchExceptionTranslatorTests { @Test // DATAES-799 void shouldConvertVersionConflictEngineExceptionWithSeqNoConflictToOptimisticLockingFailureException() { - VersionConflictEngineException ex = new VersionConflictEngineException( - new ShardId("index", "uuid", 1), "exception-id", + VersionConflictEngineException ex = new VersionConflictEngineException(new ShardId("index", "uuid", 1), + "exception-id", "Elasticsearch exception [type=version_conflict_engine_exception, reason=[WPUUsXEB6uuA6j8_A7AB]: version conflict, required seqNo [34], primary term [16]. current document has seqNo [35] and primary term [16]]"); DataAccessException translated = translator.translateExceptionIfPossible(ex); @@ -58,4 +56,4 @@ class ElasticsearchExceptionTranslatorTests { assertThat(translated.getMessage()).startsWith("Cannot index a document due to seq_no+primary_term conflict"); assertThat(translated.getCause()).isSameAs(ex); } -} \ No newline at end of file +} diff --git a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateTests.java b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateTests.java index e78e93853..b75beb71b 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchTemplateTests.java @@ -62,7 +62,16 @@ import org.springframework.data.elasticsearch.annotations.Field; import org.springframework.data.elasticsearch.annotations.Score; import org.springframework.data.elasticsearch.client.reactive.ReactiveElasticsearchClient; import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; -import org.springframework.data.elasticsearch.core.query.*; +import org.springframework.data.elasticsearch.core.query.Criteria; +import org.springframework.data.elasticsearch.core.query.CriteriaQuery; +import org.springframework.data.elasticsearch.core.query.IndexQuery; +import org.springframework.data.elasticsearch.core.query.IndexQueryBuilder; +import org.springframework.data.elasticsearch.core.query.NativeSearchQuery; +import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; +import org.springframework.data.elasticsearch.core.query.Query; +import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm; +import org.springframework.data.elasticsearch.core.query.StringQuery; +import org.springframework.data.elasticsearch.core.query.UpdateQuery; import org.springframework.data.elasticsearch.junit.junit4.ElasticsearchVersion; import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest; import org.springframework.util.StringUtils; @@ -858,10 +867,8 @@ public class ReactiveElasticsearchTemplateTests { original.setMessage("It's fine"); OptimisticEntity saved = template.save(original).block(); - template.get(saved.getId(), OptimisticEntity.class) - .as(StepVerifier::create) - .assertNext(this::assertThatSeqNoPrimaryTermIsFilled) - .verifyComplete(); + template.get(saved.getId(), OptimisticEntity.class).as(StepVerifier::create) + .assertNext(this::assertThatSeqNoPrimaryTermIsFilled).verifyComplete(); } private void assertThatSeqNoPrimaryTermIsFilled(OptimisticEntity retrieved) { @@ -878,10 +885,10 @@ public class ReactiveElasticsearchTemplateTests { original.setMessage("It's fine"); OptimisticEntity saved = template.save(original).block(); - template.multiGet(multiGetQueryForOne(saved.getId()), OptimisticEntity.class, template.getIndexCoordinatesFor(OptimisticEntity.class)) - .as(StepVerifier::create) - .assertNext(this::assertThatSeqNoPrimaryTermIsFilled) - .verifyComplete(); + template + .multiGet(multiGetQueryForOne(saved.getId()), OptimisticEntity.class, + template.getIndexCoordinatesFor(OptimisticEntity.class)) + .as(StepVerifier::create).assertNext(this::assertThatSeqNoPrimaryTermIsFilled).verifyComplete(); } private Query multiGetQueryForOne(String id) { @@ -895,17 +902,15 @@ public class ReactiveElasticsearchTemplateTests { OptimisticEntity saved = template.save(original).block(); restTemplate.refresh(OptimisticEntity.class); - template.search(searchQueryForOne(saved.getId()), OptimisticEntity.class, template.getIndexCoordinatesFor(OptimisticEntity.class)) - .map(SearchHit::getContent) - .as(StepVerifier::create) - .assertNext(this::assertThatSeqNoPrimaryTermIsFilled) + template + .search(searchQueryForOne(saved.getId()), OptimisticEntity.class, + template.getIndexCoordinatesFor(OptimisticEntity.class)) + .map(SearchHit::getContent).as(StepVerifier::create).assertNext(this::assertThatSeqNoPrimaryTermIsFilled) .verifyComplete(); } private Query searchQueryForOne(String id) { - return new NativeSearchQueryBuilder() - .withFilter(new IdsQueryBuilder().addIds(id)) - .build(); + return new NativeSearchQueryBuilder().withFilter(new IdsQueryBuilder().addIds(id)).build(); } @Test // DATAES-799 @@ -921,12 +926,9 @@ public class ReactiveElasticsearchTemplateTests { template.save(forEdit1).block(); forEdit2.setMessage("It'll be great"); - template.save(forEdit2) - .as(StepVerifier::create) - .expectError(OptimisticLockingFailureException.class) - .verify(); + template.save(forEdit2).as(StepVerifier::create).expectError(OptimisticLockingFailureException.class).verify(); } - + @Test // DATAES-799 void shouldThrowOptimisticLockingFailureExceptionWhenConcurrentUpdateOccursOnVersionedEntityWithSeqNoPrimaryTermProperty() { OptimisticAndVersionedEntity original = new OptimisticAndVersionedEntity(); @@ -940,10 +942,7 @@ public class ReactiveElasticsearchTemplateTests { template.save(forEdit1).block(); forEdit2.setMessage("It'll be great"); - template.save(forEdit2) - .as(StepVerifier::create) - .expectError(OptimisticLockingFailureException.class) - .verify(); + template.save(forEdit2).as(StepVerifier::create).expectError(OptimisticLockingFailureException.class).verify(); } @Test // DATAES-799 @@ -955,10 +954,7 @@ public class ReactiveElasticsearchTemplateTests { OptimisticAndVersionedEntity forEdit = template.get(saved.getId(), OptimisticAndVersionedEntity.class).block(); forEdit.setMessage("It'll be ok"); - template.save(forEdit) - .as(StepVerifier::create) - .expectNextCount(1) - .verifyComplete(); + template.save(forEdit).as(StepVerifier::create).expectNextCount(1).verifyComplete(); } @Data 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 ec4f319e6..336261f5d 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/RequestFactoryTests.java @@ -233,8 +233,8 @@ class RequestFactoryTests { when(client.prepareSearch(any())).thenReturn(new SearchRequestBuilder(client, SearchAction.INSTANCE)); Query query = new NativeSearchQueryBuilder().build(); - SearchRequestBuilder builder = requestFactory.searchRequestBuilder(client, query, - EntityWithSeqNoPrimaryTerm.class, IndexCoordinates.of("seqNoPrimaryTerm")); + SearchRequestBuilder builder = requestFactory.searchRequestBuilder(client, query, EntityWithSeqNoPrimaryTerm.class, + IndexCoordinates.of("seqNoPrimaryTerm")); assertThat(builder.request().source().seqNoAndPrimaryTerm()).isTrue(); } 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 45aac4f9e..486f3b417 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 @@ -703,7 +703,7 @@ public class MappingElasticsearchConverterUnitTests { EntityWithSeqNoPrimaryTerm entity = new EntityWithSeqNoPrimaryTerm(); entity.seqNoPrimaryTerm = new SeqNoPrimaryTerm(1L, 2L); Document document = Document.create(); - + mappingElasticsearchConverter.write(entity, document); assertThat(document).doesNotContainKey("seqNoPrimaryTerm"); @@ -926,7 +926,8 @@ public class MappingElasticsearchConverterUnitTests { } @Data - @org.springframework.data.elasticsearch.annotations.Document(indexName = "test-index-entity-with-seq-no-primary-term-mapper") + @org.springframework.data.elasticsearch.annotations.Document( + indexName = "test-index-entity-with-seq-no-primary-term-mapper") static class EntityWithSeqNoPrimaryTerm { @Nullable private SeqNoPrimaryTerm seqNoPrimaryTerm; diff --git a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderTests.java b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderTests.java index 5045aa726..a59904a64 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/index/MappingBuilderTests.java @@ -579,7 +579,7 @@ public class MappingBuilderTests extends MappingContextBaseTests { @Test // DATAES-799 void shouldNotIncludeSeqNoPrimaryTermPropertyInMappingEvenWhenAnnotatedWithField() { String propertyMapping = getMappingBuilder().buildPropertyMapping(EntityWithSeqNoPrimaryTerm.class); - + assertThat(propertyMapping).doesNotContain("seqNoPrimaryTerm"); } diff --git a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntityTests.java b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntityTests.java index ddb5ea7c8..321fd36d5 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntityTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentEntityTests.java @@ -99,7 +99,8 @@ public class SimpleElasticsearchPersistentEntityTests { @Test // DATAES-799 void shouldReportThatThereIsNoSeqNoPrimaryTermPropertyWhenThereIsNoSuchProperty() { - TypeInformation typeInformation = ClassTypeInformation.from(EntityWithoutSeqNoPrimaryTerm.class); + TypeInformation typeInformation = ClassTypeInformation + .from(EntityWithoutSeqNoPrimaryTerm.class); SimpleElasticsearchPersistentEntity entity = new SimpleElasticsearchPersistentEntity<>( typeInformation); @@ -108,7 +109,8 @@ public class SimpleElasticsearchPersistentEntityTests { @Test // DATAES-799 void shouldReportThatThereIsSeqNoPrimaryTermPropertyWhenThereIsSuchProperty() { - TypeInformation typeInformation = ClassTypeInformation.from(EntityWithSeqNoPrimaryTerm.class); + TypeInformation typeInformation = ClassTypeInformation + .from(EntityWithSeqNoPrimaryTerm.class); SimpleElasticsearchPersistentEntity entity = new SimpleElasticsearchPersistentEntity<>( typeInformation); @@ -119,7 +121,8 @@ public class SimpleElasticsearchPersistentEntityTests { @Test // DATAES-799 void shouldReturnSeqNoPrimaryTermPropertyWhenThereIsSuchProperty() { - TypeInformation typeInformation = ClassTypeInformation.from(EntityWithSeqNoPrimaryTerm.class); + TypeInformation typeInformation = ClassTypeInformation + .from(EntityWithSeqNoPrimaryTerm.class); SimpleElasticsearchPersistentEntity entity = new SimpleElasticsearchPersistentEntity<>( typeInformation); entity.addPersistentProperty(createProperty(entity, "seqNoPrimaryTerm")); @@ -134,7 +137,8 @@ public class SimpleElasticsearchPersistentEntityTests { @Test // DATAES-799 void shouldNotAllowMoreThanOneSeqNoPrimaryTermProperties() { - TypeInformation typeInformation = ClassTypeInformation.from(EntityWithSeqNoPrimaryTerm.class); + TypeInformation typeInformation = ClassTypeInformation + .from(EntityWithSeqNoPrimaryTerm.class); SimpleElasticsearchPersistentEntity entity = new SimpleElasticsearchPersistentEntity<>( typeInformation); entity.addPersistentProperty(createProperty(entity, "seqNoPrimaryTerm")); @@ -202,8 +206,7 @@ public class SimpleElasticsearchPersistentEntityTests { @Nullable @Field(name = "renamed-field") private String renamedField; } - private static class EntityWithoutSeqNoPrimaryTerm { - } + private static class EntityWithoutSeqNoPrimaryTerm {} private static class EntityWithSeqNoPrimaryTerm { private SeqNoPrimaryTerm seqNoPrimaryTerm; diff --git a/src/test/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTermTests.java b/src/test/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTermTests.java index 6f31ba6a4..524fc45c3 100644 --- a/src/test/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTermTests.java +++ b/src/test/java/org/springframework/data/elasticsearch/core/query/SeqNoPrimaryTermTests.java @@ -49,4 +49,4 @@ class SeqNoPrimaryTermTests { assertThatThrownBy(() -> new SeqNoPrimaryTerm(1, SequenceNumbers.UNASSIGNED_PRIMARY_TERM)) .isInstanceOf(IllegalArgumentException.class); } -} \ No newline at end of file +}