@Test
  public void shouldValidateForGracePeriodWithDIPBInterestTypeAndVariableInstallments() {
    ActionMessageMatcher actionMessageMatcher =
        new ActionMessageMatcher(
            ProductDefinitionConstants.INVALID_INTEREST_TYPE_FOR_GRACE_PERIODS);

    loanPrdActionForm.setGracePeriodType(GraceType.PRINCIPALONLYGRACE.getValueAsString());
    loanPrdActionForm.setCanConfigureVariableInstallments(true);
    loanPrdActionForm.setInterestTypes(InterestType.FLAT.getValueAsString());
    loanPrdActionForm.validateInterestTypeForGracePeriods(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setGracePeriodType(GraceType.PRINCIPALONLYGRACE.getValueAsString());
    loanPrdActionForm.setCanConfigureVariableInstallments(false);
    loanPrdActionForm.setInterestTypes(InterestType.DECLINING_PB.getValueAsString());
    loanPrdActionForm.validateInterestTypeForGracePeriods(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setGracePeriodType(GraceType.GRACEONALLREPAYMENTS.getValueAsString());
    loanPrdActionForm.setCanConfigureVariableInstallments(true);
    loanPrdActionForm.setInterestTypes(InterestType.COMPOUND.getValueAsString());
    loanPrdActionForm.validateInterestTypeForGracePeriods(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setGracePeriodType(GraceType.NONE.getValueAsString());
    loanPrdActionForm.setCanConfigureVariableInstallments(false);
    loanPrdActionForm.setInterestTypes(InterestType.DECLINING_EPI.getValueAsString());
    loanPrdActionForm.validateInterestTypeForGracePeriods(errors, Locale.getDefault());
    Mockito.verifyZeroInteractions(errors);
    Mockito.reset(errors);
  }
  @Test
  public void onlyDecliningInterestTypeShouldBeSelectedForVariableInstallmentLoanProduct() {
    ActionMessageMatcher actionMessageMatcher =
        new ActionMessageMatcher(
            ProductDefinitionConstants.INVALID_INTEREST_TYPE_FOR_VARIABLE_INSTALLMENT);

    loanPrdActionForm.setCanConfigureVariableInstallments(true);
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setInterestTypes(InterestType.FLAT.getValueAsString());
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setInterestTypes(InterestType.DECLINING.getValueAsString());
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verifyZeroInteractions(errors);
    Mockito.reset(errors);

    loanPrdActionForm.setInterestTypes(InterestType.COMPOUND.getValueAsString());
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setInterestTypes(InterestType.DECLINING_EPI.getValueAsString());
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);

    loanPrdActionForm.setInterestTypes(InterestType.DECLINING_PB.getValueAsString());
    loanPrdActionForm.validateInterestTypeForVariableInstallment(errors, Locale.getDefault());
    Mockito.verify(errors).add(Mockito.anyString(), Mockito.argThat(actionMessageMatcher));
    Mockito.reset(errors);
  }