@@ -1413,9 +1413,45 @@ void iterable_soft_assertions_should_report_errors_on_final_methods_and_methods_
1413
1413
.filteredOnAssertions (name -> assertThat (name .first ).startsWith ("Jo" ))
1414
1414
.as ("filteredOn with consumer" )
1415
1415
.hasSize (5 );
1416
+ softly .assertThat (characters )
1417
+ .as ("using flatMap on Iterable" )
1418
+ .overridingErrorMessage ("error message" )
1419
+ .flatMap (childrenExtractor )
1420
+ .containsAnyOf (homer , fred );
1421
+ softly .assertThat (characters )
1422
+ .as ("using flatMap on Iterable with exception" )
1423
+ .overridingErrorMessage ("error message" )
1424
+ .flatMap (CartoonCharacter ::getChildrenWithException )
1425
+ .containsExactlyInAnyOrder (homer , fred );
1426
+ softly .assertThat (names )
1427
+ .overridingErrorMessage ("error message" )
1428
+ .as ("flatMap with multiple Extractors" )
1429
+ .flatMap (firstNameFunction , lastNameFunction )
1430
+ .contains ("John" , "Jane" , "Doe" )
1431
+ .contains ("Sauron" );
1432
+ softly .assertThat (names )
1433
+ .overridingErrorMessage ("error message" )
1434
+ .as ("flatMap with multiple ThrowingExtractors" )
1435
+ .flatMap (throwingFirstNameFunction , throwingLastNameFunction )
1436
+ .contains ("John" , "Jane" , "Doe" )
1437
+ .contains ("Sauron" );
1438
+ softly .assertThat (names )
1439
+ .as ("map(throwingFirstNameFunction)" )
1440
+ .overridingErrorMessage ("error message" )
1441
+ .map (throwingFirstNameFunction )
1442
+ .contains ("frodo" );
1443
+ softly .assertThat (names )
1444
+ .as ("map(firstNameFunction)" )
1445
+ .map (firstNameFunction )
1446
+ .contains ("sam" );
1447
+ softly .assertThat (names )
1448
+ .map (firstNameFunction , lastNameFunction )
1449
+ .as ("map with multiple functions" )
1450
+ .contains (tuple ("John" , "Doe" ))
1451
+ .contains (tuple ("Frodo" , "Baggins" ));
1416
1452
// THEN
1417
1453
List <Throwable > errorsCollected = softly .errorsCollected ();
1418
- assertThat (errorsCollected ).hasSize (33 );
1454
+ assertThat (errorsCollected ).hasSize (40 );
1419
1455
assertThat (errorsCollected .get (0 )).hasMessage ("[extracting(throwingFirstNameFunction)] error message" );
1420
1456
assertThat (errorsCollected .get (1 )).hasMessage ("[extracting(throwingFirstNameFunction)] error message" );
1421
1457
assertThat (errorsCollected .get (2 )).hasMessage ("[extracting(\" last\" )] error message" );
@@ -1449,6 +1485,13 @@ void iterable_soft_assertions_should_report_errors_on_final_methods_and_methods_
1449
1485
assertThat (errorsCollected .get (30 )).hasMessage ("[using flatExtracting(String... fieldOrPropertyNames)] error message" );
1450
1486
assertThat (errorsCollected .get (31 )).hasMessage ("[using flatExtracting(String fieldOrPropertyName)] error message" );
1451
1487
assertThat (errorsCollected .get (32 )).hasMessage ("[filteredOn with consumer] error message" );
1488
+ assertThat (errorsCollected .get (33 )).hasMessageContaining ("using flatMap on Iterable" );
1489
+ assertThat (errorsCollected .get (34 )).hasMessageContaining ("using flatMap on Iterable with exception" );
1490
+ assertThat (errorsCollected .get (35 )).hasMessageContaining ("flatMap with multiple Extractors" );
1491
+ assertThat (errorsCollected .get (36 )).hasMessageContaining ("flatMap with multiple ThrowingExtractors" );
1492
+ assertThat (errorsCollected .get (37 )).hasMessageContaining ("map(throwingFirstNameFunction)" );
1493
+ assertThat (errorsCollected .get (38 )).hasMessageContaining ("map(firstNameFunction)" );
1494
+ assertThat (errorsCollected .get (39 )).hasMessageContaining ("map with multiple functions" );
1452
1495
}
1453
1496
1454
1497
// the test would fail if any method was not proxyable as the assertion error would not be softly caught
@@ -1597,9 +1640,45 @@ void list_soft_assertions_should_report_errors_on_final_methods_and_methods_that
1597
1640
.filteredOnAssertions (name -> assertThat (name .first ).startsWith ("Jo" ))
1598
1641
.as ("filteredOn with consumer" )
1599
1642
.hasSize (5 );
1643
+ softly .assertThat (names )
1644
+ .overridingErrorMessage ("error message" )
1645
+ .as ("flatMap with multiple Extractors" )
1646
+ .flatMap (firstNameFunction , lastNameFunction )
1647
+ .contains ("John" , "Jane" , "Doe" )
1648
+ .contains ("Sauron" );
1649
+ softly .assertThat (names )
1650
+ .overridingErrorMessage ("error message" )
1651
+ .as ("flatMap with multiple ThrowingExtractors" )
1652
+ .flatMap (throwingFirstNameFunction , throwingLastNameFunction )
1653
+ .contains ("John" , "Jane" , "Doe" )
1654
+ .contains ("Sauron" );
1655
+ softly .assertThat (characters )
1656
+ .as ("using flatMap on Iterable" )
1657
+ .overridingErrorMessage ("error message" )
1658
+ .flatMap (childrenExtractor )
1659
+ .containsAnyOf (homer , fred );
1660
+ softly .assertThat (characters )
1661
+ .as ("using flatMap on Iterable with exception" )
1662
+ .overridingErrorMessage ("error message" )
1663
+ .flatMap (CartoonCharacter ::getChildrenWithException )
1664
+ .containsExactlyInAnyOrder (homer , fred );
1665
+ softly .assertThat (names )
1666
+ .as ("map(throwingFirstNameFunction)" )
1667
+ .overridingErrorMessage ("error message" )
1668
+ .map (throwingFirstNameFunction )
1669
+ .contains ("frodo" );
1670
+ softly .assertThat (names )
1671
+ .as ("map(firstNameFunction)" )
1672
+ .map (firstNameFunction )
1673
+ .contains ("sam" );
1674
+ softly .assertThat (names )
1675
+ .map (firstNameFunction , lastNameFunction )
1676
+ .as ("map with multiple functions" )
1677
+ .contains (tuple ("John" , "Doe" ))
1678
+ .contains (tuple ("Frodo" , "Baggins" ));
1600
1679
// THEN
1601
1680
List <Throwable > errorsCollected = softly .errorsCollected ();
1602
- assertThat (errorsCollected ).hasSize (33 );
1681
+ assertThat (errorsCollected ).hasSize (40 );
1603
1682
assertThat (errorsCollected .get (0 )).hasMessage ("[extracting(throwingFirstNameFunction)] error message" );
1604
1683
assertThat (errorsCollected .get (1 )).hasMessage ("[extracting(throwingFirstNameFunction)] error message" );
1605
1684
assertThat (errorsCollected .get (2 )).hasMessage ("[extracting(\" last\" )] error message" );
@@ -1633,6 +1712,13 @@ void list_soft_assertions_should_report_errors_on_final_methods_and_methods_that
1633
1712
assertThat (errorsCollected .get (30 )).hasMessage ("[using flatExtracting(String... fieldOrPropertyNames)] error message" );
1634
1713
assertThat (errorsCollected .get (31 )).hasMessage ("[using flatExtracting(String fieldOrPropertyName)] error message" );
1635
1714
assertThat (errorsCollected .get (32 )).hasMessage ("[filteredOn with consumer] error message" );
1715
+ assertThat (errorsCollected .get (33 )).hasMessageContaining ("flatMap with multiple Extractors" );
1716
+ assertThat (errorsCollected .get (34 )).hasMessageContaining ("flatMap with multiple ThrowingExtractors" );
1717
+ assertThat (errorsCollected .get (35 )).hasMessageContaining ("using flatMap on Iterable" );
1718
+ assertThat (errorsCollected .get (36 )).hasMessageContaining ("using flatMap on Iterable with exception" );
1719
+ assertThat (errorsCollected .get (37 )).hasMessageContaining ("map(throwingFirstNameFunction)" );
1720
+ assertThat (errorsCollected .get (38 )).hasMessageContaining ("map(firstNameFunction)" );
1721
+ assertThat (errorsCollected .get (39 )).hasMessageContaining ("map with multiple functions" );
1636
1722
}
1637
1723
1638
1724
// the test would fail if any method was not proxyable as the assertion error would not be softly caught
0 commit comments