Skip to content

Commit 29c4d55

Browse files
spotlessApply
Signed-off-by: Srikanth Padakanti <[email protected]>
1 parent 33e47bf commit 29c4d55

File tree

1 file changed

+18
-29
lines changed

1 file changed

+18
-29
lines changed

server/src/test/java/org/opensearch/index/query/TermQueryWithDocIdAndQueryTests.java

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,21 @@
3232

3333
package org.opensearch.index.query;
3434

35-
import org.apache.lucene.search.MatchAllDocsQuery;
3635
import org.apache.lucene.search.Query;
3736
import org.apache.lucene.search.TotalHits;
38-
import org.opensearch.action.ListenableActionFuture;
39-
import org.opensearch.action.search.SearchRequest;
4037
import org.opensearch.action.search.SearchResponse;
4138
import org.opensearch.core.common.bytes.BytesArray;
42-
import org.opensearch.index.mapper.MappedFieldType;
4339
import org.opensearch.indices.TermsLookup;
4440
import org.opensearch.search.SearchHit;
4541
import org.opensearch.search.SearchHits;
4642
import org.opensearch.test.OpenSearchTestCase;
47-
import org.opensearch.transport.client.Client;
4843

4944
import java.io.IOException;
5045
import java.util.Arrays;
51-
import java.util.Collections;
52-
import java.util.List;
53-
import java.util.Map;
5446

5547
import static org.hamcrest.CoreMatchers.instanceOf;
56-
import static org.mockito.ArgumentMatchers.any;
57-
import static org.mockito.Mockito.*;
48+
import static org.mockito.Mockito.mock;
49+
import static org.mockito.Mockito.when;
5850

5951
public class TermQueryWithDocIdAndQueryTests extends OpenSearchTestCase {
6052
public void testTermsQueryWithIdOnlyAndVerifyResults() throws Exception {
@@ -72,9 +64,9 @@ public void testTermsQueryWithIdOnlyAndVerifyResults() throws Exception {
7264
// Mock the search response
7365
SearchResponse mockResponse = mock(SearchResponse.class);
7466
SearchHits mockHits = new SearchHits(
75-
new SearchHit[]{
67+
new SearchHit[] {
7668
new SearchHit(1).sourceRef(new BytesArray("{\"name\":\"Jane Doe\",\"student_id\":\"111\"}")),
77-
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Mary Major\",\"student_id\":\"222\"}"))},
69+
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Mary Major\",\"student_id\":\"222\"}")) },
7870
new TotalHits(2, TotalHits.Relation.EQUAL_TO), // Use TotalHits instead of int
7971
1.0f
8072
);
@@ -112,9 +104,9 @@ public void testTermsQueryWithQueryOnlyAndVerifyResults() throws Exception {
112104
// Mock the search response
113105
SearchResponse mockResponse = mock(SearchResponse.class);
114106
SearchHits mockHits = new SearchHits(
115-
new SearchHit[]{
107+
new SearchHit[] {
116108
new SearchHit(1).sourceRef(new BytesArray("{\"name\":\"Jane Doe\",\"student_id\":\"111\"}")),
117-
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Mary Major\",\"student_id\":\"222\"}"))},
109+
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Mary Major\",\"student_id\":\"222\"}")) },
118110
new TotalHits(2, TotalHits.Relation.EQUAL_TO),
119111
1.0f
120112
);
@@ -191,9 +183,9 @@ public void testTermsQueryWithInsertedData() throws Exception {
191183
// Mock the search response
192184
SearchResponse mockResponse = mock(SearchResponse.class);
193185
SearchHits mockHits = new SearchHits(
194-
new SearchHit[]{
186+
new SearchHit[] {
195187
new SearchHit(1).sourceRef(new BytesArray("{\"name\":\"John Smith\",\"student_id\":\"333\"}")),
196-
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Alice Brown\",\"student_id\":\"444\"}"))},
188+
new SearchHit(2).sourceRef(new BytesArray("{\"name\":\"Alice Brown\",\"student_id\":\"444\"}")) },
197189
new TotalHits(2, TotalHits.Relation.EQUAL_TO),
198190
1.0f
199191
);
@@ -210,9 +202,7 @@ public void testTermsQueryWithInsertedData() throws Exception {
210202

211203
public void testTermsQueryWithNoIdAndNoQuery() {
212204
// Attempt to create a TermsLookup with no id and no query
213-
Exception exception = expectThrows(IllegalArgumentException.class, () -> {
214-
new TermsLookup("classes", null, "enrolled");
215-
});
205+
Exception exception = expectThrows(IllegalArgumentException.class, () -> { new TermsLookup("classes", null, "enrolled"); });
216206

217207
// Verify the exception message
218208
assertEquals(
@@ -256,7 +246,6 @@ public void testTermsQueryWithComplexQuery() throws Exception {
256246
public void testRewriteWithTermsLookupQuery() throws IOException {
257247
QueryBuilder spyQuery = mock(QueryBuilder.class);
258248

259-
260249
TermsLookup termsLookup = new TermsLookup("test-index", null, "field", spyQuery);
261250

262251
// Create the TermsQueryBuilder with the TermsLookup
@@ -276,15 +265,15 @@ public void testRewriteWithTermsLookupQuery() throws IOException {
276265
assertEquals(1.0f, resultTermsQuery.boost(), 0.001f);
277266

278267
// Optionally, check the JSON representation if you want string-based asserts
279-
String expectedJson = "{\n" +
280-
" \"terms\" : {\n" +
281-
" \"field\" : [\n" +
282-
" \"value1\",\n" +
283-
" \"value2\"\n" +
284-
" ],\n" +
285-
" \"boost\" : 1.0\n" +
286-
" }\n" +
287-
"}";
268+
String expectedJson = "{\n"
269+
+ " \"terms\" : {\n"
270+
+ " \"field\" : [\n"
271+
+ " \"value1\",\n"
272+
+ " \"value2\"\n"
273+
+ " ],\n"
274+
+ " \"boost\" : 1.0\n"
275+
+ " }\n"
276+
+ "}";
288277
assertEquals(expectedJson, result.toString());
289278
}
290279
}

0 commit comments

Comments
 (0)