@Test
public void getLoanRepaymentScheduleShouldValidateViewDate() throws Exception {

    ActionForward getLoanScheduleFailure = new ActionForward("getLoanRepaymentScheduleFailure");
    java.sql.Date extraInterestDate = TestUtils.getSqlDate(10, 7, 2010);
    Errors errors = new Errors();
    errors.addError(LoanConstants.CANNOT_VIEW_REPAYMENT_SCHEDULE, new String[] {extraInterestDate.toString()});
    when(loanBusinessService.computeExtraInterest(loanBO, extraInterestDate)).thenReturn(errors);
    when(form.getScheduleViewDateValue(Locale.US)).thenReturn(extraInterestDate);
    when(request.getParameter("accountId")).thenReturn("1");
    when(mapping.findForward("getLoanRepaymentScheduleFailure")).thenReturn(getLoanScheduleFailure);
    when(loanServiceFacade.retrieveOriginalLoanSchedule(Matchers.<Integer>any())).
            thenReturn(new OriginalScheduleInfoDto("100", new Date(), Collections.<RepaymentScheduleInstallment>emptyList()));
    ActionForward forward = loanAccountAction.getLoanRepaymentSchedule(mapping, form, request, response);
    assertThat(forward, is(getLoanScheduleFailure));
    verify(form).resetScheduleViewDate();
}