77
77
import static org .junit .jupiter .api .Assertions .assertFalse ;
78
78
import static org .junit .jupiter .api .Assertions .assertNotNull ;
79
79
import static org .junit .jupiter .api .Assertions .assertNull ;
80
+ import static org .junit .jupiter .api .Assertions .assertSame ;
80
81
import static org .junit .jupiter .api .Assertions .assertThrows ;
81
82
import static org .junit .jupiter .api .Assertions .assertTrue ;
82
83
import static org .mockito .ArgumentMatchers .any ;
@@ -389,6 +390,7 @@ protected void testRunInUnmanagedTransactionAndWaitForRunResponse( boolean succe
389
390
390
391
ResponseHandler runResponseHandler = verifyRunInvoked ( connection , false , InternalBookmark .empty (), TransactionConfig .empty (), mode ).runHandler ;
391
392
assertFalse ( cursorFuture .isDone () );
393
+ Throwable error = new RuntimeException ();
392
394
393
395
if ( success )
394
396
{
@@ -397,18 +399,18 @@ protected void testRunInUnmanagedTransactionAndWaitForRunResponse( boolean succe
397
399
else
398
400
{
399
401
// When responded with a failure
400
- runResponseHandler .onFailure ( new RuntimeException () );
402
+ runResponseHandler .onFailure ( error );
401
403
}
402
404
403
405
// Then
404
406
assertTrue ( cursorFuture .isDone () );
405
407
if ( success )
406
408
{
407
- assertNotNull ( cursorFuture .get () );
409
+ assertFalse ( cursorFuture .get (). runError (). isPresent () );
408
410
}
409
411
else
410
412
{
411
- assertThrows ( RuntimeException . class , () -> await ( cursorFuture ) );
413
+ assertSame ( error , cursorFuture . get (). runError (). orElseThrow ( () -> new RuntimeException ( "Unexpected" ) ) );
412
414
}
413
415
}
414
416
@@ -474,11 +476,12 @@ protected void testFailedRunInAutoCommitTxWithWaitingForResponse( Bookmark bookm
474
476
assertFalse ( cursorFuture .isDone () );
475
477
476
478
ResponseHandler runResponseHandler = verifyRunInvoked ( connection , true , bookmark , config , mode ).runHandler ;
477
- runResponseHandler .onFailure ( new RuntimeException () );
479
+ Throwable error = new RuntimeException ();
480
+ runResponseHandler .onFailure ( error );
478
481
assertEquals ( bookmark , bookmarkHolder .getBookmark () );
479
482
480
- assertTrue ( cursorFuture .isCompletedExceptionally () );
481
- assertThrows ( RuntimeException . class , () -> await ( cursorFuture ) );
483
+ assertTrue ( cursorFuture .isDone () );
484
+ assertSame ( error , cursorFuture . get (). runError (). orElseThrow ( () -> new RuntimeException ( "Unexpected" ) ) );
482
485
}
483
486
484
487
private static InternalAuthToken dummyAuthToken ()
0 commit comments