Search in sources :

Example 21 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class GenerateMeetingsForCustomerAndSavingsHelperIntegrationTest method testExecuteForSavingsAccount.

@Test
public void testExecuteForSavingsAccount() throws Exception {
    int configuredValue = GeneralConfig.getOutputIntervalForBatchJobs();
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    int outputInterval = 1;
    try {
        // force output for every account
        configMgr.setProperty(GeneralConfig.OutputIntervalForBatchJobs, outputInterval);
        savings = getSavingsAccountForCenter();
        int noOfInstallments = savings.getAccountActionDates().size();
        AccountTestUtils.changeInstallmentDatesToPreviousDate(savings);
        StaticHibernateUtil.flushSession();
        savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
        new GenerateMeetingsForCustomerAndSavingsTask().getTaskHelper().execute(System.currentTimeMillis());
        savings = TestObjectFactory.getObject(SavingsBO.class, savings.getAccountId());
        Assert.assertEquals(noOfInstallments + 20, savings.getAccountActionDates().size());
    } finally {
        // restore original output interval value
        configMgr.setProperty(GeneralConfig.OutputIntervalForBatchJobs, configuredValue);
    }
}
Also used : SavingsBO(org.mifos.accounts.savings.business.SavingsBO) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

Example 22 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class GeneralConfigTest method testGetOutputIntervalForBatchJobs.

public void testGetOutputIntervalForBatchJobs() {
    int configuredValue = GeneralConfig.getOutputIntervalForBatchJobs();
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    int currentValue = 500;
    configMgr.setProperty(GeneralConfig.OutputIntervalForBatchJobs, currentValue);
    Assert.assertEquals(currentValue, GeneralConfig.getOutputIntervalForBatchJobs());
    configMgr.clearProperty(GeneralConfig.OutputIntervalForBatchJobs);
    int defaultValue = GeneralConfig.getOutputIntervalForBatchJobs();
    int expectedDefaultValue = 1000;
    Assert.assertEquals(defaultValue, expectedDefaultValue);
    // save it back
    configMgr.setProperty(GeneralConfig.OutputIntervalForBatchJobs, configuredValue);
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 23 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class GeneralConfigTest method testGetBatchSizeForBatchJobs.

public void testGetBatchSizeForBatchJobs() {
    int configuredValue = GeneralConfig.getBatchSizeForBatchJobs();
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    int currentValue = 40;
    configMgr.setProperty(GeneralConfig.BatchSizeForBatchJobs, currentValue);
    Assert.assertEquals(currentValue, GeneralConfig.getBatchSizeForBatchJobs());
    // clear the BatchSizeForBatchJobs property from the config file so
    // should get the default value
    configMgr.clearProperty(GeneralConfig.BatchSizeForBatchJobs);
    int defaultValue = GeneralConfig.getBatchSizeForBatchJobs();
    int expectedDefaultValue = 40;
    Assert.assertEquals(defaultValue, expectedDefaultValue);
    // save it back
    configMgr.setProperty(GeneralConfig.BatchSizeForBatchJobs, configuredValue);
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 24 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class GeneralConfigTest method testGetRecordCommittingSizeForBatchJobs.

public void testGetRecordCommittingSizeForBatchJobs() {
    int configuredValue = GeneralConfig.getRecordCommittingSizeForBatchJobs();
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    int currentValue = 500;
    configMgr.setProperty(GeneralConfig.RecordCommittingSizeForBatchJobs, currentValue);
    Assert.assertEquals(currentValue, GeneralConfig.getRecordCommittingSizeForBatchJobs());
    // clear the BatchSizeForBatchJobs property from the config file so
    // should get the default value
    configMgr.clearProperty(GeneralConfig.RecordCommittingSizeForBatchJobs);
    int defaultValue = GeneralConfig.getRecordCommittingSizeForBatchJobs();
    int expectedDefaultValue = 1000;
    Assert.assertEquals(defaultValue, expectedDefaultValue);
    // save it back
    configMgr.setProperty(GeneralConfig.RecordCommittingSizeForBatchJobs, configuredValue);
}
Also used : MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager)

Example 25 with MifosConfigurationManager

use of org.mifos.config.business.MifosConfigurationManager in project head by mifos.

the class AccountingRulesTest method testGetInitialRoundingMode.

@Test
public void testGetInitialRoundingMode() {
    RoundingMode configuredMode = AccountingRules.getInitialRoundingMode();
    String roundingMode = "FLOOR";
    RoundingMode configRoundingMode = RoundingMode.FLOOR;
    MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance();
    configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, roundingMode);
    // return value from accounting rules class has to be the value defined
    // in the config file
    assertEquals(configRoundingMode, AccountingRules.getInitialRoundingMode());
    // clear the RoundingRule property from the config file
    configMgr.clearProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE);
    RoundingMode defaultValue = AccountingRules.getInitialRoundingMode();
    assertEquals(defaultValue, RoundingMode.HALF_UP);
    // now set a wrong rounding mode in config
    roundingMode = "UP";
    configMgr.addProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, roundingMode);
    try {
        AccountingRules.getInitialRoundingMode();
        fail();
    } catch (RuntimeException e) {
        assertEquals("InitialRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode, e.getMessage());
    }
    // save it back
    configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, configuredMode.toString());
}
Also used : RoundingMode(java.math.RoundingMode) MifosConfigurationManager(org.mifos.config.business.MifosConfigurationManager) Test(org.junit.Test)

Aggregations

MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)66 Test (org.junit.Test)18 ConfigurationException (org.mifos.config.exceptions.ConfigurationException)8 Properties (java.util.Properties)5 MifosRuntimeException (org.mifos.core.MifosRuntimeException)5 PersistenceException (org.mifos.framework.exceptions.PersistenceException)5 ApplicationException (org.mifos.framework.exceptions.ApplicationException)4 RoundingMode (java.math.RoundingMode)3 ConfigurationPersistence (org.mifos.config.persistence.ConfigurationPersistence)3 CustomerAccountBO (org.mifos.customers.business.CustomerAccountBO)3 SystemException (org.mifos.framework.exceptions.SystemException)3 BigDecimal (java.math.BigDecimal)2 Ignore (org.junit.Ignore)2 AccountBO (org.mifos.accounts.business.AccountBO)2 SavingsBO (org.mifos.accounts.savings.business.SavingsBO)2 ConfigurationKeyValue (org.mifos.config.business.ConfigurationKeyValue)2 CurrencyMismatchException (org.mifos.core.CurrencyMismatchException)2 PersonnelBO (org.mifos.customers.personnel.business.PersonnelBO)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1