@@ -932,6 +932,34 @@ public void mappingShouldConvertMapKeysToString() {
932
932
}
933
933
}
934
934
935
+ @ Test // DATAMONGO-1772
936
+ public void mappingShouldAddTypeKeyInListOfInterfaceTypeContainedInConcreteObjectCorrectly () {
937
+
938
+ ConcreteInner inner = new ConcreteInner ();
939
+ inner .interfaceTypeList = Collections .singletonList (new SomeInterfaceImpl ());
940
+ List <ConcreteInner > list = Collections .singletonList (inner );
941
+
942
+ Document mappedUpdate = mapper .getMappedObject (new Update ().set ("concreteInnerList" , list ).getUpdateObject (),
943
+ context .getPersistentEntity (Outer .class ));
944
+
945
+ assertThat (mappedUpdate , isBsonObject ().containing ("$set.concreteInnerList.[0].interfaceTypeList.[0]._class" )
946
+ .notContaining ("$set.concreteInnerList.[0]._class" ));
947
+ }
948
+
949
+ @ Test // DATAMONGO-1772
950
+ public void mappingShouldAddTypeKeyInListOfAbstractTypeContainedInConcreteObjectCorrectly () {
951
+
952
+ ConcreteInner inner = new ConcreteInner ();
953
+ inner .abstractTypeList = Collections .singletonList (new SomeInterfaceImpl ());
954
+ List <ConcreteInner > list = Collections .singletonList (inner );
955
+
956
+ Document mappedUpdate = mapper .getMappedObject (new Update ().set ("concreteInnerList" , list ).getUpdateObject (),
957
+ context .getPersistentEntity (Outer .class ));
958
+
959
+ assertThat (mappedUpdate , isBsonObject ().containing ("$set.concreteInnerList.[0].abstractTypeList.[0]._class" )
960
+ .notContaining ("$set.concreteInnerList.[0]._class" ));
961
+ }
962
+
935
963
static class DomainTypeWrappingConcreteyTypeHavingListOfInterfaceTypeAttributes {
936
964
ListModelWrapper concreteTypeWithListAttributeOfInterfaceType ;
937
965
}
@@ -1218,4 +1246,26 @@ static class SimpleValueHolder {
1218
1246
Integer intValue ;
1219
1247
int primIntValue ;
1220
1248
}
1249
+
1250
+ static class Outer {
1251
+ List <ConcreteInner > concreteInnerList ;
1252
+ }
1253
+
1254
+ static class ConcreteInner {
1255
+ List <SomeInterfaceType > interfaceTypeList ;
1256
+ List <SomeAbstractType > abstractTypeList ;
1257
+ }
1258
+
1259
+ interface SomeInterfaceType {
1260
+
1261
+ }
1262
+
1263
+ static abstract class SomeAbstractType {
1264
+
1265
+ }
1266
+
1267
+ static class SomeInterfaceImpl extends SomeAbstractType implements SomeInterfaceType {
1268
+
1269
+ }
1270
+
1221
1271
}
0 commit comments