@@ -249,13 +249,17 @@ public void should_leave_causing_stack() throws Exception {
249
249
settings , new MockHandlerImpl <>(settings ), new ExceptionThrowingClass ());
250
250
251
251
StackTraceElement [] returnedStack =
252
- assertThrows (IOException .class , () -> proxy .get ().throwException ()).getStackTrace ();
252
+ assertThrows (IOException .class , () -> proxy .get ().throwException ()).getStackTrace ();
253
253
254
254
assertNotNull ("Stack trace from mockito expected" , returnedStack );
255
255
256
- List <StackTraceElement > exceptionClassElements = Arrays .stream (returnedStack )
257
- .filter (element -> element .getClassName ().equals (ExceptionThrowingClass .class .getName ()))
258
- .collect (Collectors .toList ());
256
+ List <StackTraceElement > exceptionClassElements =
257
+ Arrays .stream (returnedStack )
258
+ .filter (
259
+ element ->
260
+ element .getClassName ()
261
+ .equals (ExceptionThrowingClass .class .getName ()))
262
+ .collect (Collectors .toList ());
259
263
assertEquals (3 , exceptionClassElements .size ());
260
264
assertEquals ("internalThrowException" , exceptionClassElements .get (0 ).getMethodName ());
261
265
assertEquals ("internalThrowException" , exceptionClassElements .get (1 ).getMethodName ());
@@ -264,26 +268,34 @@ public void should_leave_causing_stack() throws Exception {
264
268
265
269
@ Test
266
270
public void should_leave_causing_stack_with_two_spies () throws Exception {
267
- //given
271
+ // given
268
272
MockSettingsImpl <ExceptionThrowingClass > settingsEx = new MockSettingsImpl <>();
269
273
settingsEx .setTypeToMock (ExceptionThrowingClass .class );
270
274
settingsEx .defaultAnswer (Answers .CALLS_REAL_METHODS );
271
275
Optional <ExceptionThrowingClass > proxyEx =
272
- mockMaker .createSpy (settingsEx , new MockHandlerImpl <>(settingsEx ), new ExceptionThrowingClass ());
276
+ mockMaker .createSpy (
277
+ settingsEx ,
278
+ new MockHandlerImpl <>(settingsEx ),
279
+ new ExceptionThrowingClass ());
273
280
274
281
MockSettingsImpl <WrapperClass > settingsWr = new MockSettingsImpl <>();
275
282
settingsWr .setTypeToMock (WrapperClass .class );
276
283
settingsWr .defaultAnswer (Answers .CALLS_REAL_METHODS );
277
284
Optional <WrapperClass > proxyWr =
278
- mockMaker .createSpy (settingsWr , new MockHandlerImpl <>(settingsWr ), new WrapperClass ());
285
+ mockMaker .createSpy (
286
+ settingsWr , new MockHandlerImpl <>(settingsWr ), new WrapperClass ());
279
287
280
- //when
281
- IOException ex = assertThrows (IOException .class , () -> proxyWr .get ().callWrapped (proxyEx .get ()));
282
- List <StackTraceElement > wrapperClassElements = Arrays .stream (ex .getStackTrace ())
283
- .filter (element -> element .getClassName ().equals (WrapperClass .class .getName ()))
284
- .collect (Collectors .toList ());
288
+ // when
289
+ IOException ex =
290
+ assertThrows (IOException .class , () -> proxyWr .get ().callWrapped (proxyEx .get ()));
291
+ List <StackTraceElement > wrapperClassElements =
292
+ Arrays .stream (ex .getStackTrace ())
293
+ .filter (
294
+ element ->
295
+ element .getClassName ().equals (WrapperClass .class .getName ()))
296
+ .collect (Collectors .toList ());
285
297
286
- //then
298
+ // then
287
299
assertEquals (1 , wrapperClassElements .size ());
288
300
assertEquals ("callWrapped" , wrapperClassElements .get (0 ).getMethodName ());
289
301
}
0 commit comments