Search in sources :

Example 21 with AccountStateEntity

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

the class EditStatusActionStrutsTest method updateSuccessForLoan.

@Ignore("Convert to unit test")
public void updateSuccessForLoan() throws Exception {
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    //        createInitialObjects();
    createCenterGroupClientHierarchy();
    accountBO = getLoanAccount(client, meeting, AccountState.LOAN_ACTIVE_IN_GOOD_STANDING);
    setRequestPathInfo("/editStatusAction.do");
    addRequestParameter("method", "load");
    addRequestParameter("input", "loan");
    addRequestParameter("accountId", accountBO.getAccountId().toString());
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward("load_success");
    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("/editStatusAction.do");
    addRequestParameter("method", "preview");
    addRequestParameter("input", "loan");
    addRequestParameter("notes", "Test");
    addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
    addRequestParameter("newStatusId", "8");
    addRequestParameter("flagId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward("preview_success");
    StaticHibernateUtil.flushSession();
    setRequestPathInfo("/editStatusAction.do");
    addRequestParameter("method", "update");
    addRequestParameter("notes", "Test");
    addRequestParameter("accountTypeId", accountBO.getType().getValue().toString());
    addRequestParameter("newStatusId", "8");
    addRequestParameter("flagId", "1");
    addRequestParameter(Constants.CURRENTFLOWKEY, (String) request.getAttribute(Constants.CURRENTFLOWKEY));
    actionPerform();
    verifyForward(ActionForwards.loan_detail_page.toString());
    verifyNoActionErrors();
    verifyNoActionMessages();
    accountBO = TestObjectFactory.getObject(AccountBO.class, accountBO.getAccountId());
    List<AuditLog> auditLogList = TestObjectFactory.getChangeLog(EntityType.LOAN, accountBO.getAccountId());
    Assert.assertEquals(1, auditLogList.size());
    Assert.assertEquals(EntityType.LOAN.getValue(), auditLogList.get(0).getEntityType());
    Assert.assertEquals(3, auditLogList.get(0).getAuditLogRecords().size());
    for (AuditLogRecord auditLogRecord : auditLogList.get(0).getAuditLogRecords()) {
        if (auditLogRecord.getFieldName().equalsIgnoreCase("Explanation")) {
            Assert.assertEquals("-", auditLogRecord.getOldValue());
            Assert.assertEquals("Withdraw", auditLogRecord.getNewValue());
        } else if (auditLogRecord.getFieldName().equalsIgnoreCase("Status")) {
            Assert.assertEquals("Active in Good Standing", auditLogRecord.getOldValue());
            Assert.assertEquals("Closed- Rescheduled", auditLogRecord.getNewValue());
        }
    }
}
Also used : AccountBO(org.mifos.accounts.business.AccountBO) AuditLogRecord(org.mifos.framework.components.audit.business.AuditLogRecord) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) AuditLog(org.mifos.framework.components.audit.business.AuditLog) Ignore(org.junit.Ignore)

Example 22 with AccountStateEntity

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

the class LegacyMasterDaoIntegrationTest method testRetrieveMasterDataEntity.

@Test
public void testRetrieveMasterDataEntity() throws Exception {
    List<AccountStateEntity> masterDataList = legacyMasterDao.findMasterDataEntities(AccountStateEntity.class);
    Assert.assertEquals(18, masterDataList.size());
    for (MasterDataEntity masterDataEntity : masterDataList) {
        for (LookUpValueLocaleEntity lookUpValueLocaleEntity : masterDataEntity.getLookUpValue().getLookUpValueLocales()) {
            Assert.assertEquals(Short.valueOf("1"), lookUpValueLocaleEntity.getLocaleId());
        }
    }
}
Also used : MasterDataEntity(org.mifos.application.master.business.MasterDataEntity) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) LookUpValueLocaleEntity(org.mifos.application.master.business.LookUpValueLocaleEntity) Test(org.junit.Test)

Example 23 with AccountStateEntity

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

the class CheckListBOIntegrationTest method testUpdateAccountCheckListInvalidState.

@Test
public void testUpdateAccountCheckListInvalidState() throws Exception {
    AccountCheckListBO accountCheckList1 = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_APPROVED, CheckListConstants.STATUS_ACTIVE);
    accountCheckList = TestObjectFactory.createAccountChecklist(ProductType.LOAN.getValue(), AccountState.LOAN_ACTIVE_IN_GOOD_STANDING, CheckListConstants.STATUS_ACTIVE);
    AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.LOAN_APPROVED);
    StaticHibernateUtil.flushSession();
    accountCheckList = (AccountCheckListBO) TestObjectFactory.getObject(AccountCheckListBO.class, accountCheckList.getChecklistId());
    try {
        accountCheckList.update(accountCheckList.getProductTypeEntity(), accountStateEntity, "Account CheckList", CheckListConstants.STATUS_INACTIVE, getCheckListDetails(), (short) 1, (short) 1);
        Assert.fail();
    } catch (CheckListException ce) {
        Assert.assertTrue(true);
    } finally {
        TestObjectFactory.deleteChecklist(accountCheckList1);
        StaticHibernateUtil.flushSession();
    }
}
Also used : CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 24 with AccountStateEntity

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

the class EditCustomerStatusActionStrutsTest method testUpdateCenterStatus.

@SuppressWarnings("unchecked")
@Test
public void testUpdateCenterStatus() throws Exception {
    MeetingBO meeting = TestObjectFactory.createMeeting(TestObjectFactory.getTypicalMeeting());
    center = TestObjectFactory.createWeeklyFeeCenter("Center", meeting);
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.loadStatus.toString());
    addRequestParameter("customerId", center.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", 1, ((List<AccountStateEntity>) SessionUtils.getAttribute(SavingsConstants.STATUS_LIST, request)).size());
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.previewStatus.toString());
    addRequestParameter("notes", "Test");
    addRequestParameter("levelId", center.getCustomerLevel().getId().toString());
    addRequestParameter("newStatusId", "14");
    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 cancel,so flag should be null.", SessionUtils.getAttribute(SavingsConstants.FLAG_NAME, request.getSession()));
    setRequestPathInfo("/editCustomerStatusAction.do");
    addRequestParameter("method", Methods.updateStatus.toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.center_detail_page.toString());
    center = TestObjectFactory.getCustomer(center.getCustomerId());
    Assert.assertFalse(center.isActive());
}
Also used : MeetingBO(org.mifos.application.meeting.business.MeetingBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 25 with AccountStateEntity

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

the class CheckListServiceFacadeWebTier method updateAccountChecklist.

@Override
public void updateAccountChecklist(Short checklistId, Short productId, Short stateId, Short checklistStatus, String checklistName, List<String> checklistDetails) {
    MifosUser user = (MifosUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
    UserContext userContext = new UserContextFactory().create(user);
    try {
        ProductTypeEntity productTypeEntity = null;
        for (ProductTypeEntity prdTypeEntity : new ProductCategoryBusinessService().getProductTypes()) {
            if (productId.equals(prdTypeEntity.getProductTypeID())) {
                productTypeEntity = prdTypeEntity;
                break;
            }
        }
        hibernateTransactionHelper.startTransaction();
        AccountStateEntity accountStateEntity = new AccountStateEntity(AccountState.fromShort(stateId));
        AccountCheckListBO accountCheckList = (AccountCheckListBO) new CheckListPersistence().getCheckList(checklistId);
        accountCheckList.update(productTypeEntity, accountStateEntity, checklistName, checklistStatus, checklistDetails, userContext.getLocaleId(), userContext.getId());
        customerDao.save(accountCheckList);
        hibernateTransactionHelper.commitTransaction();
    } catch (ServiceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } catch (CheckListException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new BusinessRuleException(e.getKey(), e);
    } catch (PersistenceException e) {
        hibernateTransactionHelper.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        hibernateTransactionHelper.closeSession();
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) MifosUser(org.mifos.security.MifosUser) UserContextFactory(org.mifos.accounts.servicefacade.UserContextFactory) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) ProductCategoryBusinessService(org.mifos.accounts.productdefinition.business.service.ProductCategoryBusinessService) BusinessRuleException(org.mifos.service.BusinessRuleException) ServiceException(org.mifos.framework.exceptions.ServiceException) CheckListPersistence(org.mifos.customers.checklist.persistence.CheckListPersistence) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) CheckListException(org.mifos.customers.checklist.exceptions.CheckListException) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

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