AggregationExpression extends EvaluationExpression { @Override public IJsonNode evaluate(final IJsonNode nodes, final IJsonNode target, final EvaluationContext context) { this.aggregator = this.function.initialize(this.aggregator); for (final IJsonNode node : (IArrayNode) nodes) this.aggregator = this.function.aggregate(this.preprocessing.evaluate(node, context), this.aggregator, context); return this.function.getFinalAggregate(this.aggregator, target); } AggregationExpression(final Aggregation<?, ?> function); @SuppressWarnings("unchecked")  AggregationExpression(final Aggregation<?, ?> function, final EvaluationExpression preprocessing); @Override IJsonNode evaluate(final IJsonNode nodes, final IJsonNode target, final EvaluationContext context); @SuppressWarnings("unchecked") @Override EvaluationExpression transformRecursively(final TransformFunction function); Aggregation<IJsonNode, IJsonNode> getFunction(); EvaluationExpression getPreprocessing(); @Override int hashCode(); @Override boolean equals(final Object obj); @Override void toString(final StringBuilder builder);  }
@Test public void shouldAggregate() { final IJsonNode result = new AggregationExpression(CoreFunctions.AVERAGE).evaluate(createArrayNode(2, 4), null, this.context); Assert.assertTrue(result instanceof INumericNode); Assert.assertEquals(3.0, ((INumericNode) result).getDoubleValue()); }