Skip to content

Commit

Permalink
Remove unused suppressed exception adding
Browse files Browse the repository at this point in the history
  • Loading branch information
marcphilipp committed Jul 10, 2022
1 parent a43b2ab commit 7c0dbe5
Showing 1 changed file with 1 addition and 17 deletions.
Expand Up @@ -12,9 +12,6 @@

import static org.junit.jupiter.api.AssertionUtils.getCanonicalName;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;

import org.junit.platform.commons.util.StringUtils;
Expand All @@ -24,7 +21,6 @@ public class AssertionFailureBuilder {

private Object message;
private Throwable cause;
private final List<Throwable> suppressed = new ArrayList<>();
private boolean mismatch;
private Object expected;
private Object actual;
Expand Down Expand Up @@ -53,16 +49,6 @@ public AssertionFailureBuilder cause(Throwable cause) {
return this;
}

public AssertionFailureBuilder suppressed(Throwable suppressed) {
this.suppressed.add(suppressed);
return this;
}

public AssertionFailureBuilder suppressed(Throwable... suppressed) {
this.suppressed.addAll(Arrays.asList(suppressed));
return this;
}

public AssertionFailureBuilder expected(Object expected) {
this.mismatch = true;
this.expected = expected;
Expand Down Expand Up @@ -93,11 +79,9 @@ public AssertionFailedError build() {
if (reason != null) {
message = buildPrefix(message) + reason;
}
AssertionFailedError assertionFailedError = mismatch //
return mismatch //
? new AssertionFailedError(message, expected, actual, cause) //
: new AssertionFailedError(message, cause);
suppressed.forEach(assertionFailedError::addSuppressed);
return assertionFailedError;
}

private static String nullSafeGet(Object messageOrSupplier) {
Expand Down

0 comments on commit 7c0dbe5

Please sign in to comment.