diff --git a/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java b/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java index b26e2e8b812..50371ced0e0 100644 --- a/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java +++ b/core/src/test/java/org/elasticsearch/index/query/SpanMultiTermQueryBuilderTests.java @@ -19,12 +19,17 @@ package org.elasticsearch.index.query; +import org.apache.lucene.index.Term; import org.apache.lucene.search.BoostQuery; import org.apache.lucene.search.MultiTermQuery; import org.apache.lucene.search.Query; +import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.spans.SpanBoostQuery; import org.apache.lucene.search.spans.SpanMultiTermQueryWrapper; import org.apache.lucene.search.spans.SpanQuery; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.common.xcontent.ToXContent; +import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.search.internal.SearchContext; import org.elasticsearch.test.AbstractQueryTestCase; @@ -72,12 +77,57 @@ public class SpanMultiTermQueryBuilderTests extends AbstractQueryTestCase 0 && context.fieldMapper(DATE_FIELD_NAME) != null); + MultiTermQueryBuilder query = new MultiTermQueryBuilder() { + @Override + public Query toQuery(QueryShardContext context) throws IOException { + return new TermQuery(new Term("foo", "bar")); + } - RangeQueryBuilder query = new RangeQueryBuilder(DATE_FIELD_NAME); + @Override + public Query toFilter(QueryShardContext context) throws IOException { + return toQuery(context); + } + + @Override + public QueryBuilder queryName(String queryName) { + return this; + } + + @Override + public String queryName() { + return "foo"; + } + + @Override + public float boost() { + return 1f; + } + + @Override + public QueryBuilder boost(float boost) { + return this; + } + + @Override + public String getName() { + return "foo"; + } + + @Override + public String getWriteableName() { + return "foo"; + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + return builder; + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + + } + }; SpanMultiTermQueryBuilder spamMultiTermQuery = new SpanMultiTermQueryBuilder(query); UnsupportedOperationException e = expectThrows(UnsupportedOperationException.class, () -> spamMultiTermQuery.toQuery(createShardContext()));