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;
}
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();
}
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);
}
}
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) {
}
}
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);
}
Aggregations