Search in sources :

Example 11 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class CheckListActionStrutsTest method testCreate_customer.

@Test
public void testCreate_customer() throws Exception {
    setRequestPathInfo("/chkListAction");
    addRequestParameter("method", "create");
    addRequestParameter("masterTypeId", "1");
    addRequestParameter("masterTypeName", "kendra");
    addRequestParameter("isCustomer", "true");
    addRequestParameter("type", "1");
    addRequestParameter("stateId", "13");
    addRequestParameter("stateName", "active");
    addRequestParameter("checklistName", "new checklistName");
    addRequestParameter("detailsList[0]", "newdetails");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyForward(ActionForwards.create_success.toString());
    List<CustomerCheckListBO> customerCheckLists = new CheckListPersistence().retreiveAllCustomerCheckLists();
    Assert.assertNotNull(customerCheckLists);
    Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    Assert.assertEquals(1, customerCheckLists.size());
    for (CustomerCheckListBO checkList : customerCheckLists) {
        Assert.assertEquals("new checklistName", checkList.getChecklistName());
        Assert.assertEquals("1", checkList.getCustomerLevel().getId().toString());
        Assert.assertEquals("13", checkList.getCustomerStatus().getId().toString());
        Assert.assertEquals("1", checkList.getChecklistStatus().toString());
        Assert.assertEquals(1, checkList.getChecklistDetails().size());
    }
}
Also used : CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) Test(org.junit.Test)

Example 12 with CustomerCheckListBO

use of org.mifos.customers.checklist.business.CustomerCheckListBO in project head by mifos.

the class CheckListActionStrutsTest method testUpdate_customer.

@Test
public void testUpdate_customer() throws Exception {
    CheckListBO checkList = TestObjectFactory.createCustomerChecklist(CustomerLevel.CENTER.getValue(), CustomerStatus.CENTER_ACTIVE.getValue(), (short) 1);
    StaticHibernateUtil.flushSession();
    checkList = (CheckListBO) TestObjectFactory.getObject(CustomerCheckListBO.class, checkList.getChecklistId());
    setRequestPathInfo("/chkListAction");
    addRequestParameter("method", "update");
    addRequestParameter("checklistName", checkList.getChecklistName());
    addRequestParameter("isCustomer", "true");
    addRequestParameter("detailsList[0]", "newdetails");
    addRequestParameter("masterTypeId", ((CustomerCheckListBO) checkList).getCustomerLevel().getId().toString());
    addRequestParameter("stateId", ((CustomerCheckListBO) checkList).getCustomerStatus().getId().toString());
    addRequestParameter("checklistStatus", CheckListConstants.STATUS_INACTIVE.toString());
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, checkList, request);
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.update_success.toString());
    Assert.assertNull(request.getAttribute(Constants.CURRENTFLOWKEY));
    StaticHibernateUtil.flushSession();
    checkList = (CheckListBO) TestObjectFactory.getObject(CustomerCheckListBO.class, checkList.getChecklistId());
    Assert.assertEquals(1, checkList.getChecklistDetails().size());
    checkList = null;
}
Also used : CheckListBO(org.mifos.customers.checklist.business.CheckListBO) CustomerCheckListBO(org.mifos.customers.checklist.business.CustomerCheckListBO) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) Test(org.junit.Test)

Aggregations

CustomerCheckListBO (org.mifos.customers.checklist.business.CustomerCheckListBO)12 Test (org.junit.Test)4 AccountCheckListBO (org.mifos.customers.checklist.business.AccountCheckListBO)4 CheckListPersistence (org.mifos.customers.checklist.persistence.CheckListPersistence)4 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)4 MifosRuntimeException (org.mifos.core.MifosRuntimeException)3 CustomerLevelEntity (org.mifos.customers.business.CustomerLevelEntity)3 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)3 CheckListBO (org.mifos.customers.checklist.business.CheckListBO)3 ChkListActionForm (org.mifos.customers.checklist.struts.actionforms.ChkListActionForm)3 ArrayList (java.util.ArrayList)2 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)2 CheckListException (org.mifos.customers.checklist.exceptions.CheckListException)2 CheckListStatesView (org.mifos.dto.screen.CheckListStatesView)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 MifosUser (org.mifos.security.MifosUser)2 UserContext (org.mifos.security.util.UserContext)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 List (java.util.List)1 AccountException (org.mifos.accounts.exceptions.AccountException)1