diff --git a/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java index 9834ea1a1c3..a36d00eece0 100644 --- a/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/GeoPolygonQueryBuilderTests.java @@ -51,7 +51,7 @@ import static org.hamcrest.Matchers.equalTo; public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase { @Override protected GeoPolygonQueryBuilder doCreateTestQueryBuilder() { - List polygon = randomPolygon(randomIntBetween(4, 50)); + List polygon = randomPolygon(); GeoPolygonQueryBuilder builder = new GeoPolygonQueryBuilder(GEO_POINT_FIELD_NAME, polygon); if (randomBoolean()) { builder.setValidationMethod(randomFrom(GeoValidationMethod.values())); @@ -125,7 +125,7 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase randomPolygon(int numPoints) { + private static List randomPolygon() { ShapeBuilder shapeBuilder = null; // This is a temporary fix because sometimes the RandomShapeGenerator // returns null. This is if there is an error generating the polygon. So @@ -143,7 +143,7 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase new GeoPolygonQueryBuilder(null, randomPolygon(5))); + IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> new GeoPolygonQueryBuilder(null, randomPolygon())); assertEquals("fieldName must not be null", e.getMessage()); } @@ -370,7 +370,7 @@ public class GeoPolygonQueryBuilderTests extends AbstractQueryTestCase polygon = randomPolygon(randomIntBetween(4, 50)); + List polygon = randomPolygon(); final GeoPolygonQueryBuilder queryBuilder = new GeoPolygonQueryBuilder("unmapped", polygon); queryBuilder.ignoreUnmapped(true); Query query = queryBuilder.toQuery(createShardContext());