use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testUpdateSuccessWithoutRegeneratingNewRepaymentSchedule.
@Test
public void testUpdateSuccessWithoutRegeneratingNewRepaymentSchedule() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
accountBO = getLoanAccount();
LoanBO loan = (LoanBO) accountBO;
LoanOfferingBO loanOffering = loan.getLoanOffering();
Date firstInstallmentDate = loan.getDetailsOfNextInstallment().getActionDate();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
Date newDate = DateUtils.addWeeks(loan.getDisbursementDate(), 1);
Date originalDate = loan.getDisbursementDate();
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "update");
addRequestParameter("loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
addRequestParameter("interestRate", loan.getLoanOffering().getDefInterestRate().toString());
addRequestParameter("noOfInstallments", loanOffering.getDefaultNumOfEligibleInstallmentsSameForAllLoan().toString());
addRequestParameter("disbursementDate", DateUtils.format(newDate));
addRequestParameter("businessActivityId", "1");
addRequestParameter("intDedDisbursement", "0");
addRequestParameter("gracePeriodDuration", "1");
addRequestParameter("collateralNote", "test");
actionPerform();
verifyForward(ActionForwards.update_success.toString());
loan = TestObjectFactory.getObject(LoanBO.class, loan.getAccountId());
Assert.assertEquals("test", loan.getCollateralNote());
Assert.assertEquals(300.0, loan.getLoanAmount().getAmount().doubleValue(), DELTA);
Assert.assertEquals(1, loan.getGracePeriodDuration().intValue());
Assert.assertEquals(DateUtils.format(originalDate), DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loan.getDisbursementDate())));
Assert.assertEquals(firstInstallmentDate, loan.getAccountActionDate(Short.valueOf("1")).getActionDate());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LegacyLoanDaoIntegrationTest method testFindBySystemId.
@Test
public void testFindBySystemId() throws Exception {
LegacyLoanDao loanPersistance = legacyLoanDao;
LoanBO loanBO = loanPersistance.findBySystemId(loanAccount.getGlobalAccountNum());
Assert.assertEquals(loanAccount.getGlobalAccountNum(), loanBO.getGlobalAccountNum());
Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LegacyLoanDaoIntegrationTest method testFindByExternalId.
@Test
public void testFindByExternalId() throws Exception {
String externalId = "ABC";
StaticHibernateUtil.startTransaction();
loanAccount.setExternalId(externalId);
StaticHibernateUtil.flushSession();
LegacyLoanDao loanPersistance = legacyLoanDao;
LoanBO loanBO = loanPersistance.findByExternalId(loanAccount.getExternalId());
Assert.assertEquals(externalId, loanBO.getExternalId());
Assert.assertEquals(loanAccount.getAccountId(), loanBO.getAccountId());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LegacyLoanDaoIntegrationTest method testGetAccount.
@Test
public void testGetAccount() throws Exception {
LoanBO loanBO = legacyLoanDao.getAccount(loanAccount.getAccountId());
Assert.assertEquals(loanBO.getAccountId(), loanAccount.getAccountId());
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionIndividualLoansIntegrationTest method testShouldCallDeleteMethodIfExistingMembersRemoved.
@Test
public void testShouldCallDeleteMethodIfExistingMembersRemoved() throws Exception {
GlimLoanUpdater glimLoanUpdaterMock = createMock(GlimLoanUpdater.class);
LoanAccountAction loanAccountAction = new LoanAccountAction(ApplicationContextProvider.getBean(LoanBusinessService.class), new ConfigurationBusinessService(), glimLoanUpdaterMock);
LoanBO loanMock = createMock(LoanBO.class);
Locale locale = Locale.ENGLISH;
expect(loanMock.getAccountId()).andReturn(2).anyTimes();
ClientBO customerMock = createMock(ClientBO.class);
expect(loanMock.getCustomer()).andReturn(customerMock).anyTimes();
expect(customerMock.getGlobalCustNum()).andReturn("3").anyTimes();
LoanAccountActionForm loanAccountActionForm = new LoanAccountActionForm();
List<LoanAccountDetailsDto> clientDetails = new ArrayList<LoanAccountDetailsDto>();
List<LoanBO> loans = new ArrayList<LoanBO>();
loans.add(loanMock);
glimLoanUpdaterMock.delete(loanMock);
expectLastCall().atLeastOnce();
replay(glimLoanUpdaterMock, loanMock, customerMock);
loanAccountAction.handleIndividualLoans(loanMock, loanAccountActionForm, true, clientDetails, loans, locale);
verify(glimLoanUpdaterMock, loanMock, customerMock);
}
Aggregations