Tests: Fix TermsQueryBuilderTests expectations when lookup returns no terms
When the termslookup (mocked in this case) doesn't return any terms, the query used to rewrite to an empty boolean query. Now it rewrites to a MatchNoDocsQuery. This changes the test expectation accordingly. Closes #18071
This commit is contained in:
parent
b2ce2f5afa
commit
262a814c8d
|
@ -96,6 +96,12 @@ public class TermsQueryBuilderTests extends AbstractQueryTestCase<TermsQueryBuil
|
|||
protected void doAssertLuceneQuery(TermsQueryBuilder queryBuilder, Query query, QueryShardContext context) throws IOException {
|
||||
if (queryBuilder.termsLookup() == null && (queryBuilder.values() == null || queryBuilder.values().isEmpty())) {
|
||||
assertThat(query, instanceOf(MatchNoDocsQuery.class));
|
||||
MatchNoDocsQuery matchNoDocsQuery = (MatchNoDocsQuery) query;
|
||||
assertThat(matchNoDocsQuery.toString(), containsString("No terms supplied for \"terms\" query."));
|
||||
} else if (queryBuilder.termsLookup() != null && randomTerms.size() == 0){
|
||||
assertThat(query, instanceOf(MatchNoDocsQuery.class));
|
||||
MatchNoDocsQuery matchNoDocsQuery = (MatchNoDocsQuery) query;
|
||||
assertThat(matchNoDocsQuery.toString(), containsString("No terms supplied for \"terms\" query."));
|
||||
} else {
|
||||
assertThat(query, instanceOf(BooleanQuery.class));
|
||||
BooleanQuery booleanQuery = (BooleanQuery) query;
|
||||
|
|
Loading…
Reference in New Issue