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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations