/**
   * We know what is the next visa to apply. Let's add it to the list of applied visas and check
   * what is the new visaStatus of the request
   *
   * @param appliedVisa Visa to add
   */
  private void addAgreementVisa(RequestAgreementVisa appliedVisa) {
    getAgreementVisas().add(appliedVisa);

    RequestAgreementVisaStatus lastAppliedVisaStatus = appliedVisa.getStatus();

    // If last visa applied has been denied, no need to carry on: request is refused
    if (lastAppliedVisaStatus == RequestAgreementVisaStatus.DENIED) {
      nextAgreementVisaRank = -1;
      agreementStatus = RequestAgreementStatus.REFUSED;
      overallStatus = RequestOverallStatus.REFUSED;
    } else if (lastAppliedVisaStatus == RequestAgreementVisaStatus.GRANTED) {
      // Let's check if granted visa is the last one
      Integer rankOfLastExpectedVisa =
          ruleAud
              .getVisas()
              .stream()
              .max(Comparator.comparing(AgreementRuleVisaAud::getRank))
              .get()
              .getRank();

      if (appliedVisa.getRank().equals(rankOfLastExpectedVisa)) {
        nextAgreementVisaRank = -1;
        agreementStatus = RequestAgreementStatus.GRANTED;
        overallStatus = RequestOverallStatus.VALIDATED;
      } else {
        nextAgreementVisaRank++;
      }
    } else {
      // Not supposed to happen except business rule gets changed
      throw UNEXPECTED_ERROR.exception(
          "Unknown visaStatus of agreement visa: " + lastAppliedVisaStatus);
    }
  }