UnmanagedTransaction { public CompletionStage<Void> closeAsync() { if ( isOpen() ) { return rollbackAsync(); } else { return completedWithNull(); } } UnmanagedTransaction(Connection connection, BookmarkHolder bookmarkHolder, long fetchSize ); CompletionStage<UnmanagedTransaction> beginAsync(Bookmark initialBookmark, TransactionConfig config ); CompletionStage<Void> closeAsync(); CompletionStage<Void> commitAsync(); CompletionStage<Void> rollbackAsync(); CompletionStage<ResultCursor> runAsync(Query query, boolean waitForRunResponse ); CompletionStage<RxResultCursor> runRx(Query query); boolean isOpen(); void markTerminated( Throwable cause ); Connection connection();  }
@Test void shouldRollbackOnImplicitFailure() { Connection connection = connectionMock(); UnmanagedTransaction tx = beginTx( connection ); await( tx.closeAsync() ); InOrder order = inOrder( connection ); verifyBeginTx( connection ); verifyRollbackTx( connection ); order.verify( connection ).release(); }
@Test void shouldReleaseConnectionWhenClose() throws Throwable { Connection connection = connectionMock(); UnmanagedTransaction tx = new UnmanagedTransaction( connection, new DefaultBookmarkHolder(), UNLIMITED_FETCH_SIZE ); await( tx.closeAsync() ); verify( connection ).release(); }