Search in sources :

Example 1 with LegacyAccountDao

use of org.mifos.accounts.persistence.LegacyAccountDao in project head by mifos.

the class ChartOfAccountsCacheTest method createMockAccountPersistance.

private LegacyAccountDao createMockAccountPersistance() {
    LegacyAccountDao ap = createMock(LegacyAccountDao.class);
    expect(ap.getCategory(GLCategoryType.INCOME)).andReturn(new COABO(ACCOUNT_ID, ACCOUNT_NAME));
    replay(ap);
    return ap;
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) COABO(org.mifos.accounts.financial.business.COABO)

Example 2 with LegacyAccountDao

use of org.mifos.accounts.persistence.LegacyAccountDao in project head by mifos.

the class AccountBOTest method testInvalidConnectionThrowsExceptionInUpdate.

@Test(expected = AccountException.class)
public void testInvalidConnectionThrowsExceptionInUpdate() throws Exception {
    final LegacyAccountDao legacyAccountDao = mock(LegacyAccountDao.class);
    AccountBO accountBO = new AccountBO() {

        @Override
        public LegacyAccountDao getlegacyAccountDao() {
            return legacyAccountDao;
        }
    };
    when(legacyAccountDao.createOrUpdate(accountBO)).thenThrow(new PersistenceException("some exception"));
    // exercise test
    accountBO.update();
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test)

Example 3 with LegacyAccountDao

use of org.mifos.accounts.persistence.LegacyAccountDao in project head by mifos.

the class ProcessFlowRules method initLoanPendingApprovalState.

private static void initLoanPendingApprovalState() throws ConfigurationException {
    LegacyAccountDao ap = ApplicationContextProvider.getBean(LegacyAccountDao.class);
    AccountStateEntity ase = ap.loadPersistentObject(AccountStateEntity.class, AccountState.LOAN_PENDING_APPROVAL.getValue());
    boolean fromDb = isLoanPendingApprovalStateEnabledOnDatabaseConfig(ase);
    boolean fromCfg = isLoanPendingApprovalStateEnabled();
    if (databaseAndCustomConfigurationAreNotTheSame(fromDb, fromCfg)) {
        int count = ApplicationContextProvider.getBean(LegacyLoanDao.class).countOfLoanAccounts();
        if (count > 0) {
            String errMsg = getBadOverrideMsg(LOAN_PENDING_APPROVAL, "Records for loans in the 'pending approval' state" + " may already exist.");
            throw new ConfigurationException(errMsg);
        }
        makeDatabaseConfigurationMatchPropertiesFileConfiguration(ap, ase, fromCfg);
    }
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) ConfigurationException(org.mifos.config.exceptions.ConfigurationException) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) LegacyLoanDao(org.mifos.accounts.loan.persistance.LegacyLoanDao)

Example 4 with LegacyAccountDao

use of org.mifos.accounts.persistence.LegacyAccountDao in project head by mifos.

the class LoanBOTest method testInvalidConnectionForSave.

@Test
@ExpectedException(value = AccountException.class)
public void testInvalidConnectionForSave() throws PersistenceException {
    final LegacyAccountDao legacyAccountDao = mock(LegacyAccountDao.class);
    LoanBO loanBO = new LoanBO() {

        @Override
        public LegacyAccountDao getlegacyAccountDao() {
            return legacyAccountDao;
        }
    };
    try {
        when(legacyAccountDao.createOrUpdate(loanBO)).thenThrow(new PersistenceException("some exception"));
        loanBO.update();
        junit.framework.Assert.fail("should fail because of invalid session");
    } catch (AccountException e) {
    }
}
Also used : AccountException(org.mifos.accounts.exceptions.AccountException) LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) PersistenceException(org.mifos.framework.exceptions.PersistenceException) Test(org.junit.Test) ExpectedException(org.springframework.test.annotation.ExpectedException)

Example 5 with LegacyAccountDao

use of org.mifos.accounts.persistence.LegacyAccountDao in project head by mifos.

the class ChartOfAccountsCacheTest method testTopLevelAccountCached.

public void testTopLevelAccountCached() throws Exception {
    LegacyAccountDao ap = createMockAccountPersistance();
    COABO income = ap.getCategory(GLCategoryType.INCOME);
    COABO cachedIncome = ChartOfAccountsCache.get(INCOME_GL_ACCOUNT_CODE);
    Assert.assertEquals(income, cachedIncome);
}
Also used : LegacyAccountDao(org.mifos.accounts.persistence.LegacyAccountDao) COABO(org.mifos.accounts.financial.business.COABO)

Aggregations

LegacyAccountDao (org.mifos.accounts.persistence.LegacyAccountDao)9 AccountStateEntity (org.mifos.accounts.business.AccountStateEntity)3 COABO (org.mifos.accounts.financial.business.COABO)3 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)3 Test (org.junit.Test)2 LegacyLoanDao (org.mifos.accounts.loan.persistance.LegacyLoanDao)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Session (org.hibernate.Session)1 AccountException (org.mifos.accounts.exceptions.AccountException)1 FinancialException (org.mifos.accounts.financial.exceptions.FinancialException)1 LoanBO (org.mifos.accounts.loan.business.LoanBO)1 LoanPrdPersistence (org.mifos.accounts.productdefinition.persistence.LoanPrdPersistence)1 ChartOfAccountsConfig (org.mifos.config.ChartOfAccountsConfig)1 GLAccount (org.mifos.config.GLAccount)1 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)1 CustomerStatusEntity (org.mifos.customers.business.CustomerStatusEntity)1 CustomerDao (org.mifos.customers.persistence.CustomerDao)1 BatchJobException (org.mifos.framework.components.batchjobs.exceptions.BatchJobException)1