BoltProtocolV3 implements BoltProtocol { @Override public CompletionStage<Bookmark> commitTransaction( Connection connection ) { CompletableFuture<Bookmark> commitFuture = new CompletableFuture<>(); connection.writeAndFlush( COMMIT, new CommitTxResponseHandler( commitFuture ) ); return commitFuture; }  @Override MessageFormat createMessageFormat(); @Override void initializeChannel( String userAgent, AuthToken authToken, RoutingContext routingContext, ChannelPromise channelInitializedPromise ); @Override void prepareToCloseChannel( Channel channel ); @Override CompletionStage<Void> beginTransaction( Connection connection, Bookmark bookmark, TransactionConfig config ); @Override CompletionStage<Bookmark> commitTransaction( Connection connection ); @Override CompletionStage<Void> rollbackTransaction( Connection connection ); @Override ResultCursorFactory runInAutoCommitTransaction(Connection connection, Query query, BookmarkHolder bookmarkHolder,
                                                          TransactionConfig config, boolean waitForRunResponse, long fetchSize ); @Override ResultCursorFactory runInUnmanagedTransaction(Connection connection, Query query, UnmanagedTransaction tx,
                                                         boolean waitForRunResponse, long fetchSize ); @Override BoltProtocolVersion version(); static final BoltProtocolVersion VERSION; static final BoltProtocol INSTANCE; static final MetadataExtractor METADATA_EXTRACTOR; }
@Test void shouldCommitTransaction() { String bookmarkString = "neo4j:bookmark:v1:tx4242"; Connection connection = connectionMock( protocol ); when( connection.protocol() ).thenReturn( protocol ); doAnswer( invocation -> { ResponseHandler commitHandler = invocation.getArgument( 1 ); commitHandler.onSuccess( singletonMap( "bookmark", value( bookmarkString ) ) ); return null; } ).when( connection ).writeAndFlush( eq( CommitMessage.COMMIT ), any() ); CompletionStage<Bookmark> stage = protocol.commitTransaction( connection ); verify( connection ).writeAndFlush( eq( CommitMessage.COMMIT ), any( CommitTxResponseHandler.class ) ); assertEquals( InternalBookmark.parse( bookmarkString ), await( stage ) ); }