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