Search in sources :

Example 6 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class EditCustomerStatusActionStrutsTest method testUpdateStatusForClientWhenClientIsAssignedPosition.

@SuppressWarnings("unchecked")
@Test
public void testUpdateStatusForClientWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(new PositionEntity(Short.valueOf("1")), client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", client.getCustomerId().toString());
    actionPerform();
    verifyForward(ActionForwards.loadStatus_success.toString());
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request));
    Assert.assertEquals("Size of the status list should be 2", 2, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", client.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "6");
    addRequestParameter("flagId", "7");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNotNull("Since new Status is Closed,so flag should be Duplicate.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request));
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNotNull(customerPosition.getCustomer());
        break;
    }
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
    cleanInitialObjects();
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Example 7 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class GroupActionStrutsTest method testGet.

@Ignore
@Test
public void testGet() throws Exception {
    createCustomers();
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(new PositionEntity((short) 1), client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    savingsBO = getSavingsAccount("fsaf6", "ads6");
    loanBO = getLoanAccount();
    group.update();
    StaticHibernateUtil.flushAndClearSession();
    setRequestPathInfo("/groupCustAction.do");
    addRequestParameter("method", "get");
    addRequestParameter("globalCustNum", group.getGlobalCustNum());
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.get_success.toString());
    center = TestObjectFactory.getCenter(center.getCustomerId());
    group = TestObjectFactory.getGroup(group.getCustomerId());
    client = TestObjectFactory.getClient(client.getCustomerId());
    loanBO = (LoanBO) legacyAccountDao.getAccount(loanBO.getAccountId());
    savingsBO = (SavingsBO) legacyAccountDao.getAccount(savingsBO.getAccountId());
    GroupInformationDto groupInformationDto = (GroupInformationDto) SessionUtils.getAttribute("groupInformationDto", request);
    Assert.assertEquals("Size of active loan accounts should be 1", 1, groupInformationDto.getLoanAccountsInUse().size());
    Assert.assertEquals("Size of active savings accounts should be 1", 1, groupInformationDto.getSavingsAccountsInUse().size());
    Assert.assertEquals("No of active (or on hold) clients should be 1", "1", groupInformationDto.getGroupPerformanceHistory().getActiveClientCount());
    Assert.assertEquals("No of clients that are not closed or cancelled should be 1", 1, groupInformationDto.getClientsOtherThanClosedAndCancelled().size());
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertEquals("Center Leader", customerPosition.getPosition().getName());
        break;
    }
    TestObjectFactory.removeCustomerFromPosition(group);
    StaticHibernateUtil.flushAndClearSession();
    center = TestObjectFactory.getCenter(Integer.valueOf(center.getCustomerId()).intValue());
    group = TestObjectFactory.getGroup(Integer.valueOf(group.getCustomerId()).intValue());
    client = TestObjectFactory.getClient(Integer.valueOf(client.getCustomerId()).intValue());
    loanBO = (LoanBO) legacyAccountDao.getAccount(loanBO.getAccountId());
    savingsBO = (SavingsBO) legacyAccountDao.getAccount(savingsBO.getAccountId());
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) GroupInformationDto(org.mifos.dto.screen.GroupInformationDto) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 8 with CustomerPositionEntity

use of org.mifos.customers.business.CustomerPositionEntity in project head by mifos.

the class TestObjectFactory method removeCustomerFromPosition.

public static void removeCustomerFromPosition(final CustomerBO customer) throws CustomerException {
    if (customer != null) {
        for (CustomerPositionEntity customerPositionEntity : customer.getCustomerPositions()) {
            customerPositionEntity.setCustomer(null);
        }
        customer.update();
        StaticHibernateUtil.flushSession();
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity)

Aggregations

CustomerPositionEntity (org.mifos.customers.business.CustomerPositionEntity)8 PositionEntity (org.mifos.customers.business.PositionEntity)7 Test (org.junit.Test)4 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 CustomerFlagDetailEntity (org.mifos.customers.business.CustomerFlagDetailEntity)3 CustomerPositionDto (org.mifos.dto.domain.CustomerPositionDto)3 ArrayList (java.util.ArrayList)2 CustomerDetailDto (org.mifos.dto.domain.CustomerDetailDto)2 CustomerPositionOtherDto (org.mifos.dto.domain.CustomerPositionOtherDto)2 Ignore (org.junit.Ignore)1 CustomerBO (org.mifos.customers.business.CustomerBO)1 GroupInformationDto (org.mifos.dto.screen.GroupInformationDto)1