Search in sources :

Example 71 with BigDecimal

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

the class MultiMapMaxAggregationTest method testComparableMax.

@Test
public void testComparableMax() 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++) {
        BigDecimal value = values[i];
        expectation = i == 0 ? value : expectation.max(value);
    }
    Aggregation<String, Comparable, Comparable> aggregation = Aggregations.comparableMax();
    Comparable result = testMax(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 72 with BigDecimal

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

the class MultiMapMaxAggregationTest method testBigDecimalMax.

@Test
public void testBigDecimalMax() 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++) {
        BigDecimal value = values[i];
        expectation = i == 0 ? value : expectation.max(value);
    }
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalMax();
    BigDecimal result = testMax(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 73 with BigDecimal

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

the class MultiMapMinAggregationTest method testBigDecimalMin.

@Test
public void testBigDecimalMin() 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++) {
        BigDecimal value = values[i];
        expectation = i == 0 ? value : expectation.min(value);
    }
    Aggregation<String, BigDecimal, BigDecimal> aggregation = Aggregations.bigDecimalMin();
    BigDecimal result = testMin(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 74 with BigDecimal

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

the class MultiMapMinAggregationTest 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 75 with BigDecimal

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

the class MultiMapSumAggregationTest 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)

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