|
|
@@ -29,6 +29,8 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import static org.hamcrest.Matchers.equalTo;
|
|
|
+
|
|
|
public class InternalGeoCentroidTests extends InternalAggregationTestCase<InternalGeoCentroid> {
|
|
|
|
|
|
@Override
|
|
|
@@ -52,7 +54,7 @@ public class InternalGeoCentroidTests extends InternalAggregationTestCase<Intern
|
|
|
protected void assertReduced(InternalGeoCentroid reduced, List<InternalGeoCentroid> inputs) {
|
|
|
double lonSum = 0;
|
|
|
double latSum = 0;
|
|
|
- int totalCount = 0;
|
|
|
+ long totalCount = 0;
|
|
|
for (InternalGeoCentroid input : inputs) {
|
|
|
if (input.count() > 0) {
|
|
|
lonSum += (input.count() * input.centroid().getLon());
|
|
|
@@ -67,6 +69,14 @@ public class InternalGeoCentroidTests extends InternalAggregationTestCase<Intern
|
|
|
assertEquals(totalCount, reduced.count());
|
|
|
}
|
|
|
|
|
|
+ public void testReduceMaxCount() {
|
|
|
+ InternalGeoCentroid maxValueGeoCentroid = new InternalGeoCentroid("agg", new GeoPoint(10, 0),
|
|
|
+ Long.MAX_VALUE, Collections.emptyMap());
|
|
|
+ InternalGeoCentroid reducedGeoCentroid = maxValueGeoCentroid
|
|
|
+ .reduce(Collections.singletonList(maxValueGeoCentroid), null);
|
|
|
+ assertThat(reducedGeoCentroid.count(), equalTo(Long.MAX_VALUE));
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
protected void assertFromXContent(InternalGeoCentroid aggregation, ParsedAggregation parsedAggregation) {
|
|
|
assertTrue(parsedAggregation instanceof ParsedGeoCentroid);
|