use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testManage.
@Test
public void testManage() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date startDate = new Date(System.currentTimeMillis());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
LoanBO loan = (LoanBO) accountBO;
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "manage");
addRequestParameter("customerId", accountBO.getCustomer().getCustomerId().toString());
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
actionPerform();
verifyForward(ActionForwards.manage_success.toString());
Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.LOANOFFERING, request));
Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.COLLATERAL_TYPES, request));
Assert.assertNotNull(SessionUtils.getAttribute(MasterConstants.BUSINESS_ACTIVITIES, request));
Assert.assertNotNull(SessionUtils.getAttribute(LoanConstants.CUSTOM_FIELDS, request));
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testManageWithoutFlow.
/*
* this test appears to be confirming that an unauthenticated user gets a
* "page expired" exception, but the catch() block doesn't appear to be
* reached.
*/
@Test
public void testManageWithoutFlow() throws Exception {
try {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date startDate = new Date(System.currentTimeMillis());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
LoanBO loan = (LoanBO) accountBO;
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter("method", "manage");
addRequestParameter("customerId", accountBO.getCustomer().getCustomerId().toString());
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
actionPerform();
// I'd normally expect to see a call to JUnit 3's fail() here
} catch (PageExpiredException pe) {
Assert.assertTrue(true);
Assert.assertEquals(ExceptionConstants.PAGEEXPIREDEXCEPTION, pe.getKey());
}
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testUpdateSuccessWithRegeneratingNewRepaymentSchedule.
@Test
public void testUpdateSuccessWithRegeneratingNewRepaymentSchedule() throws Exception {
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
Date startDate = new Date(System.currentTimeMillis());
String newDate = offSetCurrentDate(14, userContext.getPreferredLocale());
// This is a loan with weekly meetings every week. No interest is paid
// at disbursement, so the first payment will be one week after the
// disbursement date of the loan (14 days + 7 days = 21 days)
String firstInstallmentDateWithNoInterestPaidAtDisbursementDate = offSetCurrentDate(21, userContext.getPreferredLocale());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
((LoanBO) accountBO).setBusinessActivityId(1);
PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
accountBO.changeStatus(AccountState.LOAN_APPROVED, null, "status changed", loggedInUser);
accountBO.update();
StaticHibernateUtil.flushSession();
LoanBO loan = (LoanBO) accountBO;
LoanOfferingBO loanOffering = loan.getLoanOffering();
// loanOffering.updateLoanOfferingSameForAllLoan(loanOffering);
SessionUtils.setAttribute(Constants.BUSINESS_KEY, loan, request);
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "manage");
addRequestParameter("customerId", accountBO.getCustomer().getCustomerId().toString());
addRequestParameter("globalAccountNum", accountBO.getGlobalAccountNum());
actionPerform();
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "managePreview");
addRequestParameter("loanAmount", loanOffering.getEligibleLoanAmountSameForAllLoan().getDefaultLoanAmount().toString());
addRequestParameter("interestRate", loan.getLoanOffering().getDefInterestRate().toString());
addRequestParameter("noOfInstallments", loanOffering.getDefaultNumOfEligibleInstallmentsSameForAllLoan().toString());
addRequestParameter("disbursementDate", newDate);
addRequestParameter("gracePeriodDuration", "0");
addRequestParameter("intDedDisbursement", "0");
addRequestParameter("customerId", group.getCustomerId().toString());
actionPerform();
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
addRequestParameter("method", "update");
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(0, loan.getGracePeriodDuration().intValue());
Assert.assertEquals(firstInstallmentDateWithNoInterestPaidAtDisbursementDate, DateUtils.getUserLocaleDate(TestObjectFactory.getContext().getPreferredLocale(), DateUtils.toDatabaseFormat(loan.getAccountActionDate(Short.valueOf("1")).getActionDate())));
}
use of org.mifos.accounts.loan.business.LoanBO in project head by mifos.
the class LoanAccountActionStrutsTest method testGetWithPayment.
@Test
public void testGetWithPayment() throws Exception {
setMifosUserFromContext();
Date startDate = new Date(System.currentTimeMillis());
accountBO = getLoanAccount(AccountState.LOAN_APPROVED, startDate, 1);
disburseLoan(startDate);
LoanBO loan = (LoanBO) accountBO;
setRequestPathInfo("/loanAccountAction.do");
addRequestParameter("method", "get");
addRequestParameter("globalAccountNum", loan.getGlobalAccountNum());
actionPerform();
verifyForward("get_success");
Assert.assertEquals("Total no. of notes should be 5", 5, accountBO.getAccountNotes().size());
// LoanInformationDto loanInformationDto = retrieveLoanInformationDtoFromSession();
// Assert.assertEquals("Total no. of recent notes should be 3", 3, loanInformationDto.getRecentAccountNotes().size());
Assert.assertEquals("Last payment action should be 'PAYMENT'", AccountActionTypes.DISBURSAL.getValue(), SessionUtils.getAttribute(AccountConstants.LAST_PAYMENT_ACTION, request));
client = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, client.getCustomerId());
group = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, group.getCustomerId());
center = (CustomerBO) StaticHibernateUtil.getSessionTL().get(CustomerBO.class, center.getCustomerId());
}
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());
}
Aggregations