### Question:
FailedState implements BoltStateMachineState { @Override public BoltStateMachineState process( RequestMessage message, StateMachineContext context ) throws BoltConnectionFatality { assertInitialized(); if ( shouldIgnore( message ) ) { context.connectionState().markIgnored(); return this; } if ( message instanceof AckFailureMessage ) { context.connectionState().resetPendingFailedAndIgnored(); return readyState; } if ( message instanceof ResetMessage ) { return processResetMessage( context ); } if ( message instanceof InterruptSignal ) { return interruptedState; } return null; }  @Override BoltStateMachineState process( RequestMessage message, StateMachineContext context ); @Override String name(); void setReadyState( BoltStateMachineState readyState ); void setInterruptedState( BoltStateMachineState interruptedState );  }### Answer:
@Test void shouldProcessRunMessage() throws Exception { BoltStateMachineState newState = state.process( new RunMessage( "RETURN 1", EMPTY_MAP ), context ); assertEquals( state, newState ); assertTrue( connectionState.hasPendingIgnore() ); }
@Test void shouldProcessPullAllMessage() throws Exception { BoltStateMachineState newState = state.process( PullAllMessage.INSTANCE, context ); assertEquals( state, newState ); assertTrue( connectionState.hasPendingIgnore() ); }
@Test void shouldProcessDiscardAllMessage() throws Exception { BoltStateMachineState newState = state.process( DiscardAllMessage.INSTANCE, context ); assertEquals( state, newState ); assertTrue( connectionState.hasPendingIgnore() ); }
@Test void shouldProcessAckFailureMessageWithPendingIgnore() throws Exception { connectionState.markIgnored(); assertTrue( connectionState.hasPendingIgnore() ); BoltStateMachineState newState = state.process( AckFailureMessage.INSTANCE, context ); assertEquals( readyState, newState ); assertFalse( connectionState.hasPendingIgnore() ); }
@Test void shouldProcessAckFailureMessageWithPendingError() throws Exception { Neo4jError error = Neo4jError.from( new RuntimeException() ); connectionState.markFailed( error ); assertEquals( error, connectionState.getPendingError() ); BoltStateMachineState newState = state.process( AckFailureMessage.INSTANCE, context ); assertEquals( readyState, newState ); assertNull( connectionState.getPendingError() ); }
@Test void shouldProcessResetMessageWithPerndingIgnore() throws Exception { when( context.resetMachine() ).thenReturn( true ); connectionState.markIgnored(); assertTrue( connectionState.hasPendingIgnore() ); BoltStateMachineState newState = state.process( ResetMessage.INSTANCE, context ); assertEquals( readyState, newState ); assertFalse( connectionState.hasPendingIgnore() ); }
@Test void shouldProcessResetMessageWithPerndingError() throws Exception { when( context.resetMachine() ).thenReturn( true ); Neo4jError error = Neo4jError.from( new RuntimeException() ); connectionState.markFailed( error ); assertEquals( error, connectionState.getPendingError() ); BoltStateMachineState newState = state.process( ResetMessage.INSTANCE, context ); assertEquals( readyState, newState ); assertNull( connectionState.getPendingError() ); }
@Test void shouldHandleResetMessageFailure() throws Exception { when( context.resetMachine() ).thenReturn( false ); BoltStateMachineState newState = state.process( ResetMessage.INSTANCE, context ); assertEquals( state, newState ); }
@Test void shouldProcessInterruptMessage() throws Exception { BoltStateMachineState newState = state.process( InterruptSignal.INSTANCE, context ); assertEquals( interruptedState, newState ); }
@Test void shouldNotProcessUnsupportedMessage() throws Exception { RequestMessage unsupportedMessage = mock( RequestMessage.class ); BoltStateMachineState newState = state.process( unsupportedMessage, context ); assertNull( newState ); }