@@ -909,6 +909,55 @@ void shouldWriteNullValueIfConfigured() throws JSONException {
909
909
assertEquals (expected , document .toJson (), false );
910
910
}
911
911
912
+ @ Test // #2627
913
+ @ DisplayName ("should write Map containing collection containing map" )
914
+ void shouldWriteMapContainingCollectionContainingMap () throws JSONException {
915
+
916
+ class EntityWithMapCollectionMap {
917
+ Map <String , Object > map ;
918
+ }
919
+ class InnerEntity {
920
+ String prop1 ;
921
+
922
+ String prop2 ;
923
+
924
+ public InnerEntity () {}
925
+
926
+ public InnerEntity (String prop1 , String prop2 ) {
927
+ this .prop1 = prop1 ;
928
+ this .prop2 = prop2 ;
929
+ }
930
+
931
+ }
932
+
933
+ var entity = new EntityWithMapCollectionMap ();
934
+ entity .map = Collections .singletonMap ("collection" ,
935
+ Collections .singletonList (Collections .singletonMap ("destination" , new InnerEntity ("prop1" , "prop2" ))));
936
+
937
+ var expected = """
938
+ {
939
+ "_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$1EntityWithMapCollectionMap",
940
+ "map": {
941
+ "collection": [
942
+ {
943
+ "destination": {
944
+ "_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$1InnerEntity",
945
+ "prop1": "prop1",
946
+ "prop2": "prop2"
947
+ }
948
+ }
949
+ ]
950
+ }
951
+ }
952
+ """ ;
953
+
954
+ Document document = Document .create ();
955
+
956
+ mappingElasticsearchConverter .write (entity , document );
957
+
958
+ assertEquals (expected , document .toJson (), false );
959
+ }
960
+
912
961
@ Nested
913
962
class RangeTests {
914
963
@@ -1953,12 +2002,12 @@ void shouldWriteEntityWithDottedFieldName() throws JSONException {
1953
2002
1954
2003
@ Language ("JSON" )
1955
2004
var expected = """
1956
- {
1957
- "_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$FieldNameDotsEntity",
1958
- "id": "42",
1959
- "dotted.field": "dotted field"
1960
- }
1961
- """ ;
2005
+ {
2006
+ "_class": "org.springframework.data.elasticsearch.core.convert.MappingElasticsearchConverterUnitTests$FieldNameDotsEntity",
2007
+ "id": "42",
2008
+ "dotted.field": "dotted field"
2009
+ }
2010
+ """ ;
1962
2011
var entity = new FieldNameDotsEntity ();
1963
2012
entity .setId ("42" );
1964
2013
entity .setDottedField ("dotted field" );
@@ -3192,6 +3241,7 @@ public void setMapToNotWriteWhenEmpty(@Nullable Map<String, String> mapToNotWrit
3192
3241
this .mapToNotWriteWhenEmpty = mapToNotWriteWhenEmpty ;
3193
3242
}
3194
3243
}
3244
+
3195
3245
static class FieldNameDotsEntity {
3196
3246
@ Id
3197
3247
@ Nullable private String id ;
0 commit comments