Search in sources :

Example 31 with AccountStateEntity

use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.

the class EditCustomerStatusActionStrutsTest method testUpdateStatusForClientForActiveLoanOfficer.

@SuppressWarnings("unchecked")
@Test
public void testUpdateStatusForClientForActiveLoanOfficer() throws CustomerException, PageExpiredException {
    createInitialObjects();
    CustomerBOTestUtils.setCustomerStatus(client, new CustomerStatusEntity(CustomerStatus.CLIENT_PARTIAL.getValue()));
    client.update();
    StaticHibernateUtil.flushAndClearSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    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", "3");
    addRequestParameter("flagId", "");
    actionPerform();
    verifyForward(ActionForwards.previewStatus_success.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    Assert.assertNotNull(SessionUtils.getAttribute(SavingsConstants.NEW_STATUS_NAME, request));
    Assert.assertNull("Since new Status is not Closed,so flag should be null.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request.getSession()));
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.client_detail_page.toString());
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    Assert.assertTrue(client.isActive());
    cleanInitialObjects();
}
Also used : CustomerStatusEntity(org.mifos.customers.business.CustomerStatusEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 32 with AccountStateEntity

use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsNotAssignedPosition.

@Test
public void testUIHelperWhenClientIsNotAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group.setUserContext(TestObjectFactory.getContext());
    CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
    }
    String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
    Assert.assertEquals("(Center Leader)", positionName);
    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());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Example 33 with AccountStateEntity

use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.

the class CustomerUIHelperFnStrutsTest method testUIHelperWhenClientIsAssignedPosition.

@Test
public void testUIHelperWhenClientIsAssignedPosition() throws CustomerException, PageExpiredException {
    createInitialObjects();
    PositionEntity positionEntity = (PositionEntity) TestObjectFactory.getObject(PositionEntity.class, Short.valueOf("1"));
    CustomerPositionEntity customerPositionEntity = new CustomerPositionEntity(positionEntity, client, client.getParentCustomer());
    group.addCustomerPosition(customerPositionEntity);
    group.update();
    StaticHibernateUtil.flushSession();
    client = TestObjectFactory.getCustomer(client.getCustomerId());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    group.setUserContext(TestObjectFactory.getContext());
    CustomerDetailDto clientDetail = new CustomerDetailDto(client.getCustomerId(), client.getDisplayName(), client.getSearchId(), client.getGlobalCustNum());
    List<CustomerPositionOtherDto> customerPositions = new ArrayList<CustomerPositionOtherDto>();
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        customerPositions.add(new CustomerPositionOtherDto(customerPosition.getPosition().getName(), customerPosition.getCustomer().getCustomerId(), customerPosition.getCustomer().getDisplayName()));
    }
    String positionName = CustomerUIHelperFn.getClientPosition(customerPositions, clientDetail);
    Assert.assertEquals("(Center Leader)", positionName);
    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());
    group = TestObjectFactory.getCustomer(group.getCustomerId());
    Assert.assertFalse(client.isActive());
    for (CustomerFlagDetailEntity customerFlagDetailEntity : client.getCustomerFlags()) {
        Assert.assertFalse(customerFlagDetailEntity.getStatusFlag().isBlackListed());
        break;
    }
    for (CustomerPositionEntity customerPosition : group.getCustomerPositions()) {
        Assert.assertNull(customerPosition.getCustomer());
        break;
    }
}
Also used : CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) CustomerPositionEntity(org.mifos.customers.business.CustomerPositionEntity) PositionEntity(org.mifos.customers.business.PositionEntity) CustomerDetailDto(org.mifos.dto.domain.CustomerDetailDto) ArrayList(java.util.ArrayList) CustomerPositionOtherDto(org.mifos.dto.domain.CustomerPositionOtherDto) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerFlagDetailEntity(org.mifos.customers.business.CustomerFlagDetailEntity) Test(org.junit.Test)

Example 34 with AccountStateEntity

use of org.mifos.accounts.business.AccountStateEntity 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 35 with AccountStateEntity

use of org.mifos.accounts.business.AccountStateEntity in project head by mifos.

the class PentahoReportsServiceIntegrationTest method testGetAdminReport.

@Test
public void testGetAdminReport() throws Exception {
    String adminDocumentUploadPath = viewOrganizationSettingsServiceFacade.getAdminDocumentStorageDirectory();
    String adminDocumentPath = "IntegrationTest_Loan_template.prpt";
    File adminDocumentSrc = new File(this.getClass().getResource("/Loan_template.prpt").toString().replace("file:", ""));
    File adminDocumentDst = new File(adminDocumentUploadPath + "/" + adminDocumentPath);
    try {
        FileUtils.copyFile(adminDocumentSrc, adminDocumentDst);
        AdminDocumentBO adminDocumentBO = new AdminDocumentBO();
        adminDocumentBO.setAdmindocId(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentName("IntegrationTest_Loan_template");
        adminDocumentBO.setIsActive(Short.valueOf("1"));
        adminDocumentBO.setAdminDocumentIdentifier(adminDocumentPath);
        AdminDocAccStateMixBO adminDocAccStateMixBO = new AdminDocAccStateMixBO();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
        adminDocAccStateMixBO.setAccountStateID(accountStateEntity);
        adminDocAccStateMixBO.setAdminDocumentID(adminDocumentBO);
        legacyAdminDocumentDao.createOrUpdate(adminDocumentBO);
        Map<String, AbstractPentahoParameter> params = new HashMap<String, AbstractPentahoParameter>();
        PentahoInputParameter entityIdParameter = new PentahoInputParameter();
        entityIdParameter.setParamName("entity_id");
        entityIdParameter.setValue("000100000000002");
        params.put("entity_id", entityIdParameter);
        Integer adminDocId = Integer.parseInt(adminDocumentBO.getAdmindocId().toString());
        for (PentahoOutputType outputType : PentahoOutputType.values()) {
            PentahoReport report = pentahoReportsServiceImpl.getAdminReport(adminDocId, outputType.getId(), params);
            Assert.assertTrue(report.getFileExtension() == outputType.getFileExtension());
            Assert.assertTrue(report.getContentType() == outputType.getContentType());
            Assert.assertTrue(report.getErrors().isEmpty());
        }
    } catch (Exception e) {
        throw e;
    } finally {
        if (adminDocumentDst.exists()) {
            adminDocumentDst.delete();
        }
    }
}
Also used : PentahoReport(org.mifos.reports.pentaho.PentahoReport) AbstractPentahoParameter(org.mifos.reports.pentaho.params.AbstractPentahoParameter) HashMap(java.util.HashMap) AdminDocAccStateMixBO(org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) PentahoOutputType(org.mifos.reports.pentaho.util.PentahoOutputType) AdminDocumentBO(org.mifos.reports.admindocuments.business.AdminDocumentBO) PentahoInputParameter(org.mifos.reports.pentaho.params.PentahoInputParameter) File(java.io.File) Test(org.junit.Test)

Aggregations

AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)49 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)11 AccountStatusChangeHistoryEntity (org.mifos.accounts.business.AccountStatusChangeHistoryEntity)11 AccountException (org.mifos.accounts.exceptions.AccountException)8 PersistenceException (org.mifos.framework.exceptions.PersistenceException)7 Money (org.mifos.framework.util.helpers.Money)7 MifosRuntimeException (org.mifos.core.MifosRuntimeException)6 TransactionDemarcate (org.mifos.framework.util.helpers.TransactionDemarcate)6 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)5 AdminDocAccStateMixBO (org.mifos.reports.admindocuments.business.AdminDocAccStateMixBO)5 AdminDocumentBO (org.mifos.reports.admindocuments.business.AdminDocumentBO)5 Date (java.util.Date)4 List (java.util.List)4 LocalDate (org.joda.time.LocalDate)4 AccountPaymentEntity (org.mifos.accounts.business.AccountPaymentEntity)4 AccountStateFlagEntity (org.mifos.accounts.business.AccountStateFlagEntity)4 LoanBO (org.mifos.accounts.loan.business.LoanBO)4 DateTimeService (org.mifos.framework.util.DateTimeService)4 UserContext (org.mifos.security.util.UserContext)4