File tree 1 file changed +8
-9
lines changed
spring-test/src/test/java/org/springframework/test/context/junit
1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 24
24
import org .junit .platform .testkit .engine .EngineTestKit ;
25
25
import org .junit .platform .testkit .engine .Events ;
26
26
27
+ import org .springframework .core .NestedExceptionUtils ;
28
+
27
29
import static java .util .stream .Collectors .toList ;
28
30
import static org .junit .platform .engine .discovery .DiscoverySelectors .selectClass ;
29
31
@@ -42,6 +44,11 @@ public static Events executeTestsForClass(Class<?> testClass) {
42
44
.testEvents ();
43
45
}
44
46
47
+ /**
48
+ * Create a new {@link Condition} that matches if and only if a
49
+ * {@link Throwable}'s root {@linkplain Throwable#getCause() cause} matches
50
+ * all supplied conditions.
51
+ */
45
52
@ SafeVarargs
46
53
@ SuppressWarnings ("varargs" )
47
54
public static Condition <Throwable > rootCause (Condition <Throwable >... conditions ) {
@@ -53,16 +60,8 @@ public static Condition<Throwable> rootCause(Condition<Throwable>... conditions)
53
60
}
54
61
55
62
private static Condition <Throwable > rootCause (Condition <Throwable > condition ) {
56
- return new Condition <>(throwable -> condition .matches (getRootCause (throwable )),
63
+ return new Condition <>(throwable -> condition .matches (NestedExceptionUtils . getRootCause (throwable )),
57
64
"throwable root cause matches %s" , condition );
58
65
}
59
66
60
- private static Throwable getRootCause (Throwable throwable ) {
61
- Throwable cause = throwable .getCause ();
62
- if (cause == null ) {
63
- return throwable ;
64
- }
65
- return getRootCause (cause );
66
- }
67
-
68
67
}
You can’t perform that action at this time.
0 commit comments