Search in sources :

Example 46 with AccountStateEntity

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

the class SavingsPersistenceIntegrationTest method testGetAccountStatus.

@Test
public void testGetAccountStatus() throws Exception {
    AccountStateEntity accountState = savingsPersistence.getAccountStatusObject(AccountStates.SAVINGS_ACC_CLOSED);
    Assert.assertNotNull(accountState);
    Assert.assertEquals(accountState.getId().shortValue(), AccountStates.SAVINGS_ACC_CLOSED);
}
Also used : AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 47 with AccountStateEntity

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

the class AccountStateIntegrationTest method testRetrieveAllAccountStateList.

/*
     * Check that the values in the enumerated type AccountState match with the
     * Entity values in terms of ids, state names, and the text that they
     * eventually resolve to.
     */
@Test
public void testRetrieveAllAccountStateList() throws NumberFormatException, PersistenceException {
    List<AccountStateEntity> accountStateEntityList = legacyAccountDao.retrieveAllAccountStateList(ProductType.SAVINGS.getValue());
    Assert.assertNotNull(accountStateEntityList);
    Assert.assertEquals(6, accountStateEntityList.size());
    List<AccountStateEntity> accountStateEntityList2 = legacyAccountDao.retrieveAllAccountStateList(ProductType.LOAN.getValue());
    Assert.assertNotNull(accountStateEntityList2);
    Assert.assertEquals(12, accountStateEntityList2.size());
    accountStateEntityList.addAll(accountStateEntityList2);
    // order by id
    Collections.sort(accountStateEntityList, new Comparator<AccountStateEntity>() {

        @Override
        public int compare(AccountStateEntity state1, AccountStateEntity state2) {
            return state1.getId().compareTo(state2.getId());
        }
    });
    Assert.assertEquals(AccountState.values().length, accountStateEntityList.size());
    Iterator<AccountStateEntity> stateListIterator = accountStateEntityList.iterator();
    for (AccountState state : AccountState.values()) {
        AccountStateEntity stateInDatabase = stateListIterator.next();
        Assert.assertEquals(state.getValue(), stateInDatabase.getId());
        Assert.assertEquals(state.getPropertiesKey(), stateInDatabase.getLookUpValue().getLookUpName());
        Assert.assertEquals(ApplicationContextProvider.getBean(MessageLookup.class).lookup(state), ApplicationContextProvider.getBean(MessageLookup.class).lookup(stateInDatabase));
    }
}
Also used : AccountState(org.mifos.accounts.util.helpers.AccountState) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 48 with AccountStateEntity

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

the class SavingsBOIntegrationTest method testSuccessfulFlagSave.

@Test
public void testSuccessfulFlagSave() throws Exception {
    Session session = StaticHibernateUtil.getSessionTL();
    StaticHibernateUtil.startTransaction();
    createInitialObjects();
    savingsOffering = helper.createSavingsOffering("dfasdasd1", "sad1");
    savings = helper.createSavingsAccount("000X00000000013", savingsOffering, group, AccountStates.SAVINGS_ACC_APPROVED, userContext);
    savings.setUserContext(TestObjectFactory.getContext());
    PersonnelBO loggedInUser = IntegrationTestObjectMother.testUser();
    savings.changeStatus(AccountState.SAVINGS_CANCELLED, null, "", loggedInUser);
    savings.setUserContext(this.userContext);
    AccountStateEntity state = (AccountStateEntity) session.get(AccountStateEntity.class, (short) 15);
    for (AccountStateFlagEntity flag : state.getFlagSet()) {
        AccountTestUtils.addAccountFlag(flag, savings);
    }
    savings.update();
    session = StaticHibernateUtil.getSessionTL();
    SavingsBO savingsNew = (SavingsBO) (session.get(SavingsBO.class, Integer.valueOf(savings.getAccountId())));
    Assert.assertEquals(savingsNew.getAccountFlags().size(), 3);
    session.evict(savingsNew);
}
Also used : AccountStateFlagEntity(org.mifos.accounts.business.AccountStateFlagEntity) PersonnelBO(org.mifos.customers.personnel.business.PersonnelBO) SavingsBO(org.mifos.accounts.savings.business.SavingsBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Session(org.hibernate.Session) Test(org.junit.Test)

Example 49 with AccountStateEntity

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

the class IntegrationTestObjectMother method createAccountChecklist.

public static AccountCheckListBO createAccountChecklist(Short prdTypeId, AccountState accountState, Short checklistStatus, List<String> details) {
    try {
        StaticHibernateUtil.startTransaction();
        ProductTypeEntity productTypeEntity = (ProductTypeEntity) StaticHibernateUtil.getSessionTL().get(ProductTypeEntity.class, prdTypeId);
        AccountStateEntity accountStateEntity = new AccountStateEntity(accountState);
        AccountCheckListBO accountChecklist = new AccountCheckListBO(productTypeEntity, accountStateEntity, "productchecklist", checklistStatus, details, Short.valueOf("1"), PersonnelConstants.SYSTEM_USER);
        customerDao.save(accountChecklist);
        StaticHibernateUtil.commitTransaction();
        return accountChecklist;
    } catch (Exception e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new RuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : MifosRuntimeException(org.mifos.core.MifosRuntimeException) AccountCheckListBO(org.mifos.customers.checklist.business.AccountCheckListBO) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) CustomerException(org.mifos.customers.exceptions.CustomerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) PersistenceException(org.mifos.framework.exceptions.PersistenceException) AccountException(org.mifos.accounts.exceptions.AccountException) ProductTypeEntity(org.mifos.accounts.productdefinition.business.ProductTypeEntity)

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