NetworkSession { public Bookmark lastBookmark() { return bookmarkHolder.getBookmark(); } NetworkSession( ConnectionProvider connectionProvider, RetryLogic retryLogic, DatabaseName databaseName, AccessMode mode,
            BookmarkHolder bookmarkHolder, long fetchSize, Logging logging ); CompletionStage<ResultCursor> runAsync(Query query, TransactionConfig config, boolean waitForRunResponse ); CompletionStage<RxResultCursor> runRx(Query query, TransactionConfig config ); CompletionStage<UnmanagedTransaction> beginTransactionAsync( TransactionConfig config ); CompletionStage<UnmanagedTransaction> beginTransactionAsync( AccessMode mode, TransactionConfig config ); CompletionStage<Void> resetAsync(); RetryLogic retryLogic(); Bookmark lastBookmark(); CompletionStage<Void> releaseConnectionAsync(); CompletionStage<Connection> connectionAsync(); boolean isOpen(); CompletionStage<Void> closeAsync();  }
@Test void updatesBookmarkWhenTxIsClosed() { Bookmark bookmarkAfterCommit = InternalBookmark.parse( "TheBookmark" ); BoltProtocol protocol = spy( BoltProtocolV4.INSTANCE ); doReturn( completedFuture( bookmarkAfterCommit ) ).when( protocol ).commitTransaction( any( Connection.class ) ); when( connection.protocol() ).thenReturn( protocol ); UnmanagedTransaction tx = beginTransaction( session ); assertThat( session.lastBookmark(), instanceOf( InternalBookmark.class ) ); Bookmark bookmark = (InternalBookmark) session.lastBookmark(); assertTrue( bookmark.isEmpty() ); await( tx.commitAsync() ); assertEquals( bookmarkAfterCommit, session.lastBookmark() ); }
@Test void bookmarkIsPropagatedBetweenTransactions() { Bookmark bookmark1 = InternalBookmark.parse( "Bookmark1" ); Bookmark bookmark2 = InternalBookmark.parse( "Bookmark2" ); NetworkSession session = newSession( connectionProvider ); BoltProtocol protocol = spy( BoltProtocolV4.INSTANCE ); doReturn( completedFuture( bookmark1 ), completedFuture( bookmark2 ) ).when( protocol ).commitTransaction( any( Connection.class ) ); when( connection.protocol() ).thenReturn( protocol ); UnmanagedTransaction tx1 = beginTransaction( session ); await( tx1.commitAsync() ); assertEquals( bookmark1, session.lastBookmark() ); UnmanagedTransaction tx2 = beginTransaction( session ); verifyBeginTx( connection, bookmark1 ); await( tx2.commitAsync() ); assertEquals( bookmark2, session.lastBookmark() ); }
@Test void testPassingNoBookmarkShouldRetainBookmark() { NetworkSession session = newSession( connectionProvider, InternalBookmark.parse( "X" ) ); beginTransaction( session ); assertThat( session.lastBookmark(), equalTo( InternalBookmark.parse( "X" ) ) ); }
@Test void shouldHaveEmptyLastBookmarkInitially() { assertThat( session.lastBookmark(), instanceOf( InternalBookmark.class ) ); Bookmark bookmark = (InternalBookmark) session.lastBookmark(); assertTrue( bookmark.isEmpty() ); }