LoanAccountAction extends AccountAppAction implements QuestionnaireAction { @TransactionDemarcate(saveToken = true) public ActionForward getLoanRepaymentSchedule(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response) throws Exception { LoanAccountActionForm loanAccountActionForm = (LoanAccountActionForm) form; UserContext userContext = getUserContext(request); Integer loanId = Integer.valueOf(request.getParameter(ACCOUNT_ID)); Locale locale = userContext.getPreferredLocale(); Date viewDate = loanAccountActionForm.getScheduleViewDateValue(locale); LoanBO loan = getLoan(loanId); setSessionAtributeForGLIM(request, loan); loan.updateDetails(userContext); Errors errors = loanBusinessService.computeExtraInterest(loan, viewDate); if (errors.hasErrors()) { loanAccountActionForm.resetScheduleViewDate(); } OriginalScheduleInfoDto originalSchedule = this.loanServiceFacade.retrieveOriginalLoanSchedule(loanId); String memberAccountIdParam = request.getParameter("memberAccountId"); if (StringUtils.isNotBlank(memberAccountIdParam)) { Integer memberId = Integer.valueOf(memberAccountIdParam); LoanBO member = loan.findMemberById(memberId); if (member != null) { SessionUtils.setAttribute(CustomerConstants.CUSTOMER_NAME, member.getCustomer().getDisplayName(), request); SessionUtils.setAttribute(CustomerConstants.GLOBAL_CUST_NUM, member.getCustomer().getGlobalCustNum(), request); } } SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request); SessionUtils.setAttribute(Constants.ORIGINAL_SCHEDULE_AVAILABLE, originalSchedule.hasOriginalInstallments(), request); SessionUtils.setAttribute(Constants.VIEW_DATE, viewDate, request); String forward = errors.hasErrors() ? ActionForwards.getLoanRepaymentScheduleFailure.toString() : ActionForwards.getLoanRepaymentSchedule.toString(); addErrors(request, getActionErrors(errors)); return mapping.findForward(forward); } LoanAccountAction();  LoanAccountAction(final ConfigurationBusinessService configService,
                             final LoanBusinessService loanBusinessService, final GlimLoanUpdater glimLoanUpdater,
                             final LoanPrdBusinessService loanPrdBusinessService,
                             final ConfigurationPersistence configurationPersistence,
                             final AccountBusinessService accountBusinessService,
                             final GroupLoanAccountServiceFacade groupLoanAccountServiceFacade,
                             final InformationOrderServiceFacade informationOrderServiceFacade); @Deprecated  LoanAccountAction(final LoanBusinessService loanBusinessService, final ConfigurationBusinessService configService,
                      final GlimLoanUpdater glimLoanUpdater); @Deprecated private  LoanAccountAction(final ConfigurationBusinessService configService,
                              final LoanBusinessService loanBusinessService, final GlimLoanUpdater glimLoanUpdater); ActionForward viewAndEditAdditionalInformation(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward getInstallmentDetails(final ActionMapping mapping,
                                               @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request,
                                               @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward getAllActivity(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form,
                                        final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward forwardWaiveCharge(final ActionMapping mapping,
                                            @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request,
                                            @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(saveToken = true) ActionForward get(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                             @SuppressWarnings("unused") final HttpServletResponse response); void setQuestionGroupInstances(QuestionnaireServiceFacade questionnaireServiceFacade, HttpServletRequest request, Integer loanAccountId); @TransactionDemarcate(saveToken = true) ActionForward getLoanRepaymentSchedule(final ActionMapping mapping,
                                                  final ActionForm form, final HttpServletRequest request,
                                                  @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward viewOriginalSchedule(final ActionMapping mapping,
                                              @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request,
                                              @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward viewStatusHistory(final ActionMapping mapping,
                                           @SuppressWarnings("unused") final ActionForm form, final HttpServletRequest request,
                                           @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward validate(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                                  @SuppressWarnings("unused") final HttpServletResponse response); ActionForward redoLoanBegin(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form,
                                       @SuppressWarnings("unused") final HttpServletRequest request,
                                       @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward manage(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                                @SuppressWarnings("unused") final HttpServletResponse response); static void setSessionAtributeForGLIM(final HttpServletRequest request, LoanBO loanBO); @TransactionDemarcate(joinToken = true) ActionForward managePrevious(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form,
                                        final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward managePreview(final ActionMapping mapping, final ActionForm form,
                                       final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(validateAndResetToken = true) ActionForward cancel(final ActionMapping mapping, @SuppressWarnings("unused") final ActionForm form,
                                @SuppressWarnings("unused") final HttpServletRequest request,
                                @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(validateAndResetToken = true) ActionForward update(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                                @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) @Override ActionForward captureQuestionResponses(final ActionMapping mapping, final ActionForm form,
                                                  final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) @Override ActionForward editQuestionResponses(
            final ActionMapping mapping, final ActionForm form,
            final HttpServletRequest request, @SuppressWarnings("unused") final HttpServletResponse response); void setCustomerDao(CustomerDao customerDao); @TransactionDemarcate(saveToken = true) ActionForward getGroupLoanAccountDetails(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
                             @SuppressWarnings("unused") final HttpServletResponse response); @TransactionDemarcate(joinToken = true) ActionForward getGroupLoanRepaymentSchedule(final ActionMapping mapping,
                                                  final ActionForm form, final HttpServletRequest request,
                                                  @SuppressWarnings("unused") final HttpServletResponse response); ActionForward getDetails(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request,
            @SuppressWarnings("unused") final HttpServletResponse response); static final String CUSTOMER_ID; static final String ACCOUNT_ID; static final String GLOBAL_ACCOUNT_NUM; }
@Test public void getLoanRepaymentScheduleShouldCalculateExtraInterest() throws Exception { when(loanBusinessService.computeExtraInterest(eq(loanBO), Matchers.<Date>any())).thenReturn(new Errors()); when(request.getParameter("accountId")).thenReturn("1"); when(loanServiceFacade.retrieveOriginalLoanSchedule(Matchers.<Integer>any())). thenReturn(new OriginalScheduleInfoDto("100", new Date(), Collections.<RepaymentScheduleInstallment>emptyList())); loanAccountAction.getLoanRepaymentSchedule(mapping, form, request, response); verify(loanBusinessService, times(1)).computeExtraInterest(Matchers.<LoanBO>any(), Matchers.<Date>any()); }
@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(); }