Skip to content

Commit e4a7ec6

Browse files
committed
Splitting tests that might have side effects into separate tests
1 parent 58206e0 commit e4a7ec6

File tree

1 file changed

+59
-17
lines changed

1 file changed

+59
-17
lines changed

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/core/convert/MappingMongoConverterTests.java

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -487,43 +487,85 @@ class EmptyMapTests {
487487
@Test // GH-5065
488488
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDocumentReferenceAnnotation() {
489489
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
490-
//DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
491-
assertThat(converter.read(DocumentReferenceEmptyMapDocument.class, document).map).isNotNull().isEmpty();
492-
assertThat(converter.read(DocumentReferenceEmptyMapDocument.class, document).getMap()).isNotNull().isEmpty();
490+
DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
491+
assertThat(target.map).isNotNull().isEmpty();
492+
}
493+
494+
@Test // GH-5065
495+
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDocumentReferenceAnnotationUsingGetMap() {
496+
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
497+
DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
498+
assertThat(target.getMap()).isNotNull().isEmpty();
493499
}
494500

495501
@Test // GH-5065
496502
void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDocumentReferenceAnnotation() {
497503
org.bson.Document document = org.bson.Document.parse("{\"map\":null}");
498-
//DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
499-
assertThat(converter.read(DocumentReferenceEmptyMapDocument.class, document).map).isNull();
500-
assertThat(converter.read(DocumentReferenceEmptyMapDocument.class, document).getMap()).isNull();
504+
DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
505+
assertThat(target.map).isNull();
506+
}
507+
508+
@Test // GH-5065
509+
void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDocumentReferenceAnnotationUsingGetMap() {
510+
org.bson.Document document = org.bson.Document.parse("{\"map\":null}");
511+
DocumentReferenceEmptyMapDocument target = converter.read(DocumentReferenceEmptyMapDocument.class, document);
512+
assertThat(target.getMap()).isNull();
513+
}
514+
515+
@Test // GH-5065
516+
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDocumentReferenceAnnotationWithLazyEqualToTrue() {
517+
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
518+
LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
519+
assertThat(target.map).isNotNull().isEmpty();
501520
}
502521

503522
@Test // GH-5065
504523
void converterShouldReadAnEmptyObjectAsAnEmptyMapWithAValidValuesPropertyWhenUsingDocumentReferenceAnnotationWithLazyEqualToTrue() {
505524
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
506-
//LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
507-
assertThat(converter.read(LazyDocumentReferenceEmptyMapDocument.class, document).map).isNotNull().isEmpty();
508-
assertThat(converter.read(LazyDocumentReferenceEmptyMapDocument.class, document).getMap()).isNotNull().isEmpty();
509-
assertThat(converter.read(LazyDocumentReferenceEmptyMapDocument.class, document).map.values()).isNotNull().isEmpty();
510-
assertThat(converter.read(LazyDocumentReferenceEmptyMapDocument.class, document).getMap().values()).isNotNull().isEmpty();
525+
LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
526+
assertThat(target.map.values()).isNotNull().isEmpty();
527+
}
528+
529+
@Test // GH-5065
530+
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDocumentReferenceAnnotationWithLazyEqualToTrueUsingGetMap() {
531+
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
532+
LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
533+
assertThat(target.getMap()).isNotNull().isEmpty();
534+
}
535+
536+
@Test // GH-5065
537+
void converterShouldReadAnEmptyObjectAsAnEmptyMapWithAValidValuesPropertyWhenUsingDocumentReferenceAnnotationWithLazyEqualToTrueUsingGetMap() {
538+
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
539+
LazyDocumentReferenceEmptyMapDocument target = converter.read(LazyDocumentReferenceEmptyMapDocument.class, document);
540+
assertThat(target.getMap().values()).isNotNull().isEmpty();
511541
}
512542

513543
@Test // GH-5065
514544
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDBRefAnnotation() {
515545
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
516-
//DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
517-
assertThat(converter.read(DBRefEmptyMapDocument.class, document).map).isNotNull().isEmpty();
518-
assertThat(converter.read(DBRefEmptyMapDocument.class, document).getMap()).isNotNull().isEmpty();
546+
DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
547+
assertThat(target.map).isNotNull().isEmpty();
548+
}
549+
550+
@Test // GH-5065
551+
void converterShouldReadAnEmptyObjectAsAnEmptyMapWhenUsingDBRefAnnotationUsingGetMap() {
552+
org.bson.Document document = org.bson.Document.parse("{\"map\":{}}");
553+
DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
554+
assertThat(target.getMap()).isNotNull().isEmpty();
519555
}
520556

521557
@Test // GH-5065
522558
void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDBRefAnnotation() {
523559
org.bson.Document document = org.bson.Document.parse("{\"map\":null}");
524-
//DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
525-
assertThat(converter.read(DBRefEmptyMapDocument.class, document).map).isNull();
526-
assertThat(converter.read(DBRefEmptyMapDocument.class, document).getMap()).isNull();
560+
DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
561+
assertThat(target.map).isNull();
562+
}
563+
564+
@Test // GH-5065
565+
void converterShouldReadAnExplicitlyAssignedNullAsANullMapWhenUsingDBRefAnnotationUsingGetMap() {
566+
org.bson.Document document = org.bson.Document.parse("{\"map\":null}");
567+
DBRefEmptyMapDocument target = converter.read(DBRefEmptyMapDocument.class, document);
568+
assertThat(target.getMap()).isNull();
527569
}
528570

529571
static class DocumentReferenceEmptyMapDocument {

0 commit comments

Comments
 (0)