use of org.mifos.customers.business.CustomerHistoricalDataEntity in project head by mifos.
the class CustHistoricalDataActionStrutsTest method testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull.
@Test
public void testUpdateHistoricalDataWhenCustHistoricalDataIsNotNull() throws Exception {
SecurityContext securityContext = new SecurityContextImpl();
MifosUser principal = new MifosUserBuilder().nonLoanOfficer().withAdminRole().build();
Authentication authentication = new TestingAuthenticationToken(principal, principal);
securityContext.setAuthentication(authentication);
SecurityContextHolder.setContext(securityContext);
request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
createInitialObjects();
CustomerHistoricalDataEntity customerHistoricalDataEntity = new CustomerHistoricalDataEntity(group);
group.updateHistoricalData(customerHistoricalDataEntity);
group.update();
StaticHibernateUtil.flushSession();
SessionUtils.setAttribute(Constants.BUSINESS_KEY, group, request);
setRequestPathInfo("/custHistoricalDataAction.do");
addRequestParameter("method", "updateHistoricalData");
addRequestParameter("productName", "Test");
addRequestParameter("loanAmount", "200");
addRequestParameter("totalAmountPaid", "150");
addRequestParameter("interestPaid", "50");
addRequestParameter("missedPaymentsCount", "2");
addRequestParameter("totalPaymentsCount", "3");
addRequestParameter("commentNotes", "Test notes");
addRequestParameter("loanCycleNumber", "2");
addRequestParameter("type", "Group");
addRequestParameter("mfiJoiningDate", DateUtils.getCurrentDate(((UserContext) request.getSession().getAttribute("UserContext")).getPreferredLocale()));
addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
actionPerform();
verifyForward(ActionForwards.updateHistoricalData_success.toString());
verifyNoActionErrors();
verifyNoActionMessages();
group = TestObjectFactory.getGroup(group.getCustomerId());
Assert.assertEquals("Test", group.getHistoricalData().getProductName());
Assert.assertEquals("Test notes", group.getHistoricalData().getNotes());
Assert.assertEquals(new Money(getCurrency(), "200"), group.getHistoricalData().getLoanAmount());
Assert.assertEquals(new Money(getCurrency(), "150"), group.getHistoricalData().getTotalAmountPaid());
Assert.assertEquals(new Money(getCurrency(), "50"), group.getHistoricalData().getInterestPaid());
Assert.assertEquals(2, group.getHistoricalData().getMissedPaymentsCount().intValue());
Assert.assertEquals(3, group.getHistoricalData().getTotalPaymentsCount().intValue());
Assert.assertEquals(2, group.getHistoricalData().getLoanCycleNumber().intValue());
}
Aggregations