From 816878bd4d6f416751ba9d15f3ea869ca7efd598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= <10398885+cbuescher@users.noreply.github.com> Date: Fri, 8 Dec 2017 10:11:57 +0100 Subject: [PATCH] [Tests] Add test for GeoShapeFieldType#setStrategyName (#27703) --- .../index/mapper/GeoShapeFieldTypeTests.java | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldTypeTests.java b/core/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldTypeTests.java index 41ae4bdfbe4..a1c225f8a06 100644 --- a/core/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldTypeTests.java +++ b/core/src/test/java/org/elasticsearch/index/mapper/GeoShapeFieldTypeTests.java @@ -18,11 +18,13 @@ */ package org.elasticsearch.index.mapper; +import org.elasticsearch.common.geo.SpatialStrategy; import org.elasticsearch.common.geo.builders.ShapeBuilder; -import org.elasticsearch.index.mapper.GeoShapeFieldMapper; -import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.GeoShapeFieldMapper.GeoShapeFieldType; import org.junit.Before; +import java.io.IOException; + public class GeoShapeFieldTypeTests extends FieldTypeTestCase { @Override protected MappedFieldType createDefaultFieldType() { @@ -68,4 +70,17 @@ public class GeoShapeFieldTypeTests extends FieldTypeTestCase { } }); } + + /** + * Test for {@link GeoShapeFieldType#setStrategyName(String)} that checks that {@link GeoShapeFieldType#pointsOnly()} + * gets set as a side effect when using SpatialStrategy.TERM + */ + public void testSetStrategyName() throws IOException { + GeoShapeFieldType fieldType = new GeoShapeFieldMapper.GeoShapeFieldType(); + assertFalse(fieldType.pointsOnly()); + fieldType.setStrategyName(SpatialStrategy.RECURSIVE.getStrategyName()); + assertFalse(fieldType.pointsOnly()); + fieldType.setStrategyName(SpatialStrategy.TERM.getStrategyName()); + assertTrue(fieldType.pointsOnly()); + } }