|
31 | 31 | import org.junit.jupiter.api.BeforeEach;
|
32 | 32 | import org.junit.jupiter.api.Test;
|
33 | 33 | import org.junit.jupiter.api.extension.ExtendWith;
|
| 34 | +import org.junit.jupiter.params.ParameterizedTest; |
| 35 | +import org.junit.jupiter.params.provider.ValueSource; |
34 | 36 | import org.mockito.Mockito;
|
35 | 37 | import org.mockito.junit.jupiter.MockitoExtension;
|
36 | 38 | import org.springframework.core.convert.converter.Converter;
|
@@ -1207,34 +1209,26 @@ void mapNestedStringFieldCorrectly() {
|
1207 | 1209 | assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.a.b.d", "e")));
|
1208 | 1210 | }
|
1209 | 1211 |
|
1210 |
| - @Test // GH-3775 |
1211 |
| - void mapNestedIntegerFieldCorrectly() { |
| 1212 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1213 | + @ValueSource(strings = {"levelOne.0.1.3", "levelOne.0.1.32", "levelOne2.0.1.32", "levelOne2.0.1.320"}) |
| 1214 | + void mapNestedIntegerFieldCorrectly(String path) { |
1212 | 1215 |
|
1213 |
| - Update update = new Update().set("levelOne.0.1.3", "4"); |
| 1216 | + Update update = new Update().set(path, "4"); |
1214 | 1217 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1215 | 1218 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1216 | 1219 |
|
1217 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.3", "4"))); |
| 1220 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1218 | 1221 | }
|
1219 | 1222 |
|
1220 |
| - @Test |
1221 |
| - void mapNestedLastBigIntegerFieldCorrectly() { |
1222 |
| - |
1223 |
| - Update update = new Update().set("levelOne.0.1.32", "4"); |
1224 |
| - Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), |
1225 |
| - context.getPersistentEntity(EntityWithNestedMap.class)); |
1226 |
| - |
1227 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.32", "4"))); |
1228 |
| - } |
1229 |
| - |
1230 |
| - @Test // GH-3775 |
1231 |
| - void mapNestedMixedStringIntegerFieldCorrectly() { |
| 1223 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1224 | + @ValueSource(strings = {"levelOne.0.1.c", "levelOne.0.1.c.32", "levelOne2.0.1.32.c", "levelOne2.0.1.c.320"}) |
| 1225 | + void mapNestedMixedStringIntegerFieldCorrectly(String path) { |
1232 | 1226 |
|
1233 |
| - Update update = new Update().set("levelOne.0.1.c", "4"); |
| 1227 | + Update update = new Update().set(path, "4"); |
1234 | 1228 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1235 | 1229 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1236 | 1230 |
|
1237 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.c", "4"))); |
| 1231 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1238 | 1232 | }
|
1239 | 1233 |
|
1240 | 1234 | @Test // GH-3775
|
@@ -1742,7 +1736,6 @@ static class UnwrappableType {
|
1742 | 1736 |
|
1743 | 1737 | static class EntityWithNestedMap {
|
1744 | 1738 | Map<String, Map<String, Map<String, Object>>> levelOne;
|
1745 |
| - // for test mapNestedLastBigIntegerFieldCorrectly() |
1746 | 1739 | Map<String, Map<String, Map<String, Object>>> levelOne2;
|
1747 | 1740 | }
|
1748 | 1741 |
|
|
0 commit comments