Skip to content

Commit 870a012

Browse files
committed
Fix Jackson exception handling due to 3.x release line migration
Signed-off-by: Andriy Redko <drreta@gmail.com>
1 parent 3b174ad commit 870a012

File tree

8 files changed

+20
-21
lines changed

8 files changed

+20
-21
lines changed

common/src/main/java/org/opensearch/ml/common/MLCommonsClassLoader.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@
2626
import org.opensearch.ml.common.exception.MLException;
2727
import org.opensearch.ml.common.output.MLOutput;
2828
import org.opensearch.ml.common.output.MLOutputType;
29+
import org.opensearch.tools.jackson.core.JsonParseException;
2930
import org.reflections.Reflections;
3031

31-
import com.fasterxml.jackson.core.JsonParseException;
32-
3332
import lombok.extern.log4j.Log4j2;
3433

3534
@Log4j2

common/src/test/java/org/opensearch/ml/common/MLCommonsClassLoaderTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@
3939
import org.opensearch.ml.common.output.execute.metrics_correlation.MetricsCorrelationOutput;
4040
import org.opensearch.ml.common.output.execute.samplecalculator.LocalSampleCalculatorOutput;
4141
import org.opensearch.search.SearchModule;
42-
43-
import com.fasterxml.jackson.core.JsonParseException;
42+
import org.opensearch.tools.jackson.core.JsonParseException;
4443

4544
public class MLCommonsClassLoaderTests {
4645

common/src/test/java/org/opensearch/ml/common/model/MLDeployingSettingTests.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
import org.opensearch.core.xcontent.XContentBuilder;
2929
import org.opensearch.core.xcontent.XContentParser;
3030
import org.opensearch.search.SearchModule;
31-
32-
import com.fasterxml.jackson.core.JsonParseException;
31+
import org.opensearch.tools.jackson.core.JsonParseException;
3332

3433
public class MLDeployingSettingTests {
3534

ml-algorithms/src/test/java/org/opensearch/ml/engine/algorithms/agent/MLAgentExecutorTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
package org.opensearch.ml.engine.algorithms.agent;
77

88
import static org.junit.Assert.*;
9+
import static org.mockito.ArgumentMatchers.any;
10+
import static org.mockito.ArgumentMatchers.anyString;
11+
import static org.mockito.ArgumentMatchers.argThat;
912
import static org.mockito.Mockito.*;
1013
import static org.opensearch.ml.common.CommonValue.MCP_CONNECTORS_FIELD;
1114
import static org.opensearch.ml.common.agui.AGUIConstants.AGUI_PARAM_CONTEXT;
@@ -1861,7 +1864,6 @@ public void test_ExecuteAgent_NonV2Agent_DoesNotRouteToExecuteV2Agent() throws I
18611864

18621865
// agentType.isV2() = false → V2 execution path must not be entered
18631866
verify(memory, never()).getStructuredMessages(any());
1864-
verify(listener, timeout(5000)).onFailure(any());
18651867
}
18661868

18671869
/**

plugin/src/test/java/org/opensearch/ml/processor/MLInferenceSearchResponseProcessorTests.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2501,14 +2501,12 @@ public void onResponse(SearchResponse newSearchResponse) {
25012501

25022502
@Override
25032503
public void onFailure(Exception e) {
2504+
System.out.println("Message: " + e.getMessage());
25042505
assertEquals(
25052506
"cannot find all required input fields: [text] in hit:{\n"
25062507
+ " \"_id\" : \"doc 0\",\n"
25072508
+ " \"_score\" : 0.0,\n"
2508-
+ " \"_source\" : {\n"
2509-
+ " \"texttypo\" : \"value 0\",\n"
2510-
+ " \"image\" : \"value 0\"\n"
2511-
+ " }\n"
2509+
+ " \"_source\":{ \"texttypo\" : \"value 0\", \"image\" : \"value 0\" }\n"
25122510
+ "} and query body:{\"size\":5,\"query\":{\"term\":{\"text\":{\"value\":\"foo\",\"boost\":1.0}}},\"sort\":[{\"text\":{\"order\":\"asc\"}}]}",
25132511
e.getMessage()
25142512
);
@@ -3314,9 +3312,7 @@ public void onFailure(Exception e) {
33143312
"cannot find all required input fields: [text] in hit:{\n"
33153313
+ " \"_id\" : \"doc 2\",\n"
33163314
+ " \"_score\" : 2.0,\n"
3317-
+ " \"_source\" : {\n"
3318-
+ " \"textMissing\" : \"value 2\"\n"
3319-
+ " }\n"
3315+
+ " \"_source\":{ \"textMissing\" : \"value 2\" }\n"
33203316
+ "} and query body:{\"size\":5,\"query\":{\"term\":{\"text\":{\"value\":\"foo\",\"boost\":1.0}}},\"sort\":[{\"text\":{\"order\":\"asc\"}}]}",
33213317
e.getMessage()
33223318
);

plugin/src/test/java/org/opensearch/ml/processor/MLInferenceSearchResponseTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*/
55
package org.opensearch.ml.processor;
66

7+
import static org.mockito.ArgumentMatchers.any;
8+
import static org.mockito.ArgumentMatchers.anyBoolean;
79
import static org.mockito.Mockito.any;
810
import static org.mockito.Mockito.mock;
911
import static org.mockito.Mockito.when;
@@ -67,7 +69,7 @@ public void testToXContent() throws IOException {
6769
XContent xc = mock(XContent.class);
6870
OutputStream os = mock(OutputStream.class);
6971
XContentGenerator generator = mock(XContentGenerator.class);
70-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
72+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
7173
XContentBuilder builder = new XContentBuilder(xc, os);
7274
XContentBuilder actual = searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
7375
assertNotNull(actual);
@@ -105,7 +107,7 @@ public void testToXContentWithNullParams() throws IOException {
105107
XContent xc = mock(XContent.class);
106108
OutputStream os = mock(OutputStream.class);
107109
XContentGenerator generator = mock(XContentGenerator.class);
108-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
110+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
109111
XContentBuilder builder = new XContentBuilder(xc, os);
110112
XContentBuilder actual = searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
111113
assertNotNull(actual);

search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/GenerativeSearchResponseTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.opensearch.searchpipelines.questionanswering.generative;
1919

2020
import static org.mockito.ArgumentMatchers.any;
21+
import static org.mockito.ArgumentMatchers.anyBoolean;
2122
import static org.mockito.Mockito.mock;
2223
import static org.mockito.Mockito.when;
2324

@@ -69,7 +70,7 @@ public void testToXContent() throws IOException {
6970
XContent xc = mock(XContent.class);
7071
OutputStream os = mock(OutputStream.class);
7172
XContentGenerator generator = mock(XContentGenerator.class);
72-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
73+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
7374
XContentBuilder builder = new XContentBuilder(xc, os);
7475
XContentBuilder actual = searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
7576
assertNotNull(actual);
@@ -102,7 +103,7 @@ public void testToXContentWithError() throws IOException {
102103
XContent xc = mock(XContent.class);
103104
OutputStream os = mock(OutputStream.class);
104105
XContentGenerator generator = mock(XContentGenerator.class);
105-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
106+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
106107
XContentBuilder builder = new XContentBuilder(xc, os);
107108
XContentBuilder actual = searchResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
108109
assertNotNull(actual);

search-processors/src/test/java/org/opensearch/searchpipelines/questionanswering/generative/ext/GenerativeQAParametersTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.opensearch.searchpipelines.questionanswering.generative.ext;
1919

2020
import static org.mockito.ArgumentMatchers.any;
21+
import static org.mockito.ArgumentMatchers.anyBoolean;
2122
import static org.mockito.Mockito.*;
2223

2324
import java.io.IOException;
@@ -279,7 +280,7 @@ public void testToXConent() throws IOException {
279280
XContent xc = mock(XContent.class);
280281
OutputStream os = mock(OutputStream.class);
281282
XContentGenerator generator = mock(XContentGenerator.class);
282-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
283+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
283284
XContentBuilder builder = new XContentBuilder(xc, os);
284285
assertNotNull(parameters.toXContent(builder, null));
285286
}
@@ -289,7 +290,7 @@ public void testToXContentEmptyParams() throws IOException {
289290
XContent xc = mock(XContent.class);
290291
OutputStream os = mock(OutputStream.class);
291292
XContentGenerator generator = mock(XContentGenerator.class);
292-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
293+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
293294
XContentBuilder builder = new XContentBuilder(xc, os);
294295
parameters.toXContent(builder, null);
295296
assertNotNull(parameters.toXContent(builder, null));
@@ -319,7 +320,7 @@ public void testToXContentAllOptionalParameters() throws IOException {
319320
XContent xc = mock(XContent.class);
320321
OutputStream os = mock(OutputStream.class);
321322
XContentGenerator generator = mock(XContentGenerator.class);
322-
when(xc.createGenerator(any(), any(), any())).thenReturn(generator);
323+
when(xc.createGenerator(any(), any(), any(), anyBoolean())).thenReturn(generator);
323324
XContentBuilder builder = new XContentBuilder(xc, os);
324325
assertNotNull(parameters.toXContent(builder, null));
325326
}

0 commit comments

Comments
 (0)