|
35 | 35 | import org.junit.jupiter.api.BeforeEach;
|
36 | 36 | import org.junit.jupiter.api.Test;
|
37 | 37 | import org.junit.jupiter.api.extension.ExtendWith;
|
| 38 | +import org.junit.jupiter.params.ParameterizedTest; |
| 39 | +import org.junit.jupiter.params.provider.ValueSource; |
38 | 40 | import org.mockito.Mockito;
|
39 | 41 | import org.mockito.junit.jupiter.MockitoExtension;
|
40 | 42 | import org.springframework.core.convert.converter.Converter;
|
@@ -1213,34 +1215,26 @@ void mapNestedStringFieldCorrectly() {
|
1213 | 1215 | assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.a.b.d", "e")));
|
1214 | 1216 | }
|
1215 | 1217 |
|
1216 |
| - @Test // GH-3775 |
1217 |
| - void mapNestedIntegerFieldCorrectly() { |
| 1218 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1219 | + @ValueSource(strings = {"levelOne.0.1.3", "levelOne.0.1.32", "levelOne2.0.1.32", "levelOne2.0.1.320"}) |
| 1220 | + void mapNestedIntegerFieldCorrectly(String path) { |
1218 | 1221 |
|
1219 |
| - Update update = new Update().set("levelOne.0.1.3", "4"); |
| 1222 | + Update update = new Update().set(path, "4"); |
1220 | 1223 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1221 | 1224 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1222 | 1225 |
|
1223 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.3", "4"))); |
| 1226 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1224 | 1227 | }
|
1225 | 1228 |
|
1226 |
| - @Test |
1227 |
| - void mapNestedLastBigIntegerFieldCorrectly() { |
1228 |
| - |
1229 |
| - Update update = new Update().set("levelOne.0.1.32", "4"); |
1230 |
| - Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), |
1231 |
| - context.getPersistentEntity(EntityWithNestedMap.class)); |
1232 |
| - |
1233 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.32", "4"))); |
1234 |
| - } |
1235 |
| - |
1236 |
| - @Test // GH-3775 |
1237 |
| - void mapNestedMixedStringIntegerFieldCorrectly() { |
| 1229 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1230 | + @ValueSource(strings = {"levelOne.0.1.c", "levelOne.0.1.c.32", "levelOne2.0.1.32.c", "levelOne2.0.1.c.320"}) |
| 1231 | + void mapNestedMixedStringIntegerFieldCorrectly(String path) { |
1238 | 1232 |
|
1239 |
| - Update update = new Update().set("levelOne.0.1.c", "4"); |
| 1233 | + Update update = new Update().set(path, "4"); |
1240 | 1234 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1241 | 1235 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1242 | 1236 |
|
1243 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.c", "4"))); |
| 1237 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1244 | 1238 | }
|
1245 | 1239 |
|
1246 | 1240 | @Test // GH-3775
|
@@ -1730,7 +1724,6 @@ static class UnwrappableType {
|
1730 | 1724 |
|
1731 | 1725 | static class EntityWithNestedMap {
|
1732 | 1726 | Map<String, Map<String, Map<String, Object>>> levelOne;
|
1733 |
| - // for test mapNestedLastBigIntegerFieldCorrectly() |
1734 | 1727 | Map<String, Map<String, Map<String, Object>>> levelOne2;
|
1735 | 1728 | }
|
1736 | 1729 |
|
|
0 commit comments