better error message in assumeSuccessful+assertSuccessful
This commit is contained in:
parent
2afdb3c3d7
commit
18a3718c75
@ -133,19 +133,15 @@ public class JpaAttempt {
|
||||
}
|
||||
|
||||
public JpaResult<T> assumeSuccessful() {
|
||||
assumeThat(exception).as(getSensibleMessage(exception)).isNull();
|
||||
assumeThat(exception).as(firstRootCauseMessageLineOf(exception)).isNull();
|
||||
return this;
|
||||
}
|
||||
|
||||
public JpaResult<T> 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)
|
||||
|
Loading…
Reference in New Issue
Block a user