List of usage examples for java.math RoundingMode toString
public String toString()
From source file:org.mifos.accounts.loan.business.LoanCalculationIntegrationTest.java
private void setInitialRoundingMode(RoundingMode mode) { MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance(); configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, mode.toString()); }
From source file:org.mifos.accounts.loan.business.LoanCalculationIntegrationTest.java
private void setFinalRoundingMode(RoundingMode mode) { MifosConfigurationManager configMgr = MifosConfigurationManager.getInstance(); configMgr.setProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, mode.toString()); }
From source file:org.mifos.config.AccountingRulesIntegrationTest.java
@Test public void testGetCurrencyRoundingMode() { RoundingMode configuredMode = AccountingRules.getCurrencyRoundingMode(); String roundingMode = "FLOOR"; RoundingMode configRoundingMode = RoundingMode.FLOOR; ConfigurationManager configMgr = ConfigurationManager.getInstance(); configMgr.setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, roundingMode); // return value from accounting rules class has to be the value defined // in the config file Assert.assertEquals(configRoundingMode, AccountingRules.getCurrencyRoundingMode()); // clear the RoundingRule property from the config file so should get // the default value configMgr.clearProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE); RoundingMode defaultValue = AccountingRules.getCurrencyRoundingMode(); Assert.assertEquals(defaultValue, RoundingMode.HALF_UP); // now set a wrong rounding mode in config roundingMode = "UP"; configMgr.addProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, roundingMode); try {/*from w w w. j av a 2 s . c om*/ AccountingRules.getCurrencyRoundingMode(); } catch (RuntimeException e) { Assert.assertEquals(e.getMessage(), "CurrencyRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode); } // save it back configMgr.setProperty(AccountingRulesConstants.CURRENCY_ROUNDING_MODE, configuredMode.toString()); }
From source file:org.mifos.config.AccountingRulesIntegrationTest.java
@Test public void testGetInitialRoundingMode() { RoundingMode configuredMode = AccountingRules.getInitialRoundingMode(); String roundingMode = "FLOOR"; RoundingMode configRoundingMode = RoundingMode.FLOOR; ConfigurationManager configMgr = ConfigurationManager.getInstance(); configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, roundingMode); // return value from accounting rules class has to be the value defined // in the config file Assert.assertEquals(configRoundingMode, AccountingRules.getInitialRoundingMode()); // clear the RoundingRule property from the config file configMgr.clearProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE); RoundingMode defaultValue = AccountingRules.getInitialRoundingMode(); Assert.assertEquals(defaultValue, RoundingMode.HALF_UP); // now set a wrong rounding mode in config roundingMode = "UP"; configMgr.addProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, roundingMode); try {/*from w ww .j a va2 s. c o m*/ AccountingRules.getInitialRoundingMode(); } catch (RuntimeException e) { Assert.assertEquals(e.getMessage(), "InitialRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode); } // save it back configMgr.setProperty(AccountingRulesConstants.INITIAL_ROUNDING_MODE, configuredMode.toString()); }
From source file:org.mifos.config.AccountingRulesIntegrationTest.java
@Test public void testGetFinalRoundingMode() { RoundingMode configuredMode = AccountingRules.getFinalRoundingMode(); String roundingMode = "CEILING"; RoundingMode configRoundingMode = RoundingMode.CEILING; ConfigurationManager configMgr = ConfigurationManager.getInstance(); configMgr.setProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, roundingMode); // return value from accounting rules class has to be the value defined // in the config file Assert.assertEquals(configRoundingMode, AccountingRules.getFinalRoundingMode()); // clear the RoundingRule property from the config file configMgr.clearProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE); RoundingMode defaultValue = AccountingRules.getFinalRoundingMode(); Assert.assertEquals(defaultValue, RoundingMode.CEILING); // now set a wrong rounding mode in config roundingMode = "DOWN"; configMgr.addProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, roundingMode); try {// w w w. ja va 2 s . co m AccountingRules.getFinalRoundingMode(); } catch (RuntimeException e) { Assert.assertEquals(e.getMessage(), "FinalRoundingMode defined in the config file is not CEILING, FLOOR, HALF_UP. It is " + roundingMode); } // save it back configMgr.setProperty(AccountingRulesConstants.FINAL_ROUNDING_MODE, configuredMode.toString()); }