|
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 |
|
@@ -1212,34 +1214,26 @@ void mapNestedStringFieldCorrectly() {
|
1212 | 1214 | assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.a.b.d", "e")));
|
1213 | 1215 | }
|
1214 | 1216 |
|
1215 |
| - @Test // GH-3775 |
1216 |
| - void mapNestedIntegerFieldCorrectly() { |
| 1217 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1218 | + @ValueSource(strings = {"levelOne.0.1.3", "levelOne.0.1.32", "levelOne2.0.1.32", "levelOne2.0.1.320"}) |
| 1219 | + void mapNestedIntegerFieldCorrectly(String path) { |
1217 | 1220 |
|
1218 |
| - Update update = new Update().set("levelOne.0.1.3", "4"); |
| 1221 | + Update update = new Update().set(path, "4"); |
1219 | 1222 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1220 | 1223 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1221 | 1224 |
|
1222 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.3", "4"))); |
| 1225 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1223 | 1226 | }
|
1224 | 1227 |
|
1225 |
| - @Test |
1226 |
| - void mapNestedLastBigIntegerFieldCorrectly() { |
1227 |
| - |
1228 |
| - Update update = new Update().set("levelOne.0.1.32", "4"); |
1229 |
| - Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(), |
1230 |
| - context.getPersistentEntity(EntityWithNestedMap.class)); |
1231 |
| - |
1232 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.32", "4"))); |
1233 |
| - } |
1234 |
| - |
1235 |
| - @Test // GH-3775 |
1236 |
| - void mapNestedMixedStringIntegerFieldCorrectly() { |
| 1228 | + @ParameterizedTest // GH-3775, GH-4426 |
| 1229 | + @ValueSource(strings = {"levelOne.0.1.c", "levelOne.0.1.c.32", "levelOne2.0.1.32.c", "levelOne2.0.1.c.320"}) |
| 1230 | + void mapNestedMixedStringIntegerFieldCorrectly(String path) { |
1237 | 1231 |
|
1238 |
| - Update update = new Update().set("levelOne.0.1.c", "4"); |
| 1232 | + Update update = new Update().set(path, "4"); |
1239 | 1233 | Document mappedUpdate = mapper.getMappedObject(update.getUpdateObject(),
|
1240 | 1234 | context.getPersistentEntity(EntityWithNestedMap.class));
|
1241 | 1235 |
|
1242 |
| - assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document("levelOne.0.1.c", "4"))); |
| 1236 | + assertThat(mappedUpdate).isEqualTo(new org.bson.Document("$set", new org.bson.Document(path, "4"))); |
1243 | 1237 | }
|
1244 | 1238 |
|
1245 | 1239 | @Test // GH-3775
|
@@ -1729,7 +1723,6 @@ static class UnwrappableType {
|
1729 | 1723 |
|
1730 | 1724 | static class EntityWithNestedMap {
|
1731 | 1725 | Map<String, Map<String, Map<String, Object>>> levelOne;
|
1732 |
| - // for test mapNestedLastBigIntegerFieldCorrectly() |
1733 | 1726 | Map<String, Map<String, Map<String, Object>>> levelOne2;
|
1734 | 1727 | }
|
1735 | 1728 |
|
|
0 commit comments