21
21
import static org .springframework .data .mongodb .core .DocumentTestUtils .*;
22
22
import static org .springframework .data .mongodb .test .util .IsBsonObject .*;
23
23
24
+ import lombok .AllArgsConstructor ;
25
+ import lombok .NoArgsConstructor ;
26
+
24
27
import java .time .LocalDate ;
25
28
import java .util .Arrays ;
26
29
import java .util .Collections ;
@@ -677,6 +680,23 @@ public void mappingShouldRetainTypeInformationOfNestedListWhenUpdatingConcreteyP
677
680
.containing ("$set.concreteTypeWithListAttributeOfInterfaceType.models.[0]._class" , ModelImpl .class .getName ()));
678
681
}
679
682
683
+ @ Test // DATAMONGO-1809
684
+ public void pathShouldIdentifyPositionalParameterWithMoreThanOneDigit () {
685
+
686
+ Document at2digitPosition = mapper .getMappedObject (new Update ()
687
+ .addToSet ("concreteInnerList.10.concreteTypeList" , new SomeInterfaceImpl ("szeth" )).getUpdateObject (),
688
+ context .getPersistentEntity (Outer .class ));
689
+
690
+ Document at3digitPosition = mapper .getMappedObject (new Update ()
691
+ .addToSet ("concreteInnerList.123.concreteTypeList" , new SomeInterfaceImpl ("lopen" )).getUpdateObject (),
692
+ context .getPersistentEntity (Outer .class ));
693
+
694
+ assertThat (at2digitPosition , is (equalTo (new Document ("$addToSet" ,
695
+ new Document ("concreteInnerList.10.concreteTypeList" , new Document ("value" , "szeth" ))))));
696
+ assertThat (at3digitPosition , is (equalTo (new Document ("$addToSet" ,
697
+ new Document ("concreteInnerList.123.concreteTypeList" , new Document ("value" , "lopen" ))))));
698
+ }
699
+
680
700
@ Test // DATAMONGO-1236
681
701
public void mappingShouldRetainTypeInformationForObjectValues () {
682
702
@@ -1254,6 +1274,7 @@ static class Outer {
1254
1274
static class ConcreteInner {
1255
1275
List <SomeInterfaceType > interfaceTypeList ;
1256
1276
List <SomeAbstractType > abstractTypeList ;
1277
+ List <SomeInterfaceImpl > concreteTypeList ;
1257
1278
}
1258
1279
1259
1280
interface SomeInterfaceType {
@@ -1264,8 +1285,11 @@ static abstract class SomeAbstractType {
1264
1285
1265
1286
}
1266
1287
1288
+ @ AllArgsConstructor
1289
+ @ NoArgsConstructor
1267
1290
static class SomeInterfaceImpl extends SomeAbstractType implements SomeInterfaceType {
1268
1291
1292
+ String value ;
1269
1293
}
1270
1294
1271
1295
}
0 commit comments