Skip to content

Commit ad1c15b

Browse files
committed
fix tests
Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent 4b9ee5c commit ad1c15b

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

core/src/test/java/org/opensearch/sql/executor/execution/QueryPlanTest.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,12 @@
66
package org.opensearch.sql.executor.execution;
77

88
import static org.junit.jupiter.api.Assertions.assertNotNull;
9-
import static org.junit.jupiter.api.Assertions.assertTrue;
109
import static org.junit.jupiter.api.Assertions.fail;
1110
import static org.mockito.ArgumentMatchers.any;
1211
import static org.mockito.Mockito.mock;
1312
import static org.mockito.Mockito.times;
1413
import static org.mockito.Mockito.verify;
1514

16-
import org.apache.commons.lang3.NotImplementedException;
1715
import org.junit.jupiter.api.DisplayNameGeneration;
1816
import org.junit.jupiter.api.DisplayNameGenerator;
1917
import org.junit.jupiter.api.Test;
@@ -110,20 +108,14 @@ public void onFailure(Exception e) {
110108
}
111109

112110
@Test
113-
public void explain_is_not_supported_for_pagination() {
114-
new QueryPlan(null, null, null, 0, null, null)
115-
.explain(
116-
new ResponseListener<>() {
117-
@Override
118-
public void onResponse(ExecutionEngine.ExplainResponse response) {
119-
fail();
120-
}
121-
122-
@Override
123-
public void onFailure(Exception e) {
124-
assertTrue(e instanceof NotImplementedException);
125-
}
126-
},
127-
format);
111+
public void explain_with_pagination() {
112+
int pageSize = 10;
113+
int offset = 5;
114+
QueryPlan query =
115+
new QueryPlan(queryId, queryType, plan, pageSize, offset, queryService, queryListener);
116+
query.explain(explainListener, format);
117+
118+
verify(queryService, times(1))
119+
.explain(plan, queryType, explainListener, format, pageSize, offset);
128120
}
129121
}

integ-test/src/test/java/org/opensearch/sql/sql/StandalonePaginationIT.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,13 @@ public void onFailure(Exception e) {
140140

141141
@Test
142142
@SneakyThrows
143-
public void test_explain_not_supported() {
143+
public void test_explain_cursor_not_supported() {
144144
var request = new Request("POST", "_plugins/_sql/_explain");
145-
// Request should be rejected before index names are resolved
146-
request.setJsonEntity("{ \"query\": \"select * from something\", \"fetch_size\": 10 }");
145+
// Explain with cursor continuation should be rejected
146+
request.setJsonEntity("{ \"cursor\" : \"n:0000\" }");
147147
var exception = assertThrows(ResponseException.class, () -> client().performRequest(request));
148148
var response =
149149
new JSONObject(new String(exception.getResponse().getEntity().getContent().readAllBytes()));
150-
assertEquals(
151-
"`explain` feature for paginated requests is not implemented yet.",
152-
response.getJSONObject("error").getString("details"));
153-
154-
// Request should be rejected before cursor parsed
155-
request.setJsonEntity("{ \"cursor\" : \"n:0000\" }");
156-
exception = assertThrows(ResponseException.class, () -> client().performRequest(request));
157-
response =
158-
new JSONObject(new String(exception.getResponse().getEntity().getContent().readAllBytes()));
159150
assertEquals(
160151
"Explain of a paged query continuation is not supported. Use `explain` for the initial"
161152
+ " query request.",

0 commit comments

Comments
 (0)