From 11492b896234272d7e38ab1aec0942c063a362f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 15 Jun 2015 11:40:35 +0200 Subject: [PATCH] Tests: fix RangeQueryBuilderTest, only use timestamp when date mapper is available Also renaming field names to 'mapped_' to avoid misunderstandings in error messages. --- .../elasticsearch/index/query/BaseQueryTestCase.java | 12 ++++++------ .../index/query/RangeQueryBuilderTest.java | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/index/query/BaseQueryTestCase.java b/core/src/test/java/org/elasticsearch/index/query/BaseQueryTestCase.java index 8710af2ff4e..98a76af2319 100644 --- a/core/src/test/java/org/elasticsearch/index/query/BaseQueryTestCase.java +++ b/core/src/test/java/org/elasticsearch/index/query/BaseQueryTestCase.java @@ -76,12 +76,12 @@ import static org.hamcrest.Matchers.is; @Ignore public abstract class BaseQueryTestCase> extends ElasticsearchTestCase { - protected static final String OBJECT_FIELD_NAME = "object"; - protected static final String DATE_FIELD_NAME = "age"; - protected static final String INT_FIELD_NAME = "price"; - protected static final String STRING_FIELD_NAME = "text"; - protected static final String DOUBLE_FIELD_NAME = "double"; - protected static final String BOOLEAN_FIELD_NAME = "boolean"; + protected static final String OBJECT_FIELD_NAME = "mapped_object"; + protected static final String DATE_FIELD_NAME = "mapped_date"; + protected static final String INT_FIELD_NAME = "mapped_int"; + protected static final String STRING_FIELD_NAME = "mapped_string"; + protected static final String DOUBLE_FIELD_NAME = "mapped_double"; + protected static final String BOOLEAN_FIELD_NAME = "mapped_boolean"; protected static final String[] mappedFieldNames = new String[] { DATE_FIELD_NAME, INT_FIELD_NAME, STRING_FIELD_NAME, DOUBLE_FIELD_NAME, BOOLEAN_FIELD_NAME, OBJECT_FIELD_NAME }; diff --git a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTest.java b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTest.java index 86af2f2f051..c157fa07eba 100644 --- a/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTest.java +++ b/core/src/test/java/org/elasticsearch/index/query/RangeQueryBuilderTest.java @@ -63,9 +63,8 @@ public class RangeQueryBuilderTest extends BaseQueryTestCase query = new RangeQueryBuilder(DATE_FIELD_NAME); query.from(new DateTime(System.currentTimeMillis() - randomIntBetween(0, 1000000)).toString()); query.to(new DateTime(System.currentTimeMillis() + randomIntBetween(0, 1000000)).toString()); - // Use timestamp option then we have a date mapper, otherwise we would trigger exception. - // There is a separate test for that. - if (createContext().fieldMapper(DATE_FIELD_NAME) != null) { + // Create timestamp option only then we have a date mapper, otherwise we could trigger exception. + if (createContext().mapperService().smartNameFieldType(DATE_FIELD_NAME) != null) { if (randomBoolean()) { query.timeZone(TIMEZONE_IDS.get(randomIntBetween(0, TIMEZONE_IDS.size() - 1))); }