[Tests] Add test for GeoShapeFieldType#setStrategyName (#27703)

This commit is contained in:
Christoph Büscher 2017-12-08 10:11:57 +01:00 committed by GitHub
parent 6efee323e0
commit 816878bd4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 2 deletions

View File

@ -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());
}
}