List of usage examples for java.math BigDecimal BigDecimal
public BigDecimal(long val)
From source file:io.restassured.itest.java.BigDecimalITest.java
@Test public void big_decimal_works() { when().get("/amount").then().body("amount", equalTo(new BigDecimal("250.00"))); }
From source file:com.arya.latihan.controller.ItemControllerTest.java
@Test public void testSave() { Item item = new Item(); item.setName("Biskuit Cokelat"); item.setPrice(new BigDecimal("5000")); item.setCost(new BigDecimal("4500")); item.setStock(new BigDecimal("25")); item.setExpiredDate(new DateTime(2017, 02, 10, 0, 0)); RestAssured.given().auth().basic(username, password).contentType("application/json").body(item).log() .everything().when().post(url).then().statusCode(201).log().everything() .header("Location", Matchers.containsString(url)); }
From source file:cherry.foundation.type.converter.SecureBigDecimalConverterTest.java
@Test public void testConvert() { for (int i = 0; i < 100; i++) { BigDecimal plain = new BigDecimal(random.nextDouble()); String crypto = SecureBigDecimal.plainValueOf(plain).crypto(); assertThat(cs.convert(crypto, SecureBigDecimal.class).plain(), is(plain)); }/*from ww w .ja v a2 s .c om*/ }
From source file:net.groupbuy.template.method.CurrencyMethod.java
@SuppressWarnings("rawtypes") public Object exec(List arguments) throws TemplateModelException { if (arguments != null && !arguments.isEmpty() && arguments.get(0) != null && StringUtils.isNotEmpty(arguments.get(0).toString())) { boolean showSign = false; boolean showUnit = false; if (arguments.size() == 2) { if (arguments.get(1) != null) { showSign = Boolean.valueOf(arguments.get(1).toString()); }// w w w . j av a 2 s .co m } else if (arguments.size() > 2) { if (arguments.get(1) != null) { showSign = Boolean.valueOf(arguments.get(1).toString()); } if (arguments.get(2) != null) { showUnit = Boolean.valueOf(arguments.get(2).toString()); } } Setting setting = SettingUtils.get(); BigDecimal amount = new BigDecimal(arguments.get(0).toString()); String price = setting.setScale(amount).toString(); if (showSign) { price = setting.getCurrencySign() + price; } if (showUnit) { price += setting.getCurrencyUnit(); } return new SimpleScalar(price); } return null; }
From source file:com.benfante.minimark.blo.ResultCalculationBo.java
/** * Calculate the evaluation of an assessment. Moreover it stores the result * in the assessment filling and sets the evaluated flag. * * @param assessment The assessment to evaluate. * @return The evaluation/*w w w.j ava 2s.c om*/ */ public BigDecimal calculate(AssessmentFilling assessment) { BigDecimal result = new BigDecimal("0.00"); final Assessment assessmentDef = assessment.getAssessment(); evaluateAllQuestions(assessment, assessmentDef.getEvaluationClosedMinimumEvaluation()); String evaluationType = assessmentDef.getEvaluationType(); if (evaluationType == null || Assessment.EVALUATION_SIMPLE_SUM.equals(evaluationType)) { result = calculateSimpleSum(assessment); } else if (Assessment.EVALUATION_NORMALIZED_SUM.equals(evaluationType)) { result = calculateNormalizedSum(assessment, assessmentDef.getEvaluationMaxValue()); } assessment.setEvaluationResult(result); assessment.setEvaluated(Boolean.TRUE); return result; }
From source file:org.impotch.calcul.impot.cantonal.ge.pp.BaremeFortune2011Test.java
@Test public void baremeSource() { Bareme bareme = fournisseur.getBaremeFortune(2011); assertEquals("Pour 1000000 francs", new BigDecimal("2994.50"), bareme.calcul(new BigDecimal("1000000"))); bareme = fournisseur.getBaremeFortuneSupplementaire(2011); assertEquals("Pour 1000000 francs", new BigDecimal("310.70"), bareme.calcul(new BigDecimal("1000000"))); }
From source file:org.impotch.calcul.impot.cantonal.ge.pp.BaremeRevenu2011Test.java
@Test public void baremeSource() { Bareme bareme = fournisseur.getBaremeRevenu(2011); assertEquals("Pour 17753 francs", new BigDecimal("9.90"), bareme.calcul(new BigDecimal("17753"))); assertEquals("Pour 17700 francs", new BigDecimal("5.70"), bareme.calcul(new BigDecimal("17700"))); assertEquals("Pour 17629 francs", new BigDecimal("0.00"), bareme.calcul(new BigDecimal("17629"))); assertEquals("Pour 17630 francs", new BigDecimal("0.10"), bareme.calcul(new BigDecimal("17630"))); }
From source file:com.startup.musicstore.test.repository.CreditCardRepositoryTest.java
@Test(enabled = true) public void createCreditCard() { // *** (i) Create The Entity //Get The Repository Object creditCardRepository = ctx.getBean(CreditCardRepository.class); //Create the Credit card Object using the Builder Design Pattern with ID. It will be generated // USE BUILDER PATTERN FOR CREATING ALL YOUR ENTITIES CreditCard creditCard = new CreditCard.Builder("5555-555-555-55555").balance(new BigDecimal(200.00)) .expiryDate(new Date()).nameOnCreditCard("John Dole").build(); //SAVE THE CREDIT CARD OBJECT creditCardRepository.save(creditCard); // STORE THE ID FOR LATER USE id = creditCard.getId();//from ww w .j a v a 2 s .co m // ASSERT THAT THE OBJECT IS SAVED Assert.assertNotNull(creditCard); }
From source file:org.impotch.calcul.impot.cantonal.ge.pp.BaremeRevenu2010Test.java
@Test public void baremeSource() { Bareme bareme = fournisseur.getBaremeRevenu(2010); assertEquals("Pour 17753 francs", new BigDecimal("18.10"), bareme.calcul(new BigDecimal("17753"))); }
From source file:be.ceau.chart.datapoint.ScatterDataPoint.java
public ScatterDataPoint setX(double x) { this.x = new BigDecimal(String.valueOf(x)); return this; }