22
22
import org .aopalliance .intercept .MethodInterceptor ;
23
23
import org .jspecify .annotations .Nullable ;
24
24
import org .junit .jupiter .api .BeforeEach ;
25
+ import org .junit .jupiter .api .IndicativeSentencesGeneration ;
25
26
import org .junit .jupiter .api .Nested ;
26
27
import org .junit .jupiter .api .Test ;
27
28
import org .mockito .Mockito ;
40
41
* @see JdkProxyExceptionHandlingTests
41
42
* @see CglibProxyExceptionHandlingTests
42
43
*/
44
+ @ IndicativeSentencesGeneration (generator = SentenceFragmentDisplayNameGenerator .class )
43
45
abstract class AbstractProxyExceptionHandlingTests {
44
46
45
47
private static final RuntimeException uncheckedException = new RuntimeException ();
@@ -79,6 +81,7 @@ private static Answer<?> sneakyThrow(Throwable throwable) {
79
81
80
82
81
83
@ Nested
84
+ @ SentenceFragment ("when there is one interceptor" )
82
85
class WhenThereIsOneInterceptorTests {
83
86
84
87
private @ Nullable Throwable throwableSeenByInterceptor ;
@@ -91,6 +94,7 @@ void beforeEach() {
91
94
}
92
95
93
96
@ Test
97
+ @ SentenceFragment ("and the target throws an undeclared checked exception" )
94
98
void targetThrowsUndeclaredCheckedException () throws DeclaredCheckedException {
95
99
willAnswer (sneakyThrow (undeclaredCheckedException )).given (target ).doSomething ();
96
100
invokeProxy ();
@@ -101,6 +105,7 @@ void targetThrowsUndeclaredCheckedException() throws DeclaredCheckedException {
101
105
}
102
106
103
107
@ Test
108
+ @ SentenceFragment ("and the target throws a declared checked exception" )
104
109
void targetThrowsDeclaredCheckedException () throws DeclaredCheckedException {
105
110
willThrow (declaredCheckedException ).given (target ).doSomething ();
106
111
invokeProxy ();
@@ -109,6 +114,7 @@ void targetThrowsDeclaredCheckedException() throws DeclaredCheckedException {
109
114
}
110
115
111
116
@ Test
117
+ @ SentenceFragment ("and the target throws an unchecked exception" )
112
118
void targetThrowsUncheckedException () throws DeclaredCheckedException {
113
119
willThrow (uncheckedException ).given (target ).doSomething ();
114
120
invokeProxy ();
@@ -131,6 +137,7 @@ private MethodInterceptor captureThrowable() {
131
137
132
138
133
139
@ Nested
140
+ @ SentenceFragment ("when there are no interceptors" )
134
141
class WhenThereAreNoInterceptorsTests {
135
142
136
143
@ BeforeEach
@@ -140,6 +147,7 @@ void beforeEach() {
140
147
}
141
148
142
149
@ Test
150
+ @ SentenceFragment ("and the target throws an undeclared checked exception" )
143
151
void targetThrowsUndeclaredCheckedException () throws DeclaredCheckedException {
144
152
willAnswer (sneakyThrow (undeclaredCheckedException )).given (target ).doSomething ();
145
153
invokeProxy ();
@@ -149,13 +157,15 @@ void targetThrowsUndeclaredCheckedException() throws DeclaredCheckedException {
149
157
}
150
158
151
159
@ Test
160
+ @ SentenceFragment ("and the target throws a declared checked exception" )
152
161
void targetThrowsDeclaredCheckedException () throws DeclaredCheckedException {
153
162
willThrow (declaredCheckedException ).given (target ).doSomething ();
154
163
invokeProxy ();
155
164
assertThat (throwableSeenByCaller ).isSameAs (declaredCheckedException );
156
165
}
157
166
158
167
@ Test
168
+ @ SentenceFragment ("and the target throws an unchecked exception" )
159
169
void targetThrowsUncheckedException () throws DeclaredCheckedException {
160
170
willThrow (uncheckedException ).given (target ).doSomething ();
161
171
invokeProxy ();
0 commit comments