3434
3535import org .bson .Document ;
3636import org .junit .jupiter .api .BeforeEach ;
37- import org .junit .jupiter .api .DisplayName ;
3837import org .junit .jupiter .api .Nested ;
3938import org .junit .jupiter .api .Test ;
4039
5756 * @author Christoph Strobl
5857 */
5958
60- public class MappingMongoConverterTests {
59+ class MappingMongoConverterTests {
6160
6261 private static final String DATABASE = "mapping-converter-tests" ;
6362
6463 private static @ Client MongoClient client ;
6564
66- private MongoDatabaseFactory factory = new SimpleMongoClientDatabaseFactory (client , DATABASE );
65+ private final MongoDatabaseFactory factory = new SimpleMongoClientDatabaseFactory (client , DATABASE );
6766
6867 private MappingMongoConverter converter ;
6968 private MongoMappingContext mappingContext ;
@@ -483,48 +482,26 @@ public String toString() {
483482 }
484483
485484 @ Nested // GH-5065
486- @ DisplayName ("GH-5065: Empty Map Tests" )
487485 class EmptyMapTests {
488486
489487 @ Test // GH-5065
490- @ DisplayName ("Test control: Passing test to indicate that the problem is not a more generic issue with maps in general." )
491- void readsEmptyMapCorrectly () {
492- org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
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 ();
505- }
506-
507- @ Test // GH-5065
508- @ DisplayName ("Converter should read an empty object as an empty map when using @DocumentReference." )
509- void readsEmptyMapWithDocumentReferenceCorrectly () {
488+ void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDocumentReferenceAnnotation () {
510489 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
511490 //DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
512491 assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
513492 assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
514493 }
515494
516495 @ Test // GH-5065
517- @ DisplayName ("Converter should read an explicitly assigned null as a null map when using @DocumentReference." )
518- void readsExplicitlyNullMapWithDocumentReferenceCorrectly () {
496+ void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDocumentReferenceAnnotation () {
519497 org .bson .Document document = org .bson .Document .parse ("{\" map\" :null}" );
520498 //DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
521499 assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).map ).isNull ();
522500 assertThat (converter .read (DocumentReferenceEmptyMapDocument .class , document ).getMap ()).isNull ();
523501 }
524502
525503 @ 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)." )
527- void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly () {
504+ void converterShouldReadAnEmptyObjectAsAnEmptyMapWithAValidValuesPropertyWhenUsingDocumentReferenceAnnotationWithLazyEqualToTrue () {
528505 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
529506 //LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
530507 assertThat (converter .read (LazyDocumentReferenceEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
@@ -534,36 +511,21 @@ void readsEmptyMapWithLazyLoadedDocumentReferenceCorrectly() {
534511 }
535512
536513 @ Test // GH-5065
537- @ DisplayName ("Converter should read an empty object as an empty map when using @DBRef." )
538- void readsEmptyMapWithDBRefCorrectly () {
514+ void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDBRefAnnotation () {
539515 org .bson .Document document = org .bson .Document .parse ("{\" map\" :{}}" );
540516 //DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
541517 assertThat (converter .read (DBRefEmptyMapDocument .class , document ).map ).isNotNull ().isEmpty ();
542518 assertThat (converter .read (DBRefEmptyMapDocument .class , document ).getMap ()).isNotNull ().isEmpty ();
543519 }
544520
545521 @ Test // GH-5065
546- @ DisplayName ("Converter should read an explicitly assigned null as a null map when using @DBRef." )
547- void readsExplicitlyNullMapWithDBRefCorrectly () {
522+ void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDBRefAnnotation () {
548523 org .bson .Document document = org .bson .Document .parse ("{\" map\" :null}" );
549524 //DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
550525 assertThat (converter .read (DBRefEmptyMapDocument .class , document ).map ).isNull ();
551526 assertThat (converter .read (DBRefEmptyMapDocument .class , document ).getMap ()).isNull ();
552527 }
553528
554- static class EmptyMapDocument {
555-
556- Map <String , String > map ;
557-
558- public EmptyMapDocument (Map <String , String > map ) {
559- this .map = map ;
560- }
561-
562- Map <String , String > getMap () {
563- return map ;
564- }
565- }
566-
567529 static class DocumentReferenceEmptyMapDocument {
568530
569531 @ DocumentReference
0 commit comments