@Test
public void shouldPreventIllegalStateTransition() throws Exception {

  Optional<RunState> runState = Optional.of(
      RunState.create(INSTANCE, State.QUEUED, StateData.zero(), NOW.minusMillis(1), 17));
  when(transaction.readActiveState(INSTANCE)).thenReturn(runState);
  try {
    stateManager.receive(Event.terminate(INSTANCE, Optional.empty()));
    fail();
  } catch (IllegalStateException ignore) {
  }
  verify(transaction, never()).updateActiveState(any(), any());
}