From 0065a1ebf38d34dbdc5a2fe801e1c6be5e32848a Mon Sep 17 00:00:00 2001 From: Harsha Vamsi Kalluri Date: Wed, 3 Jan 2024 10:11:17 -0800 Subject: [PATCH] Fixing assert statements Signed-off-by: Harsha Vamsi Kalluri --- .../index/query/SimpleQueryStringBuilderTests.java | 6 ++++-- .../org/opensearch/index/search/MultiMatchQueryTests.java | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java b/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java index 773b08b9f4580..0c713a9e832eb 100644 --- a/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java +++ b/server/src/test/java/org/opensearch/index/query/SimpleQueryStringBuilderTests.java @@ -316,8 +316,10 @@ protected void doAssertLuceneQuery(SimpleQueryStringBuilder queryBuilder, Query if (disjunct instanceof BoostQuery) { termQuery = ((BoostQuery) disjunct).getQuery(); } - if (termQuery instanceof TermQuery) { - TermQuery inner = (TermQuery) termQuery; + if (termQuery instanceof TermQuery || termQuery instanceof IndexOrDocValuesQuery) { + TermQuery inner; + if (termQuery instanceof IndexOrDocValuesQuery) inner = (TermQuery) ((IndexOrDocValuesQuery) termQuery).getIndexQuery(); + else inner = (TermQuery) termQuery; assertThat(inner.getTerm().bytes().toString(), is(inner.getTerm().bytes().toString().toLowerCase(Locale.ROOT))); } else { assertThat(termQuery, instanceOf(MatchNoDocsQuery.class)); diff --git a/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java b/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java index 3042c488fa80c..7c2add86cb962 100644 --- a/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java +++ b/server/src/test/java/org/opensearch/index/search/MultiMatchQueryTests.java @@ -364,6 +364,6 @@ public void testKeywordSplitQueriesOnWhitespace() throws IOException { ), 0.0f ); - assertThat(query, equalTo(expected)); + assertThat(expected, equalTo(query)); } }