@@ -984,7 +984,15 @@ public SELF doesNotMatch(Predicate<? super ACTUAL> predicate, String predicateDe
984984 */
985985 @ SafeVarargs
986986 public final SELF satisfies (Consumer <? super ACTUAL >... requirements ) {
987- return satisfiesForProxy (requirements );
987+ return executeAssertion (() -> {
988+ checkArgument (stream (requirements ).allMatch (java .util .Objects ::nonNull ), "No assertions group should be null" );
989+ List <AssertionError > assertionErrors = stream (requirements ).map (this ::catchOptionalAssertionError )
990+ .flatMap (Optional ::stream )
991+ .collect (toList ());
992+ if (!assertionErrors .isEmpty ()) {
993+ throw multipleAssertionsError (actual , assertionErrors );
994+ }
995+ });
988996 }
989997
990998 /**
@@ -1021,22 +1029,7 @@ public final SELF satisfies(Consumer<? super ACTUAL>... requirements) {
10211029 */
10221030 @ SafeVarargs
10231031 public final SELF satisfies (ThrowingConsumer <? super ACTUAL >... assertions ) {
1024- return satisfiesForProxy (assertions );
1025- }
1026-
1027- // This method is protected in order to be proxied for SoftAssertions / Assumptions.
1028- // The public method for it (the one not ending with "ForProxy") is marked as final and annotated with @SafeVarargs
1029- // in order to avoid compiler warning in user code
1030- protected SELF satisfiesForProxy (Consumer <? super ACTUAL >[] assertionsGroups ) throws AssertionError {
1031- return executeAssertion (() -> {
1032- checkArgument (stream (assertionsGroups ).allMatch (java .util .Objects ::nonNull ), "No assertions group should be null" );
1033- List <AssertionError > assertionErrors = stream (assertionsGroups ).map (this ::catchOptionalAssertionError )
1034- .flatMap (Optional ::stream )
1035- .collect (toList ());
1036- if (!assertionErrors .isEmpty ()) {
1037- throw multipleAssertionsError (actual , assertionErrors );
1038- }
1039- });
1032+ return satisfies ((Consumer <? super ACTUAL >[]) assertions );
10401033 }
10411034
10421035 private Optional <AssertionError > catchOptionalAssertionError (Consumer <? super ACTUAL > assertions ) {
@@ -1078,7 +1071,19 @@ private Optional<AssertionError> catchOptionalAssertionError(Consumer<? super AC
10781071 */
10791072 @ SafeVarargs
10801073 public final SELF satisfiesAnyOf (Consumer <? super ACTUAL >... assertions ) {
1081- return satisfiesAnyOfForProxy (assertions );
1074+ return executeAssertion (() -> {
1075+ checkArgument (stream (assertions ).allMatch (java .util .Objects ::nonNull ), "No assertions group should be null" );
1076+ // use a for loop over stream to return as soon as one assertion is met
1077+ List <AssertionError > assertionErrors = list ();
1078+ for (Consumer <? super ACTUAL > assertionsGroup : assertions ) {
1079+ Optional <AssertionError > maybeError = catchOptionalAssertionError (assertionsGroup );
1080+ if (maybeError .isEmpty ()) {
1081+ return ;
1082+ }
1083+ assertionErrors .add (maybeError .get ());
1084+ }
1085+ throw multipleAssertionsError (actual , assertionErrors );
1086+ });
10821087 }
10831088
10841089 /**
@@ -1114,26 +1119,7 @@ public final SELF satisfiesAnyOf(Consumer<? super ACTUAL>... assertions) {
11141119 */
11151120 @ SafeVarargs
11161121 public final SELF satisfiesAnyOf (ThrowingConsumer <? super ACTUAL >... assertions ) {
1117- return satisfiesAnyOfForProxy (assertions );
1118- }
1119-
1120- // This method is protected in order to be proxied for SoftAssertions / Assumptions.
1121- // The public method for it (the one not ending with "ForProxy") is marked as final and annotated with @SafeVarargs
1122- // in order to avoid compiler warning in user code
1123- protected SELF satisfiesAnyOfForProxy (Consumer <? super ACTUAL >[] assertionsGroups ) throws AssertionError {
1124- return executeAssertion (() -> {
1125- checkArgument (stream (assertionsGroups ).allMatch (java .util .Objects ::nonNull ), "No assertions group should be null" );
1126- // use a for loop over stream to return as soon as one assertion is met
1127- List <AssertionError > assertionErrors = list ();
1128- for (Consumer <? super ACTUAL > assertionsGroup : assertionsGroups ) {
1129- Optional <AssertionError > maybeError = catchOptionalAssertionError (assertionsGroup );
1130- if (maybeError .isEmpty ()) {
1131- return ;
1132- }
1133- assertionErrors .add (maybeError .get ());
1134- }
1135- throw multipleAssertionsError (actual , assertionErrors );
1136- });
1122+ return satisfiesAnyOf ((Consumer <? super ACTUAL >[]) assertions );
11371123 }
11381124
11391125 private AssertionError multipleAssertionsError (ACTUAL actual , List <AssertionError > assertionErrors ) {
0 commit comments