use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.
the class QueryContentHandlerTest method testMinAggregation.
@Test
public void testMinAggregation() {
final SingleValueMetricAggregation minAgg = SingleValueMetricAggregation.create("minPrice").value(10.0).build();
setUpForMetricsAggregations(minAgg);
runFunction("/test/QueryContentHandlerTest_MinAggregation.js", "queryWithAggregations");
}
use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.
the class ValueCountAggregationTest method verifyValueCount.
private void verifyValueCount(final Bucket parentBucket, String parentBucketKey, double value) {
assertEquals(parentBucketKey, parentBucket.getKey(), "Wrong parent bucket key");
assertEquals(1, parentBucket.getSubAggregations().getSize());
final Aggregation subAgg = parentBucket.getSubAggregations().get("subquery");
assertTrue(subAgg instanceof SingleValueMetricAggregation);
final SingleValueMetricAggregation stats = (SingleValueMetricAggregation) subAgg;
assertEquals(value, stats.getValue(), 0);
}
use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.
the class AggregationMapper method serializeAggregations.
private static void serializeAggregations(final MapGenerator gen, final Aggregations value) {
for (Aggregation aggregation : value) {
gen.map(aggregation.getName());
if (aggregation instanceof BucketAggregation) {
final Buckets buckets = ((BucketAggregation) aggregation).getBuckets();
serializeBuckets(gen, buckets);
} else if (aggregation instanceof StatsAggregation) {
final StatsAggregation statsAggregation = ((StatsAggregation) aggregation);
serializeStatsAggregation(gen, statsAggregation);
} else if (aggregation instanceof SingleValueMetricAggregation) {
gen.value("value", ((SingleValueMetricAggregation) aggregation).getValue());
}
gen.end();
}
}
use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.
the class QueryContentHandlerTest method testMaxAggregation.
@Test
public void testMaxAggregation() {
final SingleValueMetricAggregation maxAgg = SingleValueMetricAggregation.create("maxPrice").value(50.0).build();
setUpForMetricsAggregations(maxAgg);
runFunction("/test/QueryContentHandlerTest_MaxAggregation.js", "queryWithAggregations");
}
use of com.enonic.xp.aggregation.SingleValueMetricAggregation in project xp by enonic.
the class QueryContentHandlerTest method testValueCountAggregation.
@Test
public void testValueCountAggregation() {
final SingleValueMetricAggregation countAgg = SingleValueMetricAggregation.create("countProductsWithPrice").value(5).build();
setUpForMetricsAggregations(countAgg);
runFunction("/test/QueryContentHandlerTest_ValueCountAggregation.js", "queryWithAggregations");
}
Aggregations