Repository: assertj/assertj
Pull request #3700 (2024-12-15 14:07:07)

Update `AbstractCharSequenceAssert.java` reference
# PR Summary
Small PR - Commit 3f3110fd56b2dc9b55ab8b4fb1a12b0fab439cef moved `AbstractCharSequenceAssert.java`. This PR adjusts sources to changes.


Patch:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1486894a4..57850b113 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -71,7 +71,7 @@ Let's look at the `Throwables_assertHasNoCause_Test` test method names (undersco
 * `should_fail_if_actual_is_null`
 * `should_fail_if_actual_has_a_cause`
 
-A good Javadoc example taken from [`AbstractCharSequenceAssert.containsSequence`](src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java) including:
+A good Javadoc example taken from [`AbstractCharSequenceAssert.containsSequence`](assertj-core/src/main/java/org/assertj/core/api/AbstractCharSequenceAssert.java) including:
 * assertion description
 * a code example showing how to use the assertion (succeeding and failing assertion)
 * parameters description (if any)
diff --git a/assertj-core/src/main/java/org/assertj/core/error/UnsatisfiedRequirement.java b/assertj-core/src/main/java/org/assertj/core/error/UnsatisfiedRequirement.java
index 4b06db9e7..4012b552e 100644
--- a/assertj-core/src/main/java/org/assertj/core/error/UnsatisfiedRequirement.java
+++ b/assertj-core/src/main/java/org/assertj/core/error/UnsatisfiedRequirement.java
@@ -15,19 +15,35 @@ package org.assertj.core.error;
 import static java.lang.String.format;
 
 import org.assertj.core.api.AssertionInfo;
+import org.assertj.core.presentation.Representation;
 
 public class UnsatisfiedRequirement {
 
   private final Object elementNotSatisfyingRequirements;
   private final String errorMessage;
+  private final AssertionError error;
 
+  /**
+   * @param elementNotSatisfyingRequirements object not satisfying the requirement
+   * @param errorMessage                     requirement error message
+   * @deprecated use {@link UnsatisfiedRequirement#UnsatisfiedRequirement(Object, AssertionError)} instead.
+   */
+  @Deprecated
   public UnsatisfiedRequirement(Object elementNotSatisfyingRequirements, String errorMessage) {
     this.elementNotSatisfyingRequirements = elementNotSatisfyingRequirements;
     this.errorMessage = errorMessage;
+    this.error = null;
+  }
+
+  public UnsatisfiedRequirement(Object elementNotSatisfyingRequirements, AssertionError error) {
+    this.elementNotSatisfyingRequirements = elementNotSatisfyingRequirements;
+    this.errorMessage = error.getMessage();
+    this.error = error;
   }
 
   public String describe(AssertionInfo info) {
-    return format("%s%nerror: %s", info.representation().toStringOf(elementNotSatisfyingRequirements), errorMessage);
+    Representation representation = info.representation();
+    return format("%s%nerror: %s", representation.toStringOf(elementNotSatisfyingRequirements), describeError(representation));
   }
 
   @Override
@@ -36,9 +52,14 @@ public class UnsatisfiedRequirement {
   }
 
   public String describe(int index, AssertionInfo info) {
+    Representation representation = info.representation();
     return format("%s%n" +
                   "- element index: %s%n" +
                   "- error: %s",
-                  info.representation().toStringOf(elementNotSatisfyingRequirements), index, errorMessage);
+                  representation.toStringOf(elementNotSatisfyingRequirements), index, describeError(representation));
+  }
+
+  private String describeError(Representation representation) {
+    return error != null ? representation.toStringOf(error) : errorMessage;
   }
-}
\ No newline at end of file
+}
diff --git a/assertj-core/src/main/java/org/assertj/core/internal/Iterables.java b/assertj-core/src/main/java/org/assertj/core/internal/Iterables.java
index 4db99455d..10519f516 100644
--- a/assertj-core/src/main/java/org/assertj/core/internal/Iterables.java
+++ b/assertj-core/src/main/java/org/assertj/core/internal/Iterables.java
@@ -1193,7 +1193,7 @@ public class Iterables {
     try {
       requirements.accept(element);
     } catch (AssertionError ex) {
-      return Optional.of(new UnsatisfiedRequirement(element, ex.getMessage()));
+      return Optional.of(new UnsatisfiedRequirement(element, ex));
     }
     return Optional.empty();
   }
diff --git a/assertj-core/src/main/java/org/assertj/core/internal/Maps.java b/assertj-core/src/main/java/org/assertj/core/internal/Maps.java
index efb17c7ec..0f09487e9 100644
--- a/assertj-core/src/main/java/org/assertj/core/internal/Maps.java
+++ b/assertj-core/src/main/java/org/assertj/core/internal/Maps.java
@@ -115,7 +115,7 @@ public class Maps {
     try {
       entryRequirements.accept(entry.getKey(), entry.getValue());
     } catch (AssertionError ex) {
-      return Optional.of(new UnsatisfiedRequirement(entry, ex.getMessage()));
+      return Optional.of(new UnsatisfiedRequirement(entry, ex));
     }
     return Optional.empty();
   }


Test patch:
diff --git a/assertj-core/src/test/java/org/assertj/core/error/ElementsShouldSatisfy_create_Test.java b/assertj-core/src/test/java/org/assertj/core/error/ElementsShouldSatisfy_create_Test.java
index 1fde42065..962c1f84a 100644
--- a/assertj-core/src/test/java/org/assertj/core/error/ElementsShouldSatisfy_create_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/error/ElementsShouldSatisfy_create_Test.java
@@ -42,20 +42,20 @@ class ElementsShouldSatisfy_create_Test {
   @Test
   void should_create_error_message_all() {
     // GIVEN
-    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(unsatisfiedRequirement("Leia", "Leia mistake."),
-                                                                unsatisfiedRequirement("Luke", "Luke mistake."));
+    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(new UnsatisfiedRequirement("Leia",
+                                                                                           catchAssertionError("Leia mistake.")),
+                                                                new UnsatisfiedRequirement("Luke",
+                                                                                           catchAssertionError("Luke mistake.")));
     ErrorMessageFactory factory = elementsShouldSatisfy(list("Leia", "Luke", "Yoda"), unsatisfiedRequirements, info);
     // WHEN
     String message = factory.create(new TextDescription("Test"), info.representation());
     // THEN
-    then(message).isEqualTo(format("[Test] %n" +
-                                   "Expecting all elements of:%n" +
-                                   "  [\"Leia\", \"Luke\", \"Yoda\"]%n" +
-                                   "to satisfy given requirements, but these elements did not:%n%n" +
-                                   "\"Leia\"%n" +
-                                   "error: Leia mistake.%n%n" +
-                                   "\"Luke\"%n" +
-                                   "error: Luke mistake."));
+    then(message).startsWith(format("[Test] %n" +
+                                    "Expecting all elements of:%n" +
+                                    "  [\"Leia\", \"Luke\", \"Yoda\"]%n" +
+                                    "to satisfy given requirements, but these elements did not:%n%n"))
+                 .contains(format("java.lang.AssertionError: Leia mistake.%n\tat"))
+                 .contains(format("java.lang.AssertionError: Luke mistake.%n\tat"));
   }
 
   @Test
@@ -80,20 +80,20 @@ class ElementsShouldSatisfy_create_Test {
   @Test
   void should_create_error_message_any() {
     // GIVEN
-    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(unsatisfiedRequirement("Leia", "Leia mistake."),
-                                                                unsatisfiedRequirement("Luke", "Luke mistake."));
+    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(new UnsatisfiedRequirement("Leia",
+                                                                                           catchAssertionError("Leia mistake.")),
+                                                                new UnsatisfiedRequirement("Luke",
+                                                                                           catchAssertionError("Luke mistake.")));
     ErrorMessageFactory factory = elementsShouldSatisfyAny(list("Luke", "Yoda"), unsatisfiedRequirements, info);
     // WHEN
     String message = factory.create(new TextDescription("Test"), info.representation());
     // THEN
-    then(message).isEqualTo(format("[Test] %n" +
-                                   "Expecting any element of:%n" +
-                                   "  [\"Luke\", \"Yoda\"]%n" +
-                                   "to satisfy the given assertions requirements but none did:%n%n" +
-                                   "\"Leia\"%n" +
-                                   "error: Leia mistake.%n%n" +
-                                   "\"Luke\"%n" +
-                                   "error: Luke mistake."));
+    then(message).startsWith(format("[Test] %n" +
+                                    "Expecting any element of:%n" +
+                                    "  [\"Luke\", \"Yoda\"]%n" +
+                                    "to satisfy the given assertions requirements but none did:%n%n"))
+                 .contains(format("java.lang.AssertionError: Leia mistake.%n\tat"))
+                 .contains(format("java.lang.AssertionError: Luke mistake.%n\tat"));
   }
 
   @Test
@@ -119,24 +119,33 @@ class ElementsShouldSatisfy_create_Test {
   void should_create_error_SatisfyExactly_message() {
     // GIVEN
     Map<Integer, UnsatisfiedRequirement> unsatisfiedRequirements = newHashMap();
-    unsatisfiedRequirements.put(1, unsatisfiedRequirement("Leia%", "Leia mistake."));
-    unsatisfiedRequirements.put(3, unsatisfiedRequirement("Luke", "Luke mistake."));
+    unsatisfiedRequirements.put(1, new UnsatisfiedRequirement("Leia%", catchAssertionError("Leia mistake.")));
+    unsatisfiedRequirements.put(3, new UnsatisfiedRequirement("Luke", catchAssertionError("Luke mistake.")));
     ErrorMessageFactory factory = elementsShouldSatisfyExactly(list("Luke%", "Yoda"), unsatisfiedRequirements, info);
     // WHEN
     String message = factory.create(new TextDescription("Test"), info.representation());
     // THEN
-    then(message).isEqualTo(format("[Test] %n" +
-                                   "Expecting each element of:%n" +
-                                   "  [\"Luke%%\", \"Yoda\"]%n" +
-                                   "to satisfy the requirements at its index, but these elements did not:%n" +
-                                   "%n" +
-                                   "\"Leia%%\"%n" +
-                                   "- element index: 1%n" +
-                                   "- error: Leia mistake.%n" +
-                                   "%n" +
-                                   "\"Luke\"%n" +
-                                   "- element index: 3%n" +
-                                   "- error: Luke mistake."));
+    then(message).startsWith(format("[Test] %n" +
+                                    "Expecting each element of:%n" +
+                                    "  [\"Luke%%\", \"Yoda\"]%n" +
+                                    "to satisfy the requirements at its index, but these elements did not:%n" +
+                                    "%n" +
+                                    "\"Leia%%\"%n" +
+                                    "- element index: 1%n"))
+                 .contains(format("- error: java.lang.AssertionError: Leia mistake.%n\tat"))
+                 .contains(format("%n" +
+                                  "\"Luke\"%n" +
+                                  "- element index: 3%n" +
+                                  "- error: java.lang.AssertionError: Luke mistake.%n\tat"));
+  }
+
+  // just to get a stack trace
+  private static AssertionError catchAssertionError(String message) {
+    try {
+      throw new AssertionError(message);
+    } catch (AssertionError e) {
+      return e;
+    }
   }
 
 }
diff --git a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAllSatisfy_Test.java b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAllSatisfy_Test.java
index df33144c5..1034d981b 100644
--- a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAllSatisfy_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAllSatisfy_Test.java
@@ -14,20 +14,16 @@ package org.assertj.core.internal.iterables;
 
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
 import static org.assertj.core.api.Assertions.assertThatNullPointerException;
-import static org.assertj.core.api.Assertions.catchThrowable;
-import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
+import static org.assertj.core.api.BDDAssertions.then;
 import static org.assertj.core.testkit.TestData.someInfo;
+import static org.assertj.core.util.AssertionsUtil.expectAssertionError;
 import static org.assertj.core.util.FailureMessages.actualIsNull;
-import static org.assertj.core.util.Lists.list;
 import static org.assertj.core.util.Lists.newArrayList;
-import static org.mockito.Mockito.verify;
 
 import java.util.List;
 import java.util.function.Consumer;
 
-import org.assertj.core.error.UnsatisfiedRequirement;
 import org.assertj.core.internal.IterablesBaseTest;
 import org.junit.jupiter.api.Test;
 
@@ -55,20 +51,15 @@ class Iterables_assertAllSatisfy_Test extends IterablesBaseTest {
       assertThat(s.length()).isEqualTo(4);
       assertThat(s).startsWith("L");
     };
-
     // WHEN
-    Throwable error = catchThrowable(() -> iterables.assertAllSatisfy(someInfo(), actual, restrictions));
-
+    AssertionError error = expectAssertionError(() -> iterables.assertAllSatisfy(someInfo(), actual, restrictions));
     // THEN
-    assertThat(error).isNotNull();
-
-    List<UnsatisfiedRequirement> errors = list(new UnsatisfiedRequirement("Yoda", format("%n" +
-                                                                                         "Expecting actual:%n" +
-                                                                                         "  \"Yoda\"%n" +
-                                                                                         "to start with:%n" +
-                                                                                         "  \"L\"%n")));
-    verify(failures).failure(info, elementsShouldSatisfy(actual, errors, someInfo()));
-
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageContaining(format("%n" +
+                                            "Expecting actual:%n" +
+                                            "  \"Yoda\"%n" +
+                                            "to start with:%n" +
+                                            "  \"L\"%n"));
   }
 
   @Test
@@ -79,9 +70,13 @@ class Iterables_assertAllSatisfy_Test extends IterablesBaseTest {
 
   @Test
   void should_fail_if_actual_is_null() {
-    assertThatExceptionOfType(AssertionError.class).isThrownBy(() -> {
+    // WHEN
+    AssertionError error = expectAssertionError(() -> {
       actual = null;
       assertThat(actual).allSatisfy(null);
-    }).withMessage(actualIsNull());
+    });
+    // THEN
+    then(error).hasMessage(actualIsNull());
+
   }
 }
diff --git a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAnySatisfy_Test.java b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAnySatisfy_Test.java
index fc244143c..b8eaf0abc 100644
--- a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAnySatisfy_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertAnySatisfy_Test.java
@@ -17,12 +17,11 @@ import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatNullPointerException;
 import static org.assertj.core.api.Assertions.catchThrowable;
+import static org.assertj.core.api.BDDAssertions.then;
 import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
-import static org.assertj.core.error.ElementsShouldSatisfy.unsatisfiedRequirement;
 import static org.assertj.core.testkit.TestData.someInfo;
 import static org.assertj.core.util.AssertionsUtil.expectAssertionError;
 import static org.assertj.core.util.FailureMessages.actualIsNull;
-import static org.assertj.core.util.Lists.list;
 import static org.assertj.core.util.Lists.newArrayList;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doThrow;
@@ -78,32 +77,32 @@ class Iterables_assertAnySatisfy_Test extends IterablesBaseTest {
 
   @Test
   void should_fail_if_no_elements_satisfy_the_assertions_requirements() {
-    Throwable error = catchThrowable(() -> iterables.assertAnySatisfy(someInfo(), actual, s -> {
+    // WHEN
+    AssertionError error = expectAssertionError(() -> iterables.assertAnySatisfy(someInfo(), actual, s -> {
       assertThat(s).hasSize(4);
       assertThat(s).contains("W");
     }));
-
-    assertThat(error).isInstanceOf(AssertionError.class);
-    List<UnsatisfiedRequirement> errors = list(unsatisfiedRequirement("Luke", format("%n" +
-                                                                                     "Expecting actual:%n" +
-                                                                                     "  \"Luke\"%n" +
-                                                                                     "to contain:%n" +
-                                                                                     "  \"W\" ")),
-                                               unsatisfiedRequirement("Leia", format("%n" +
-                                                                                     "Expecting actual:%n" +
-                                                                                     "  \"Leia\"%n" +
-                                                                                     "to contain:%n" +
-                                                                                     "  \"W\" ")),
-                                               unsatisfiedRequirement("Yoda", format("%n" +
-                                                                                     "Expecting actual:%n" +
-                                                                                     "  \"Yoda\"%n" +
-                                                                                     "to contain:%n" +
-                                                                                     "  \"W\" ")),
-                                               unsatisfiedRequirement("Obiwan", format("%n" +
-                                                                                       "Expected size: 4 but was: 6 in:%n"
-                                                                                       +
-                                                                                       "\"Obiwan\"")));
-    verify(failures).failure(info, elementsShouldSatisfyAny(actual, errors, someInfo()));
+    // THEN
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageContainingAll(format("%n" +
+                                               "Expecting actual:%n" +
+                                               "  \"Luke\"%n" +
+                                               "to contain:%n" +
+                                               "  \"W\" "),
+                                        format("%n" +
+                                               "Expecting actual:%n" +
+                                               "  \"Leia\"%n" +
+                                               "to contain:%n" +
+                                               "  \"W\" "),
+                                        format("%n" +
+                                               "Expecting actual:%n" +
+                                               "  \"Yoda\"%n" +
+                                               "to contain:%n" +
+                                               "  \"W\" "),
+                                        format("%n" +
+                                               "Expected size: 4 but was: 6 in:%n"
+                                               +
+                                               "\"Obiwan\""));
   }
 
   @Test
diff --git a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertSatisfiesExactly_Test.java b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertSatisfiesExactly_Test.java
index fdc381aec..5fe7a52be 100644
--- a/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertSatisfiesExactly_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/internal/iterables/Iterables_assertSatisfiesExactly_Test.java
@@ -12,25 +12,19 @@
  */
 package org.assertj.core.internal.iterables;
 
-import static com.google.common.collect.Maps.newHashMap;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.BDDAssertions.then;
-import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyExactly;
 import static org.assertj.core.error.ShouldHaveSameSizeAs.shouldHaveSameSizeAs;
 import static org.assertj.core.error.ShouldStartWith.shouldStartWith;
 import static org.assertj.core.util.Arrays.array;
 import static org.assertj.core.util.AssertionsUtil.expectAssertionError;
 import static org.assertj.core.util.FailureMessages.actualIsNull;
 import static org.assertj.core.util.Lists.list;
-import static org.assertj.core.util.Maps.newHashMap;
-import static org.mockito.Mockito.verify;
 
 import java.util.List;
-import java.util.Map;
 import java.util.function.Consumer;
 
-import org.assertj.core.error.UnsatisfiedRequirement;
 import org.assertj.core.internal.IterablesBaseTest;
 import org.junit.jupiter.api.Test;
 
@@ -65,10 +59,15 @@ class Iterables_assertSatisfiesExactly_Test extends IterablesBaseTest {
                                             name -> assertThat(name).startsWith("Han"),
                                             name -> assertThat(name).endsWith("da"));
     // WHEN
-    expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
+    AssertionError error = expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
     // THEN
-    UnsatisfiedRequirement re = new UnsatisfiedRequirement("Leia", shouldStartWith("Leia", "Han").create());
-    verify(failures).failure(info, elementsShouldSatisfyExactly(actual, newHashMap(1, re), info));
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting each element of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy the requirements at its index, but these elements did not:%n%n",
+                                              info.representation().toStringOf(actual)))
+               .hasMessageContaining(shouldStartWith("Leia", "Han").create());
   }
 
   @Test
@@ -78,27 +77,37 @@ class Iterables_assertSatisfiesExactly_Test extends IterablesBaseTest {
                                             name -> assertThat(name).startsWith("Han"),
                                             name -> assertThat(name).startsWith("Io"));
     // WHEN
-    expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
+    AssertionError error = expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
     // THEN
-    Map<Integer, UnsatisfiedRequirement> unsatisfiedRequirements = newHashMap();
-    unsatisfiedRequirements.put(1, new UnsatisfiedRequirement("Leia", shouldStartWith("Leia", "Han").create()));
-    unsatisfiedRequirements.put(2, new UnsatisfiedRequirement("Yoda", shouldStartWith("Yoda", "Io").create()));
-    verify(failures).failure(info, elementsShouldSatisfyExactly(actual, unsatisfiedRequirements, info));
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting each element of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy the requirements at its index, but these elements did not:%n%n",
+                                              info.representation().toStringOf(actual)))
+               .hasMessageContaining(shouldStartWith("Leia", "Han").create())
+               .hasMessageContaining(shouldStartWith("Yoda", "Io").create());
   }
 
   @Test
-  void should_fail_when_requirements_are_met_but_in_the_right_order() {
+  void should_fail_when_requirements_are_met_but_not_in_the_right_order() {
     // GIVEN
     Consumer<String>[] requirements = array(name -> assertThat(name).isNotBlank(),
                                             name -> assertThat(name).startsWith("Yo"),
                                             name -> assertThat(name).startsWith("Lei"));
     // WHEN
-    expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
+    // WHEN
+    AssertionError error = expectAssertionError(() -> iterables.assertSatisfiesExactly(info, actual, requirements));
     // THEN
-    Map<Integer, UnsatisfiedRequirement> unsatisfiedRequirements = newHashMap();
-    unsatisfiedRequirements.put(1, new UnsatisfiedRequirement("Leia", shouldStartWith("Leia", "Yo").create()));
-    unsatisfiedRequirements.put(2, new UnsatisfiedRequirement("Yoda", shouldStartWith("Yoda", "Lei").create()));
-    verify(failures).failure(info, elementsShouldSatisfyExactly(actual, unsatisfiedRequirements, info));
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting each element of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy the requirements at its index, but these elements did not:%n%n",
+                                              info.representation().toStringOf(actual)))
+               .hasMessageContaining(shouldStartWith("Leia", "Yo").create())
+               .hasMessageContaining(shouldStartWith("Yoda", "Lei").create());
+
   }
 
   @Test
diff --git a/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAllSatisfyingConsumer_Test.java b/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAllSatisfyingConsumer_Test.java
index 6062b6ef2..9e6356221 100644
--- a/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAllSatisfyingConsumer_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAllSatisfyingConsumer_Test.java
@@ -15,20 +15,15 @@ package org.assertj.core.internal.maps;
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatNullPointerException;
+import static org.assertj.core.api.BDDAssertions.then;
 import static org.assertj.core.data.MapEntry.entry;
-import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfy;
 import static org.assertj.core.testkit.Maps.mapOf;
 import static org.assertj.core.testkit.TestData.someInfo;
 import static org.assertj.core.util.AssertionsUtil.expectAssertionError;
 import static org.assertj.core.util.FailureMessages.actualIsNull;
-import static org.assertj.core.util.Lists.list;
 
-import java.util.AbstractMap;
-import java.util.AbstractMap.SimpleEntry;
-import java.util.List;
 import java.util.Map;
 
-import org.assertj.core.error.UnsatisfiedRequirement;
 import org.assertj.core.internal.MapsBaseTest;
 import org.assertj.core.testkit.Player;
 import org.junit.jupiter.api.BeforeEach;
@@ -70,8 +65,14 @@ class Maps_assertAllSatisfyingConsumer_Test extends MapsBaseTest {
                                            .isLessThan(30);
     }));
     // THEN
-    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(failOnPpgLessThan("Bulls", jordan, 30));
-    assertThat(error).hasMessage(elementsShouldSatisfy(greatPlayers, unsatisfiedRequirements, someInfo()).create());
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting all elements of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy given requirements, but these elements did not:%n%n",
+                                              info.representation().toStringOf(greatPlayers)))
+               .hasMessageContaining("error: java.lang.AssertionError: [Michael Jordan ppg]")
+               .hasMessageNotContainingAny("[Tim Duncan ppg]", "[Magic Johnson ppg]");
   }
 
   @Test
@@ -83,9 +84,15 @@ class Maps_assertAllSatisfyingConsumer_Test extends MapsBaseTest {
                                            .isGreaterThanOrEqualTo(30);
     }));
     // THEN
-    List<UnsatisfiedRequirement> unsatisfiedRequirements = list(failOnPpgGreaterThanEqual("Spurs", duncan, 30),
-                                                                failOnPpgGreaterThanEqual("Lakers", magic, 30));
-    assertThat(error).hasMessage(elementsShouldSatisfy(greatPlayers, unsatisfiedRequirements, someInfo()).create());
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting all elements of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy given requirements, but these elements did not:%n%n",
+                                              info.representation().toStringOf(greatPlayers)))
+               .hasMessageContaining("error: java.lang.AssertionError: [Tim Duncan ppg]")
+               .hasMessageContaining("error: java.lang.AssertionError: [Magic Johnson ppg]")
+               .hasMessageNotContainingAny("[Michael Jordan ppg]");
   }
 
   @Test
@@ -93,7 +100,7 @@ class Maps_assertAllSatisfyingConsumer_Test extends MapsBaseTest {
     // WHEN
     AssertionError error = expectAssertionError(() -> maps.assertAllSatisfy(someInfo(), null, (team, player) -> {}));
     // THEN
-    assertThat(error).hasMessage(actualIsNull());
+    then(error).hasMessage(actualIsNull());
   }
 
   @Test
@@ -101,25 +108,4 @@ class Maps_assertAllSatisfyingConsumer_Test extends MapsBaseTest {
     assertThatNullPointerException().isThrownBy(() -> maps.assertAllSatisfy(someInfo(), greatPlayers, null))
                                     .withMessage("The BiConsumer<K, V> expressing the assertions requirements must not be null");
   }
-
-  private static UnsatisfiedRequirement failOnPpgGreaterThanEqual(String team, Player player, int requiredScore) {
-    SimpleEntry<String, Player> entry = new AbstractMap.SimpleEntry<>(team, player);
-    String message = format("[" + player.getName().getName() + " ppg] %n" +
-                            "Expecting actual:%n" +
-                            "  " + player.getPointsPerGame() + "%n" +
-                            "to be greater than or equal to:%n" +
-                            "  " + requiredScore + "%n");
-    return new UnsatisfiedRequirement(entry, message);
-  }
-
-  private static UnsatisfiedRequirement failOnPpgLessThan(String team, Player player, int requiredScore) {
-    SimpleEntry<String, Player> entry = new AbstractMap.SimpleEntry<>(team, player);
-    String message = format("[" + player.getName().getName() + " ppg] %n" +
-                            "Expecting actual:%n" +
-                            "  " + player.getPointsPerGame() + "%n" +
-                            "to be less than:%n" +
-                            "  " + requiredScore + " ");
-    return new UnsatisfiedRequirement(entry, message);
-  }
-
 }
diff --git a/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAnySatisfyingConsumer_Test.java b/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAnySatisfyingConsumer_Test.java
index ea911c4b5..e2d5d089c 100644
--- a/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAnySatisfyingConsumer_Test.java
+++ b/assertj-core/src/test/java/org/assertj/core/internal/maps/Maps_assertAnySatisfyingConsumer_Test.java
@@ -16,27 +16,22 @@ import static java.lang.String.format;
 import static java.util.Collections.emptyList;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatNullPointerException;
+import static org.assertj.core.api.BDDAssertions.then;
 import static org.assertj.core.data.MapEntry.entry;
 import static org.assertj.core.error.ElementsShouldSatisfy.elementsShouldSatisfyAny;
-import static org.assertj.core.error.ElementsShouldSatisfy.unsatisfiedRequirement;
 import static org.assertj.core.testkit.Maps.mapOf;
 import static org.assertj.core.testkit.TestData.someInfo;
 import static org.assertj.core.util.AssertionsUtil.expectAssertionError;
 import static org.assertj.core.util.FailureMessages.actualIsNull;
-import static org.assertj.core.util.Lists.list;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doThrow;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.function.BiConsumer;
 
-import org.assertj.core.error.UnsatisfiedRequirement;
 import org.assertj.core.internal.MapsBaseTest;
 import org.assertj.core.testkit.Player;
 import org.junit.jupiter.api.BeforeEach;
@@ -89,21 +84,21 @@ class Maps_assertAnySatisfyingConsumer_Test extends MapsBaseTest {
     AssertionError error = expectAssertionError(() -> maps.assertAnySatisfy(someInfo(), actual,
                                                                             ($1, $2) -> assertThat(true).isTrue()));
     // THEN
-    assertThat(error).hasMessage(elementsShouldSatisfyAny(actual, emptyList(), someInfo()).create());
+    then(error).hasMessage(elementsShouldSatisfyAny(actual, emptyList(), someInfo()).create());
   }
 
   @Test
   void should_fail_if_no_entry_satisfies_the_given_requirements() {
     // WHEN
-    AssertionError error = expectAssertionError(() -> maps.assertAnySatisfy(someInfo(), actual,
-                                                                            ($1, $2) -> assertThat(true).isFalse()));
+    BiConsumer<String, String> requirements = ($1, $2) -> assertThat(true).isFalse();
+    AssertionError error = expectAssertionError(() -> maps.assertAnySatisfy(someInfo(), actual, requirements));
     // THEN
-    Iterator<Entry<String, String>> actualEntries = actual.entrySet().iterator();
-    List<UnsatisfiedRequirement> errors = list(unsatisfiedRequirement(actualEntries.next(),
-                                                                      format("%nExpecting value to be false but was true")),
-                                               unsatisfiedRequirement(actualEntries.next(),
-                                                                      format("%nExpecting value to be false but was true")));
-    assertThat(error).hasMessage(elementsShouldSatisfyAny(actual, errors, someInfo()).create());
+    // can't build the exact error message due to internal stack traces
+    then(error).hasMessageStartingWith(format("%n" +
+                                              "Expecting any element of:%n" +
+                                              "  %s%n" +
+                                              "to satisfy the given assertions requirements but none did:%n%n",
+                                              info.representation().toStringOf(actual)));
   }
 
   @Test
@@ -111,7 +106,7 @@ class Maps_assertAnySatisfyingConsumer_Test extends MapsBaseTest {
     // WHEN
     AssertionError error = expectAssertionError(() -> maps.assertAnySatisfy(someInfo(), null, (team, player) -> {}));
     // THEN
-    assertThat(error).hasMessage(actualIsNull());
+    then(error).hasMessage(actualIsNull());
   }
 
   @Test
@@ -119,4 +114,5 @@ class Maps_assertAnySatisfyingConsumer_Test extends MapsBaseTest {
     assertThatNullPointerException().isThrownBy(() -> maps.assertAnySatisfy(someInfo(), greatPlayers, null))
                                     .withMessage("The BiConsumer<K, V> expressing the assertions requirements must not be null");
   }
+
 }