docs: protected void ensureTransitionAllowed(CmmnActivityExecution execution, CaseExecutionState expected, CaseExecutionState target, String transition) {
      String id = execution.getId();
  
      CaseExecutionState currentState = execution.getCurrentState();
  
      // the state "suspending" or "terminating" will set immediately
      // inside the corresponding AtomicOperation, that's why the
      // previous state will be used to ensure that the transition
      // is allowed.
      if (execution.isTerminating() || execution.isSuspending()) {
        currentState = execution.getPreviousState();
      }
  
      // is the case execution already in the target state
      if (target.equals(currentState)) {
        throw LOG.isAlreadyInStateException(transition, id, target);
  
      } else
      // is the case execution in the expected state
      if (!expected.equals(currentState)) {
        throw LOG.unexpectedStateException(transition, id, expected, currentState);
      }
    }