### Question:
BoltStateMachineV1 implements BoltStateMachine { @Override public void markFailed( Neo4jError error ) { fail( error ); state = failedState; } BoltStateMachineV1( BoltStateMachineSPI spi, BoltChannel boltChannel, Clock clock ); @Override void process( RequestMessage message, BoltResponseHandler handler ); @Override void markFailed( Neo4jError error ); @Override void interrupt(); @Override void validateTransaction(); @Override void handleExternalFailure( Neo4jError error, BoltResponseHandler handler ); @Override boolean isClosed(); @Override void close(); @Override String id(); @Override void markForTermination(); @Override boolean shouldStickOnThread(); @Override boolean hasOpenStatement(); @Override boolean reset(); @Override void handleFailure( Throwable cause, boolean fatal ); BoltStateMachineState state(); StatementProcessor statementProcessor(); MutableConnectionState connectionState();  }### Answer:
@Test public void shouldSetPendingErrorOnMarkFailedIfNoHandler() { BoltStateMachineV1SPI spi = mock( BoltStateMachineV1SPI.class ); BoltChannel boltChannel = mock( BoltChannel.class ); BoltStateMachine machine = new BoltStateMachineV1( spi, boltChannel, Clock.systemUTC() ); Neo4jError error = Neo4jError.from( Status.Request.NoThreadsAvailable, "no threads" ); machine.markFailed( error ); assertEquals( error, pendingError( machine ) ); assertThat( machine, inState( FailedState.class ) ); }
@Test public void shouldSetPendingIgnoreOnMarkFailedIfAlreadyFailedAndNoHandler() throws Exception { BoltStateMachine machine = newMachine(); Neo4jError error1 = Neo4jError.from( new RuntimeException() ); machine.markFailed( error1 ); Neo4jError error2 = Neo4jError.from( Status.Request.NoThreadsAvailable, "no threads" ); machine.markFailed( error2 ); assertTrue( pendingIgnore( machine ) ); assertEquals( error1, pendingError( machine ) ); assertThat( machine, inState( FailedState.class ) ); }