Search in sources :

Example 36 with AccountStateEntity

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

the class SavingsScheduleTest method whenASavingsScheduleForAnActiveSavingsAccountIsCreatedDepositEqualsTheAccountRecommendedAmount.

@Test
public void whenASavingsScheduleForAnActiveSavingsAccountIsCreatedDepositEqualsTheAccountRecommendedAmount() {
    AccountStateEntity savingsAccountState = new AccountStateEntity(AccountState.SAVINGS_ACTIVE);
    // stubbing
    when(savingsAccount.getAccountState()).thenReturn(savingsAccountState);
    // exercise
    savingsSchedule = new SavingsScheduleBuilder().withInstallmentNumber(1).withAccount(savingsAccount).withCustomer(payingCustomer).withDepositDue(recommendedAmount).build();
    // verification
    assertThat(savingsSchedule.getDeposit(), is(recommendedAmount));
}
Also used : SavingsScheduleBuilder(org.mifos.domain.builders.SavingsScheduleBuilder) AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) Test(org.junit.Test)

Example 37 with AccountStateEntity

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

the class SavingsPaymentStrategyForMandatorySavingsAccountsTest method setupMifosLoggerDueToUseOfStaticClientRules.

@BeforeClass
public static void setupMifosLoggerDueToUseOfStaticClientRules() {
    defaultCurrency = TestUtils.RUPEE;
    Money.setDefaultCurrency(defaultCurrency);
    savingsAccountState = new AccountStateEntity(AccountState.SAVINGS_ACTIVE);
}
Also used : AccountStateEntity(org.mifos.accounts.business.AccountStateEntity) BeforeClass(org.junit.BeforeClass)

Example 38 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 39 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 40 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)

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