@@ -487,28 +487,68 @@ public String toString() {
487487 class EmptyMapTests {
488488
489489 @ Test // GH-5065
490- @ DisplayName ("Passing test to indicate that the problem is not a more generic issue with maps in general." )
490+ @ DisplayName ("Test control: Passing test to indicate that the problem is not a more generic issue with maps in general." )
491491 void readsEmptyMapCorrectly () {
492492 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
493- EmptyMapDocument target = converter .read (EmptyMapDocument .class , document );
494- assertThat (target .map ).isNotNull ().isEmpty ();
493+ //EmptyMapDocument target = converter.read(EmptyMapDocument.class, document);
494+ assertThat (converter .read (EmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
495+ assertThat (converter .read (EmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
496+ }
497+
498+ @ Test // GH-5065
499+ @ DisplayName ("Test control: Converter should read an explicitly assigned null as a null map." )
500+ void readsExplicitlyNullMapCorrectly () {
501+ org .bson .Document document = org .bson .Document .parse ("{\" map\" :null}" );
502+ //EmptyMapDocument target = converter.read(EmptyMapDocument.class, document);
503+ assertThat (converter .read (EmptyMapDocument .class , document ).map ).isNull ();
504+ assertThat (converter .read (EmptyMapDocument .class , document ).getMap ()).isNull ();
495505 }
496506
497507 @ Test // GH-5065
498508 @ DisplayName ("Converter should read an empty object as an empty map when using @DocumentReference." )
499509 void readsEmptyMapWithDocumentReferenceCorrectly () {
500510 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
501- DocumentReferenceEmptyMapDocument target = converter .read (DocumentReferenceEmptyMapDocument .class , document );
502- assertThat (target .map ).isNotNull ().isEmpty ();
511+ //DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
512+ assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
513+ assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
503514 }
504515
505516 @ Test // GH-5065
506- @ DisplayName ("Converter should read an empty object as an empty map with a valis values property when using @DocumentReference(lazy = true)." )
517+ @ DisplayName ("Converter should read an explicitly assigned null as a null map when using @DocumentReference." )
518+ void readsExplicitlyNullMapWithDocumentReferenceCorrectly () {
519+ org .bson .Document document = org .bson .Document .parse ("{\" map\" :null}" );
520+ //DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
521+ assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).map ).isNull ();
522+ assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).getMap ()).isNull ();
523+ }
524+
525+ @ Test // GH-5065
526+ @ DisplayName ("Converter should read an empty object as an empty map with a valid values property when using @DocumentReference(lazy = true)." )
507527 void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly () {
508528 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
509- LazyDocumentReferenceEmptyMapDocument target = converter .read (LazyDocumentReferenceEmptyMapDocument .class , document );
510- assertThat (target .map ).isNotNull ();
511- assertThat (target .map .values ()).isNotNull ();
529+ //LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
530+ assertThat (converter .read (LazyDocumentReferenceEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
531+ assertThat (converter .read (LazyDocumentReferenceEmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
532+ assertThat (converter .read (LazyDocumentReferenceEmptyMapDocument .class , document ).map .values ()).isNotNull ().isEmpty ();
533+ assertThat (converter .read (LazyDocumentReferenceEmptyMapDocument .class , document ).getMap ().values ()).isNotNull ().isEmpty ();
534+ }
535+
536+ @ Test // GH-5065
537+ @ DisplayName ("Converter should read an empty object as an empty map when using @DBRef." )
538+ void readsEmptyMapWithDBRefCorrectly () {
539+ org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
540+ //DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
541+ assertThat (converter .read (DBRefEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
542+ assertThat (converter .read (DBRefEmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
543+ }
544+
545+ @ Test // GH-5065
546+ @ DisplayName ("Converter should read an explicitly assigned null as a null map when using @DBRef." )
547+ void readsExplicitlyNullMapWithDBRefCorrectly () {
548+ org .bson .Document document = org .bson .Document .parse ("{\" map\" :null}" );
549+ //DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
550+ assertThat (converter .read (DBRefEmptyMapDocument .class , document ).map ).isNull ();
551+ assertThat (converter .read (DBRefEmptyMapDocument .class , document ).getMap ()).isNull ();
512552 }
513553
514554 static class EmptyMapDocument {
@@ -518,6 +558,10 @@ static class EmptyMapDocument {
518558 public EmptyMapDocument (Map <String , String > map ) {
519559 this .map = map ;
520560 }
561+
562+ Map <String , String > getMap () {
563+ return map ;
564+ }
521565 }
522566
523567 static class DocumentReferenceEmptyMapDocument {
@@ -528,6 +572,10 @@ static class DocumentReferenceEmptyMapDocument {
528572 public DocumentReferenceEmptyMapDocument (Map <String , String > map ) {
529573 this .map = map ;
530574 }
575+
576+ Map <String , String > getMap () {
577+ return map ;
578+ }
531579 }
532580
533581 static class LazyDocumentReferenceEmptyMapDocument {
@@ -538,6 +586,24 @@ static class LazyDocumentReferenceEmptyMapDocument {
538586 public LazyDocumentReferenceEmptyMapDocument (Map <String , String > map ) {
539587 this .map = map ;
540588 }
589+
590+ Map <String , String > getMap () {
591+ return map ;
592+ }
593+ }
594+ }
595+
596+ static class DBRefEmptyMapDocument {
597+
598+ @ DBRef
599+ Map <String , String > map ;
600+
601+ public DBRefEmptyMapDocument (Map <String , String > map ) {
602+ this .map = map ;
603+ }
604+
605+ Map <String , String > getMap () {
606+ return map ;
541607 }
542608 }
543609
0 commit comments