From 18a3718c75dbf86d6a19a4d8c5fd058e8e4e6422 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 7 Sep 2022 10:24:51 +0200 Subject: [PATCH] better error message in assumeSuccessful+assertSuccessful --- src/test/java/net/hostsharing/test/JpaAttempt.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/java/net/hostsharing/test/JpaAttempt.java b/src/test/java/net/hostsharing/test/JpaAttempt.java index 85202a4b..8f62c50f 100644 --- a/src/test/java/net/hostsharing/test/JpaAttempt.java +++ b/src/test/java/net/hostsharing/test/JpaAttempt.java @@ -133,19 +133,15 @@ public class JpaAttempt { } public JpaResult assumeSuccessful() { - assumeThat(exception).as(getSensibleMessage(exception)).isNull(); + assumeThat(exception).as(firstRootCauseMessageLineOf(exception)).isNull(); return this; } public JpaResult assertSuccessful() { - assertThat(exception).as(getSensibleMessage(exception)).isNull(); + assertThat(exception).as(firstRootCauseMessageLineOf(exception)).isNull(); return this; } - private String getSensibleMessage(final RuntimeException exception) { - return exception != null ? NestedExceptionUtils.getRootCause(exception).getMessage() : null; - } - private String firstRootCauseMessageLineOf(final RuntimeException exception) { final var rootCause = NestedExceptionUtils.getRootCause(exception); return Optional.ofNullable(rootCause)