Tests: fix RangeQueryBuilderTest, only use timestamp when date mapper is available
Also renaming field names to 'mapped_<fieldtype>' to avoid misunderstandings in error messages.
This commit is contained in:
parent
5cdb1e6537
commit
11492b8962
|
@ -76,12 +76,12 @@ import static org.hamcrest.Matchers.is;
|
|||
@Ignore
|
||||
public abstract class BaseQueryTestCase<QB extends QueryBuilder<QB>> 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 };
|
||||
|
||||
|
|
|
@ -63,9 +63,8 @@ public class RangeQueryBuilderTest extends BaseQueryTestCase<RangeQueryBuilder>
|
|||
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)));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue