@@ -28,28 +28,86 @@ public ThrowsException(Matcher<? super Throwable> elementMatcher) {
28
28
this .exceptionMatcher = elementMatcher ;
29
29
}
30
30
31
- public static <U extends Runnable > ThrowsException <U > throwsException () {
31
+ /**
32
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception
33
+ *
34
+ * @param <T> type of the Runnable
35
+ * @return The matcher.
36
+ */
37
+ public static <T extends Runnable > ThrowsException <T > throwsException () {
32
38
return new ThrowsException <>(instanceOf (Throwable .class ));
33
39
}
34
40
35
- public static <U extends Runnable , V extends Throwable > ThrowsException <U > throwsException (V item ) {
36
- return new ThrowsException <>(exceptionEqualTo (item ));
41
+ /**
42
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception equal to the provided <code>throwable</code>
43
+ *
44
+ * @param <T> type of the Runnable
45
+ * @param <U> type of the Throwable
46
+ * @param throwable the Throwable instance against which examined exceptions are compared
47
+ * @return The matcher.
48
+ */
49
+ public static <T extends Runnable , U extends Throwable > ThrowsException <T > throwsException (U throwable ) {
50
+ return new ThrowsException <>(exceptionEqualTo (throwable ));
37
51
}
38
52
39
- public static <U extends Runnable > ThrowsException <U > throwsException (Matcher <? super Throwable > exceptionMatcher ) {
40
- return new ThrowsException <>(exceptionMatcher );
53
+ /**
54
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception of the provided <code>throwableClass</code> class
55
+ *
56
+ * @param <U> type of the Runnable
57
+ * @param <T> type of the Throwable
58
+ * @param throwableClass the Throwable class against which examined exceptions are compared
59
+ * @return The matcher.
60
+ */
61
+ public static <T extends Runnable , U extends Throwable > ThrowsException <T > throwsException (Class <U > throwableClass ) {
62
+ return new ThrowsException <>(instanceOf (throwableClass ));
41
63
}
42
64
43
- public static <U extends Runnable , V extends Throwable > ThrowsException <U > throwsException (Class <V > item ) {
44
- return new ThrowsException <>(instanceOf (item ));
65
+ /**
66
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception with a message equal to the provided <code>message</code> class
67
+ *
68
+ * @param <T> type of the Runnable
69
+ * @param message the String against which examined exception messages are compared
70
+ * @return The matcher.
71
+ */
72
+ public static <T extends Runnable > ThrowsException <T > throwsException (String message ) {
73
+ return new ThrowsException <>(withMessage (message ));
45
74
}
46
75
47
- public static <U extends Runnable , V extends Throwable > ThrowsException <U > throwsException (Class <V > item , String message ) {
48
- return new ThrowsException <>(allOf (instanceOf (item ), withMessage (message )));
76
+ /**
77
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception matching provided <code>matcher</code>
78
+ *
79
+ * @param <T> type of the Runnable
80
+ * @param matcher matcher to validate the exception
81
+ * @return The matcher.
82
+ */
83
+ public static <T extends Runnable > ThrowsException <T > throwsException (Matcher <? super Throwable > matcher ) {
84
+ return new ThrowsException <>(matcher );
49
85
}
50
86
51
- public static <U extends Runnable , V extends Throwable > ThrowsException <U > throwsException (Class <V > item , Matcher <? super Throwable > exceptionMatcher ) {
52
- return new ThrowsException <>(allOf (instanceOf (item ), exceptionMatcher ));
87
+ /**
88
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception of the provided <code>throwableClass</code> class and has a message equal to the provided <code>message</code>
89
+ *
90
+ * @param <T> type of the Runnable
91
+ * @param <U> type of the Throwable
92
+ * @param throwableClass the Throwable class against which examined exceptions are compared
93
+ * @param message the String against which examined exception messages are compared
94
+ * @return The matcher.
95
+ */
96
+ public static <T extends Runnable , U extends Throwable > ThrowsException <T > throwsException (Class <U > throwableClass , String message ) {
97
+ return new ThrowsException <>(allOf (instanceOf (throwableClass ), withMessage (message )));
98
+ }
99
+
100
+ /**
101
+ * Matcher for {@link Throwable} that expects that the Runnable throws an exception of the provided <code>throwableClass</code> class and matches the provided <code>matcher</code>
102
+ *
103
+ * @param <U> type of the Runnable
104
+ * @param <T> type of the Throwable
105
+ * @param throwableClass the Throwable class against which examined exceptions are compared
106
+ * @param matcher matcher to validate the exception
107
+ * @return The matcher.
108
+ */
109
+ public static <T extends Runnable , U extends Throwable > ThrowsException <T > throwsException (Class <U > throwableClass , Matcher <? super Throwable > matcher ) {
110
+ return new ThrowsException <>(allOf (instanceOf (throwableClass ), matcher ));
53
111
}
54
112
55
113
@ Override
0 commit comments