private static Map<State, Set<State>> buildTransitions() {
Map<State, Set<State>> res = new EnumMap<>(State.class);
res.put(INIT, toSet(STARTING));
- res.put(STARTING, toSet(OPERATIONAL, RESTARTING, HARD_STOPPING, STOPPED));
+ res.put(STARTING, toSet(OPERATIONAL, RESTARTING, STOPPING, HARD_STOPPING, STOPPED));
res.put(OPERATIONAL, toSet(RESTARTING, STOPPING, HARD_STOPPING, STOPPED));
res.put(STOPPING, toSet(HARD_STOPPING, STOPPED));
res.put(RESTARTING, toSet(STARTING, HARD_STOPPING, STOPPED));
assertThat(underTest.getState()).isEqualTo(STOPPED);
}
+ @Test
+ public void verify_regular_start_and_early_graceful_stop_cycle() {
+ assertThat(underTest.getState()).isEqualTo(INIT);
+ assertThat(underTest.tryToMoveTo(STARTING)).isTrue();
+ assertThat(underTest.getState()).isEqualTo(STARTING);
+ assertThat(underTest.tryToMoveTo(STOPPING)).isTrue();
+ assertThat(underTest.getState()).isEqualTo(STOPPING);
+ assertThat(underTest.tryToMoveTo(STOPPED)).isTrue();
+ assertThat(underTest.getState()).isEqualTo(STOPPED);
+ }
+
@Test
public void verify_start_and_hard_stop_cycle() {
assertThat(underTest.getState()).isEqualTo(INIT);