Search in sources :

Example 6 with CustomerHistoricalDataEntity

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());
}
Also used : Money(org.mifos.framework.util.helpers.Money) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) Authentication(org.springframework.security.core.Authentication) UserContext(org.mifos.security.util.UserContext) CustomerHistoricalDataEntity(org.mifos.customers.business.CustomerHistoricalDataEntity) SecurityContext(org.springframework.security.core.context.SecurityContext) MifosUser(org.mifos.security.MifosUser) MifosUserBuilder(org.mifos.builders.MifosUserBuilder) TestingAuthenticationToken(org.springframework.security.authentication.TestingAuthenticationToken) Test(org.junit.Test)

Aggregations

CustomerHistoricalDataEntity (org.mifos.customers.business.CustomerHistoricalDataEntity)6 UserContext (org.mifos.security.util.UserContext)5 CustomerBO (org.mifos.customers.business.CustomerBO)3 MifosUser (org.mifos.security.MifosUser)3 Date (java.sql.Date)2 Test (org.junit.Test)2 CustHistoricalDataActionForm (org.mifos.customers.struts.actionforms.CustHistoricalDataActionForm)2 CustomerHistoricalDataDto (org.mifos.dto.screen.CustomerHistoricalDataDto)2 Money (org.mifos.framework.util.helpers.Money)2 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 InvalidDateException (org.mifos.application.admin.servicefacade.InvalidDateException)1 MifosUserBuilder (org.mifos.builders.MifosUserBuilder)1 ApplicationException (org.mifos.framework.exceptions.ApplicationException)1 DateTimeService (org.mifos.framework.util.DateTimeService)1 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)1 Authentication (org.springframework.security.core.Authentication)1 SecurityContext (org.springframework.security.core.context.SecurityContext)1 SecurityContextImpl (org.springframework.security.core.context.SecurityContextImpl)1