use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class InstallmentRulesValidatorTest method shouldValidateForDueDateFallingOnHoliday.
@Test
public void shouldValidateForDueDateFallingOnHoliday() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("01-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).build();
Calendar holiday = installment1.getDueDateValueAsCalendar();
when(holidayServiceFacade.isFutureRepaymentHoliday(officeId, holiday)).thenReturn(true);
List<ErrorEntry> errorEntries = installmentRulesValidator.validateForHolidays(asList(installment1, installment2), holidayServiceFacade, officeId);
assertErrorEntry(errorEntries.get(0), AccountConstants.INSTALLMENT_DUEDATE_IS_HOLIDAY, "1");
verify(holidayServiceFacade, times(1)).isFutureRepaymentHoliday(officeId, holiday);
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class ListOfInstallmentsValidatorTest method shouldValidateInstallmentsForInvalidOrderOfDueDates.
@Test
public void shouldValidateInstallmentsForInvalidOrderOfDueDates() {
RepaymentScheduleInstallment installment0 = installmentBuilder.reset(locale).withInstallment(0).build();
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withDueDateValue("29-Nov-2010").build();
RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).build();
RepaymentScheduleInstallment installment4 = installmentBuilder.reset(locale).withInstallment(4).withDueDateValue("01-Jan-2011").build();
List<ErrorEntry> errorEntries = listOfInstallmentsValidator.validateOrderingOfDueDates(asList(installment0, installment1, installment2, installment3, installment4));
assertThat(errorEntries.get(0).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_INVALID_ORDER));
assertThat(errorEntries.get(0).getArgs(), is(Arrays.asList("2")));
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class ListOfInstallmentsValidatorTest method shouldValidateInstallmentsForDuplicateDueDates.
@Test
public void shouldValidateInstallmentsForDuplicateDueDates() {
RepaymentScheduleInstallment installment1 = installmentBuilder.reset(locale).withInstallment(1).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment2 = installmentBuilder.reset(locale).withInstallment(2).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment3 = installmentBuilder.reset(locale).withInstallment(3).build();
RepaymentScheduleInstallment installment4 = installmentBuilder.reset(locale).withInstallment(4).withDueDateValue("01-Jan-2011").build();
RepaymentScheduleInstallment installment5 = installmentBuilder.reset(locale).withInstallment(5).withDueDateValue("31-Dec-2010").build();
RepaymentScheduleInstallment installment6 = installmentBuilder.reset(locale).withInstallment(6).withDueDateValue("30-Nov-2010").build();
RepaymentScheduleInstallment installment7 = installmentBuilder.reset(locale).withInstallment(7).withDueDateValue("31-Dec-2010").build();
List<ErrorEntry> errorEntries = listOfInstallmentsValidator.validateDuplicateDueDates(asList(installment1, installment2, installment3, installment4, installment5, installment6, installment7));
assertThat(errorEntries.size(), is(2));
assertThat(errorEntries.get(0).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_DUPLICATE));
assertThat(errorEntries.get(0).getArgs(), is(Arrays.asList("[1, 2, 6]")));
assertThat(errorEntries.get(1).getErrorCode(), is(AccountConstants.INSTALLMENT_DUEDATE_DUPLICATE));
assertThat(errorEntries.get(1).getArgs(), is(Arrays.asList("[5, 7]")));
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class InstallmentFormatValidatorTest method shouldValidateVariableInstallmentScheduleForValidDueDate.
@Test
public void shouldValidateVariableInstallmentScheduleForValidDueDate() {
RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDate("30-Nov-2010").withPrincipal(new Money(rupeeCurrency, "499.9")).withInterest(new Money(rupeeCurrency, "22.1")).withFees(new Money(rupeeCurrency, "0.0")).withTotal("522.0").build();
List<ErrorEntry> errorEntries = installmentFormatValidator.validateDueDateFormat(installment);
assertThat(errorEntries.isEmpty(), is(true));
}
use of org.mifos.platform.validations.ErrorEntry in project head by mifos.
the class InstallmentFormatValidatorTest method shouldNotValidateInstallmentScheduleForTotalAmountLessThanZero.
@Test
public void shouldNotValidateInstallmentScheduleForTotalAmountLessThanZero() {
RepaymentScheduleInstallment installment = installmentBuilder.withInstallment(3).withDueDate("30-Nov-2010").withPrincipal(new Money(rupeeCurrency, "499.9")).withInterest(new Money(rupeeCurrency, "22.1")).withFees(new Money(rupeeCurrency, "0.0")).withTotal("-499.9").build();
List<ErrorEntry> errorEntries = installmentFormatValidator.validateTotalAmountFormat(installment);
assertThat(errorEntries.isEmpty(), is(true));
}
Aggregations