### Question:
StageStateMachine { public boolean transitionToFinished() { return stageState.setIf(FINISHED, currentState -> !currentState.isDone()); } StageStateMachine(
            StageId stageId,
            Session session,
            PlanFragment fragment,
            Map<PlanNodeId, TableInfo> tables,
            ExecutorService executor,
            SplitSchedulerStats schedulerStats); StageId getStageId(); Session getSession(); StageState getState(); PlanFragment getFragment(); void addStateChangeListener(StateChangeListener<StageState> stateChangeListener); synchronized boolean transitionToScheduling(); synchronized boolean transitionToSchedulingSplits(); synchronized boolean transitionToScheduled(); boolean transitionToRunning(); boolean transitionToFlushing(); boolean transitionToFinished(); boolean transitionToCanceled(); boolean transitionToAborted(); boolean transitionToFailed(Throwable throwable); void addFinalStageInfoListener(StateChangeListener<StageInfo> finalStatusListener); void setAllTasksFinal(Iterable<TaskInfo> finalTaskInfos); long getUserMemoryReservation(); long getTotalMemoryReservation(); void updateMemoryUsage(long deltaUserMemoryInBytes, long deltaRevocableMemoryInBytes, long deltaTotalMemoryInBytes); BasicStageStats getBasicStageStats(Supplier<Iterable<TaskInfo>> taskInfosSupplier); StageInfo getStageInfo(Supplier<Iterable<TaskInfo>> taskInfosSupplier); void recordGetSplitTime(long startNanos); @Override String toString();  }### Answer:
@Test public void testFinished() { StageStateMachine stateMachine = createStageStateMachine(); assertTrue(stateMachine.transitionToFinished()); assertFinalState(stateMachine, StageState.FINISHED); }