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