public boolean transitionToFailed(Throwable throwable)
    {
        // When the state enters FINISHING, the only thing remaining is to commit
        // the transaction. It should only be failed if the transaction commit fails.
        return transitionToFailed(throwable, currentState -> currentState != FINISHING && !currentState.isDone());
    }
@Test
    public void testFailed()
    {
        QueryStateMachine stateMachine = createQueryStateMachine();
        assertTrue(stateMachine.transitionToFailed(FAILED_CAUSE));
        assertFinalState(stateMachine, FAILED, FAILED_CAUSE);
    }