### Question:
TransactionStateMachine implements StatementProcessor { @Override public void beginTransaction( Bookmark bookmark ) throws KernelException { beginTransaction( bookmark, null, null ); } TransactionStateMachine( TransactionStateMachineSPI spi, AuthenticationResult authenticationResult, Clock clock ); State state(); @Override void beginTransaction( Bookmark bookmark ); @Override void beginTransaction( Bookmark bookmark, Duration txTimeout, Map<String,Object> txMetadata ); @Override StatementMetadata run( String statement, MapValue params ); @Override StatementMetadata run( String statement, MapValue params, Bookmark bookmark, Duration txTimeout, Map<String,Object> txMetaData ); @Override Bookmark streamResult( ThrowingConsumer<BoltResult, Exception> resultConsumer ); @Override Bookmark commitTransaction(); @Override void rollbackTransaction(); @Override boolean hasOpenStatement(); @Override void reset(); @Override void markCurrentTransactionForTermination(); @Override void validateTransaction(); @Override boolean hasTransaction();  }### Answer:
@Test void shouldTransitionToExplicitTransactionOnBegin() throws Exception { assertEquals( TransactionStateMachine.State.EXPLICIT_TRANSACTION, TransactionStateMachine.State.AUTO_COMMIT.beginTransaction( mutableState, stateMachineSPI, null, null, null ) ); }
@Test void shouldThrowOnBeginInExplicitTransaction() throws Exception { QueryExecutionKernelException e = assertThrows( QueryExecutionKernelException.class, () -> TransactionStateMachine.State.EXPLICIT_TRANSACTION.beginTransaction( mutableState, stateMachineSPI, null, null, null ) ); assertEquals( "Nested transactions are not supported.", e.getMessage() ); }
@Test void shouldNotWaitWhenNoBookmarkSupplied() throws Exception { stateMachine.beginTransaction( null ); verify( stateMachineSPI, never() ).awaitUpToDate( anyLong() ); }
@Test void shouldAwaitSingleBookmark() throws Exception { MapValue params = map( "bookmark", "neo4j:bookmark:v1:tx15" ); stateMachine.beginTransaction( Bookmark.fromParamsOrNull( params ) ); verify( stateMachineSPI ).awaitUpToDate( 15 ); }
@Test void shouldAwaitMultipleBookmarks() throws Exception { MapValue params = map( "bookmarks", asList( "neo4j:bookmark:v1:tx15", "neo4j:bookmark:v1:tx5", "neo4j:bookmark:v1:tx92", "neo4j:bookmark:v1:tx9" ) ); stateMachine.beginTransaction( Bookmark.fromParamsOrNull( params ) ); verify( stateMachineSPI ).awaitUpToDate( 92 ); }
@Test void shouldAwaitMultipleBookmarksWhenBothSingleAndMultipleSupplied() throws Exception { MapValue params = map( "bookmark", "neo4j:bookmark:v1:tx42", "bookmarks", asList( "neo4j:bookmark:v1:tx47", "neo4j:bookmark:v1:tx67", "neo4j:bookmark:v1:tx45" ) ); stateMachine.beginTransaction( Bookmark.fromParamsOrNull( params ) ); verify( stateMachineSPI ).awaitUpToDate( 67 ); }