Search in sources :

Example 76 with BigDecimal

use of java.math.BigDecimal in project hazelcast by hazelcast.

the class MapMinAggregationTest method testBigDecimalMinWithExtractor.

@Test
public void testBigDecimalMinWithExtractor() throws Exception {
    Value<BigDecimal>[] values = buildValues(new ValueProvider<BigDecimal>() {

        @Override
        public BigDecimal provideRandom(Random random) {
            return BigDecimal.valueOf(10000.0D + random(1000, 2000));
        }
    });
    BigDecimal expectation = BigDecimal.ZERO;
    for (int i = 0; i < values.length; i++) {
        Value<BigDecimal> value = values[i];
        expectation = i == 0 ? value.value : expectation.min(value.value);
    }
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalMin();
    BigDecimal result = testMinWithExtractor(values, aggregation);
    assertEquals(expectation, result);
}
Also used : Random(java.util.Random) BigDecimal(java.math.BigDecimal) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 77 with BigDecimal

use of java.math.BigDecimal in project hazelcast by hazelcast.

the class MapSumAggregationTest method testBigDecimalSumWithExtractor.

@Test
public void testBigDecimalSumWithExtractor() throws Exception {
    Value<BigDecimal>[] values = buildValues(new ValueProvider<BigDecimal>() {

        @Override
        public BigDecimal provideRandom(Random random) {
            return BigDecimal.valueOf(10000.0D + random(1000, 2000));
        }
    });
    BigDecimal expectation = BigDecimal.ZERO;
    for (int i = 0; i < values.length; i++) {
        expectation = expectation.add(values[i].value);
    }
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalSum();
    BigDecimal result = testSumWithExtractor(values, aggregation);
    assertEquals(expectation, result);
}
Also used : Random(java.util.Random) BigDecimal(java.math.BigDecimal) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 78 with BigDecimal

use of java.math.BigDecimal in project hazelcast by hazelcast.

the class MapSumAggregationTest method testBigDecimalSum.

@Test
public void testBigDecimalSum() throws Exception {
    BigDecimal[] values = buildPlainValues(new ValueProvider<BigDecimal>() {

        @Override
        public BigDecimal provideRandom(Random random) {
            return BigDecimal.valueOf(10000.0D + random(1000, 2000));
        }
    }, BigDecimal.class);
    BigDecimal expectation = BigDecimal.ZERO;
    for (int i = 0; i < values.length; i++) {
        expectation = expectation.add(values[i]);
    }
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalSum();
    BigDecimal result = testSum(values, aggregation);
    assertEquals(expectation, result);
}
Also used : Random(java.util.Random) BigDecimal(java.math.BigDecimal) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 79 with BigDecimal

use of java.math.BigDecimal in project hazelcast by hazelcast.

the class MultiMapAvgAggregationTest method testBigDecimalAvg.

@Test
public void testBigDecimalAvg() throws Exception {
    BigDecimal[] values = buildPlainValues(new ValueProvider<BigDecimal>() {

        @Override
        public BigDecimal provideRandom(Random random) {
            return BigDecimal.valueOf(10000.0D + random(1000, 2000));
        }
    }, BigDecimal.class);
    BigDecimal expectation = BigDecimal.ZERO;
    for (int i = 0; i < values.length; i++) {
        expectation = expectation.add(values[i]);
    }
    expectation = expectation.divide(BigDecimal.valueOf(values.length));
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalAvg();
    BigDecimal result = testAvg(values, aggregation);
    assertEquals(expectation, result);
}
Also used : Random(java.util.Random) BigDecimal(java.math.BigDecimal) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 80 with BigDecimal

use of java.math.BigDecimal in project hazelcast by hazelcast.

the class MapAvgAggregationTest method testBigDecimalAvgWithExtractor.

@Test
public void testBigDecimalAvgWithExtractor() throws Exception {
    Value<BigDecimal>[] values = buildValues(new ValueProvider<BigDecimal>() {

        @Override
        public BigDecimal provideRandom(Random random) {
            return BigDecimal.valueOf(10000.0D + random(1000, 2000));
        }
    });
    BigDecimal expectation = BigDecimal.ZERO;
    for (int i = 0; i < values.length; i++) {
        expectation = expectation.add(values[i].value);
    }
    expectation = expectation.divide(BigDecimal.valueOf(values.length));
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalAvg();
    BigDecimal result = testAvgWithExtractor(values, aggregation);
    assertEquals(expectation, result);
}
Also used : Random(java.util.Random) BigDecimal(java.math.BigDecimal) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

BigDecimal (java.math.BigDecimal)5274 Test (org.junit.Test)834 BigInteger (java.math.BigInteger)657 Test (org.testng.annotations.Test)626 LocalDate (org.joda.time.LocalDate)409 ArrayList (java.util.ArrayList)393 ResultSet (java.sql.ResultSet)251 MathContext (java.math.MathContext)220 Timestamp (java.sql.Timestamp)211 PreparedStatement (java.sql.PreparedStatement)207 Date (java.util.Date)175 SQLException (java.sql.SQLException)170 HashMap (java.util.HashMap)157 UUID (java.util.UUID)149 Invoice (org.killbill.billing.invoice.api.Invoice)148 List (java.util.List)136 DateTime (org.joda.time.DateTime)132 RoundingMode (java.math.RoundingMode)129 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)104 Session (org.hibernate.Session)96