UILifecycle { public void setState(UIState state) { if (state.ordinal() != this.state.ordinal() + 1) { throw new IllegalArgumentException( "Tried to move from state " + this.state.name() + " to " + state.name() + " which is not allowed"); } this.state = state; eventBus.fireEvent(new StateChangeEvent(this)); }  UIState getState(); void setState(UIState state); boolean isRunning(); boolean isTerminated(); HandlerRegistration addHandler(
            H handler);  }
@Test(expected = IllegalArgumentException.class) public void invalidStateChangeInitToTerminated() { lifecycle.setState(UIState.INITIALIZING); lifecycle.setState(UIState.TERMINATED); }
@Test(expected = IllegalArgumentException.class) public void invalidStateChangeRunningToInit() { lifecycle.setState(UIState.INITIALIZING); lifecycle.setState(UIState.RUNNING); lifecycle.setState(UIState.INITIALIZING); }
@Test(expected = IllegalArgumentException.class) public void invalidStateChangeTerminatedToInit() { lifecycle.setState(UIState.INITIALIZING); lifecycle.setState(UIState.RUNNING); lifecycle.setState(UIState.TERMINATED); lifecycle.setState(UIState.INITIALIZING); }
@Test(expected = IllegalArgumentException.class) public void invalidStateChangeTerminatedToRunning() { lifecycle.setState(UIState.INITIALIZING); lifecycle.setState(UIState.RUNNING); lifecycle.setState(UIState.TERMINATED); lifecycle.setState(UIState.RUNNING); }