Skip to content

Commit b99ca18

Browse files
committed
Fix adaption to PersistentProperty change.
1 parent 1a24c3c commit b99ca18

File tree

6 files changed

+29
-15
lines changed

6 files changed

+29
-15
lines changed

src/main/java/org/springframework/data/elasticsearch/core/convert/MappingElasticsearchConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ protected <R> R readProperties(ElasticsearchPersistentEntity<?> entity, R instan
403403

404404
for (ElasticsearchPersistentProperty property : entity) {
405405

406-
if (entity.isCreatorArgument(property) || !property.isReadable() || property.isIndexedIndexNameProperty()) {
406+
if (entity.isCreatorArgument(property) || !property.isReadable() || property.isSeqNoPrimaryTermProperty()
407+
|| property.isIndexedIndexNameProperty()) {
407408
continue;
408409
}
409410

src/main/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentProperty.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public boolean isWritable() {
129129

130130
@Override
131131
public boolean isReadable() {
132-
return super.isReadable() && !isAnnotationPresent(WriteOnlyProperty.class);
132+
return super.isReadable() && !isAnnotationPresent(WriteOnlyProperty.class);
133133
}
134134

135135
@Override

src/test/java/org/springframework/data/elasticsearch/core/ElasticsearchIntegrationTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4522,6 +4522,14 @@ public ImmutableEntity(@Nullable String id, String text, @Nullable SeqNoPrimaryT
45224522
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
45234523
}
45244524

4525+
public ImmutableEntity withId(@Nullable String id) {
4526+
return new ImmutableEntity(id, this.text, this.seqNoPrimaryTerm);
4527+
}
4528+
4529+
public ImmutableEntity withSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
4530+
return new ImmutableEntity(this.id, this.text, seqNoPrimaryTerm);
4531+
}
4532+
45254533
@Nullable
45264534
public String getId() {
45274535
return id;

src/test/java/org/springframework/data/elasticsearch/core/ReactiveElasticsearchIntegrationTests.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
import static java.util.Collections.*;
1919
import static org.assertj.core.api.Assertions.*;
2020
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
21-
import static org.springframework.data.elasticsearch.core.query.StringQuery.MATCH_ALL;
21+
import static org.springframework.data.elasticsearch.core.query.StringQuery.*;
2222

23-
import org.assertj.core.api.InstanceOfAssertFactories;
24-
import org.springframework.data.elasticsearch.BulkFailureException;
2523
import reactor.core.publisher.Flux;
2624
import reactor.core.publisher.Mono;
2725
import reactor.test.StepVerifier;
@@ -45,6 +43,7 @@
4543
import java.util.stream.Collectors;
4644
import java.util.stream.IntStream;
4745

46+
import org.assertj.core.api.InstanceOfAssertFactories;
4847
import org.json.JSONException;
4948
import org.junit.jupiter.api.BeforeEach;
5049
import org.junit.jupiter.api.DisplayName;
@@ -60,6 +59,7 @@
6059
import org.springframework.data.domain.PageRequest;
6160
import org.springframework.data.domain.Pageable;
6261
import org.springframework.data.domain.Sort;
62+
import org.springframework.data.elasticsearch.BulkFailureException;
6363
import org.springframework.data.elasticsearch.RestStatusException;
6464
import org.springframework.data.elasticsearch.annotations.Document;
6565
import org.springframework.data.elasticsearch.annotations.Field;
@@ -1509,6 +1509,14 @@ public ImmutableEntity(@Nullable String id, String text, @Nullable SeqNoPrimaryT
15091509
this.seqNoPrimaryTerm = seqNoPrimaryTerm;
15101510
}
15111511

1512+
public ImmutableEntity withId(@Nullable String id) {
1513+
return new ImmutableEntity(id, this.text, this.seqNoPrimaryTerm);
1514+
}
1515+
1516+
public ImmutableEntity withSeqNoPrimaryTerm(@Nullable SeqNoPrimaryTerm seqNoPrimaryTerm) {
1517+
return new ImmutableEntity(this.id, this.text, seqNoPrimaryTerm);
1518+
}
1519+
15121520
public String getId() {
15131521
return id;
15141522
}

src/test/java/org/springframework/data/elasticsearch/core/mapping/SimpleElasticsearchPersistentPropertyUnitTests.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ void seqNoPrimaryTermPropertyShouldNotBeWritable() {
185185
assertThat(seqNoProperty.isWritable()).isFalse();
186186
}
187187

188-
@Test // DATAES-799
189-
void seqNoPrimaryTermPropertyShouldNotBeReadable() {
190-
SimpleElasticsearchPersistentEntity<?> entity = context.getRequiredPersistentEntity(SeqNoPrimaryTermProperty.class);
191-
ElasticsearchPersistentProperty seqNoProperty = entity.getRequiredPersistentProperty("seqNoPrimaryTerm");
192-
193-
assertThat(seqNoProperty.isReadable()).isFalse();
194-
}
195-
196188
@Test // DATAES-924
197189
@DisplayName("should require pattern for custom date format")
198190
void shouldRequirePatternForCustomDateFormat() {
@@ -259,12 +251,12 @@ void shouldUseValueConverterAnnotation() {
259251

260252
assertThat(
261253
persistentEntity.getRequiredPersistentProperty("fieldWithClassBasedConverter").getPropertyValueConverter())
262-
.isInstanceOf(ClassBasedValueConverter.class);
254+
.isInstanceOf(ClassBasedValueConverter.class);
263255
assertThat(persistentEntity.getRequiredPersistentProperty("fieldWithClassBasedDerivedFromAbstractValueConverter")
264256
.getPropertyValueConverter()).isInstanceOf(ClassBasedDerivedFromAbstractValueConverter.class);
265257
assertThat(
266258
persistentEntity.getRequiredPersistentProperty("fieldWithEnumBasedConverter").getPropertyValueConverter())
267-
.isInstanceOf(EnumBasedValueConverter.class);
259+
.isInstanceOf(EnumBasedValueConverter.class);
268260
}
269261

270262
// region entities

src/test/java/org/springframework/data/elasticsearch/immutable/ImmutableRepositoryIntegrationTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.springframework.data.elasticsearch.junit.jupiter.SpringIntegrationTest;
3131
import org.springframework.data.elasticsearch.utils.IndexNameProvider;
3232
import org.springframework.data.repository.CrudRepository;
33+
import org.springframework.lang.Nullable;
3334

3435
/**
3536
* @author Young Gu
@@ -90,6 +91,10 @@ public ImmutableEntity(String name) {
9091
this(null, name);
9192
}
9293

94+
public ImmutableEntity withId(@Nullable String id) {
95+
return new ImmutableEntity(id, this.name);
96+
}
97+
9398
public String getId() {
9499
return id;
95100
}

0 commit comments

Comments
 (0)