/**
* Test string aggregation.
*/
public void testStringAggregation() {
ValueAggregator aggregator = new ValueAggregator(ValueType.TEXT);
aggregator.aggregate(new TextValue("a"));
aggregator.aggregate(new TextValue("b"));
try {
aggregator.getValue(AggregationType.SUM);
fail();
}
catch(UnsupportedOperationException e) {
// Expected behavior.
}
try {
aggregator.getValue(AggregationType.AVG);
fail();
}
catch(UnsupportedOperationException e) {
// Expected behavior.
}
assertEquals(new NumberValue(2), aggregator.getValue(AggregationType.COUNT));
assertEquals(new TextValue("a"), aggregator.getValue(AggregationType.MIN));
assertEquals(new TextValue("b"), aggregator.getValue(AggregationType.MAX));
}