### Question:
StateTracker { StateTracker setState(final State newState) throws IllegalStateException { for (; ;) { final State oldState = get(); oldState.check(newState); if (state.compareAndSet(oldState, newState)) { return this; } } }  State get(); @Override String toString();  }### Answer:
@Test public void testIllegalShutdownTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING).setState(STARTED).setState(SHUTTING_DOWN).setState(SHUTDOWN), NOT_STARTED, STARTED, SHUTTING_DOWN, SHUTDOWN); }
@Test public void testIllegalShuttingDownTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING).setState(STARTED).setState(SHUTTING_DOWN), NOT_STARTED, STARTING, STARTED, SHUTTING_DOWN); }
@Test public void testIllegalStartedTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING).setState(STARTED), STARTED, NOT_STARTED, STARTING, SHUTDOWN); }
@Test public void testIllegalStartingTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING), NOT_STARTED, STARTING, SHUTTING_DOWN, SHUTDOWN); }
@Test public void testIllegalWarmRestartTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING).setState(STARTED).setState(WARM_RESTARTING).setState(STARTED), STARTED, NOT_STARTED, STARTING, SHUTDOWN); }
@Test public void testIllegalWarmRestartingTransitions() throws Exception { assertIllegalState(new StateTracker().setState(STARTING).setState(STARTED).setState(WARM_RESTARTING), NOT_STARTED, STARTING, SHUTDOWN, SHUTTING_DOWN); }
@Test public void testStandardTransitions() throws Exception { new StateTracker().setState(STARTING).setState(STARTED).setState(SHUTTING_DOWN).setState(SHUTDOWN).setState(STARTING); }