diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroidTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroidTests.java index d224698257f..c797fcb91db 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroidTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/geocentroid/InternalGeoCentroidTests.java @@ -95,15 +95,25 @@ public class InternalGeoCentroidTests extends InternalAggregationTestCase 0 then we need to make sure there is a + // centroid or the constructor will throw an exception + centroid = new GeoPoint(randomDoubleBetween(-90, 90, false), randomDoubleBetween(-180, 180, false)); + } break; case 2: - GeoPoint newCentroid = new GeoPoint(centroid); - if (randomBoolean()) { - newCentroid.resetLat(centroid.getLat() / 2.0); + if (centroid == null) { + centroid = new GeoPoint(randomDoubleBetween(-90, 90, false), randomDoubleBetween(-180, 180, false)); + count = between(1, 100); } else { - newCentroid.resetLon(centroid.getLon() / 2.0); + GeoPoint newCentroid = new GeoPoint(centroid); + if (randomBoolean()) { + newCentroid.resetLat(centroid.getLat() / 2.0); + } else { + newCentroid.resetLon(centroid.getLon() / 2.0); + } + centroid = newCentroid; } - centroid = newCentroid; break; case 3: if (metaData == null) { diff --git a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java index a4ad60b87a8..584208af417 100644 --- a/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java +++ b/core/src/test/java/org/elasticsearch/search/aggregations/metrics/scripted/InternalScriptedMetricTests.java @@ -206,7 +206,7 @@ public class InternalScriptedMetricTests extends InternalAggregationTestCase