|
17 | 17 |
|
18 | 18 | import static org.assertj.core.api.Assertions.*;
|
19 | 19 |
|
| 20 | +import org.junit.jupiter.api.DisplayName; |
20 | 21 | import org.junit.jupiter.api.Test;
|
21 | 22 | import org.springframework.data.annotation.Id;
|
22 | 23 | import org.springframework.data.annotation.Version;
|
| 24 | +import org.springframework.data.elasticsearch.annotations.Document; |
23 | 25 | import org.springframework.data.elasticsearch.annotations.Field;
|
| 26 | +import org.springframework.data.elasticsearch.annotations.FieldType; |
| 27 | +import org.springframework.data.elasticsearch.core.MappingContextBaseTests; |
24 | 28 | import org.springframework.data.elasticsearch.core.query.SeqNoPrimaryTerm;
|
25 | 29 | import org.springframework.data.mapping.MappingException;
|
26 | 30 | import org.springframework.data.mapping.model.Property;
|
|
38 | 42 | * @author Peter-Josef Meisch
|
39 | 43 | * @author Roman Puchkovskiy
|
40 | 44 | */
|
41 |
| -public class SimpleElasticsearchPersistentEntityTests { |
| 45 | +public class SimpleElasticsearchPersistentEntityTests extends MappingContextBaseTests { |
42 | 46 |
|
43 | 47 | @Test
|
44 | 48 | public void shouldThrowExceptionGivenVersionPropertyIsNotLong() {
|
@@ -135,6 +139,12 @@ void shouldNotAllowMoreThanOneSeqNoPrimaryTermProperties() {
|
135 | 139 | .isInstanceOf(MappingException.class);
|
136 | 140 | }
|
137 | 141 |
|
| 142 | + @Test // #1680 |
| 143 | + @DisplayName("should allow fields with id property names") |
| 144 | + void shouldAllowFieldsWithIdPropertyNames() { |
| 145 | + elasticsearchConverter.get().getMappingContext().getRequiredPersistentEntity(EntityWithIdNameFields.class); |
| 146 | + } |
| 147 | + |
138 | 148 | private static SimpleElasticsearchPersistentProperty createProperty(SimpleElasticsearchPersistentEntity<?> entity,
|
139 | 149 | String field) {
|
140 | 150 |
|
@@ -193,4 +203,11 @@ private static class EntityWithSeqNoPrimaryTerm {
|
193 | 203 | private SeqNoPrimaryTerm seqNoPrimaryTerm;
|
194 | 204 | private SeqNoPrimaryTerm seqNoPrimaryTerm2;
|
195 | 205 | }
|
| 206 | + |
| 207 | + @Document(indexName = "fieldnames") |
| 208 | + private static class EntityWithIdNameFields { |
| 209 | + @Id private String theRealId; |
| 210 | + @Field(type = FieldType.Text, name = "document") private String document; |
| 211 | + @Field(name = "id") private String renamedId; |
| 212 | + } |
196 | 213 | }
|
0 commit comments