[TEST] fixes mutate methods in aggs tests

Closes #26121
This commit is contained in:
Colin Goodheart-Smithe 2017-08-10 07:05:46 +01:00
parent 566992d2a1
commit 20b7258d41
No known key found for this signature in database
GPG Key ID: F975E7BDD739B3C7
2 changed files with 16 additions and 6 deletions

View File

@ -95,8 +95,17 @@ public class InternalGeoCentroidTests extends InternalAggregationTestCase<Intern
break;
case 1:
count += between(1, 100);
if (centroid == null) {
// if the new count is > 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:
if (centroid == null) {
centroid = new GeoPoint(randomDoubleBetween(-90, 90, false), randomDoubleBetween(-180, 180, false));
count = between(1, 100);
} else {
GeoPoint newCentroid = new GeoPoint(centroid);
if (randomBoolean()) {
newCentroid.resetLat(centroid.getLat() / 2.0);
@ -104,6 +113,7 @@ public class InternalGeoCentroidTests extends InternalAggregationTestCase<Intern
newCentroid.resetLon(centroid.getLon() / 2.0);
}
centroid = newCentroid;
}
break;
case 3:
if (metaData == null) {

View File

@ -206,7 +206,7 @@ public class InternalScriptedMetricTests extends InternalAggregationTestCase<Int
break;
case 1:
Object newValue = randomValue(valueTypes, 0);
while ((newValue == null && value == null) || newValue.equals(value)) {
while ((newValue == null && value == null) || (newValue != null && newValue.equals(value))) {
int levels = randomIntBetween(1, 3);
Supplier[] valueTypes = new Supplier[levels];
for (int i = 0; i < levels; i++) {