From fe80f66cc30c6fa78acd39acb5a2cb3c96751d2c Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Tue, 1 Aug 2023 12:53:51 -0700 Subject: [PATCH] Fix compilation errors after recent core pushes Signed-off-by: Martin Gaievski --- .../src/test/java/org/opensearch/ml/common/TestHelper.java | 5 +++-- .../org/opensearch/ml/common/dataframe/BooleanValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/ColumnMetaTest.java | 3 ++- .../opensearch/ml/common/dataframe/DefaultDataFrameTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/DoubleValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/FloatValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/IntValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/LongValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/NullValueTest.java | 4 ++-- .../java/org/opensearch/ml/common/dataframe/RowTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/ShortValueTest.java | 4 ++-- .../org/opensearch/ml/common/dataframe/StringValueTest.java | 4 ++-- .../java/org/opensearch/ml/common/input/MLInputTest.java | 3 ++- .../opensearch/ml/common/input/nlp/TextDocsMLInputTest.java | 3 ++- .../opensearch/ml/common/output/MLPredictionOutputTest.java | 5 +++-- .../opensearch/ml/common/output/MLTrainingOutputTest.java | 3 ++- .../samplecalculator/LocalSampleCalculatorOutputTest.java | 5 +++-- .../ml/common/output/sample/SampleAlgoOutputTest.java | 5 +++-- .../transport/deploy/MLDeployModelNodesResponseTest.java | 4 ++-- .../common/transport/deploy/MLDeployModelResponseTest.java | 3 ++- .../common/transport/execute/MLExecuteTaskResponseTest.java | 3 ++- .../ml/common/transport/forward/MLForwardResponseTest.java | 3 ++- .../ml/common/transport/model/MLModelGetResponseTest.java | 3 ++- .../transport/prediction/MLPredictionTaskResponseTest.java | 4 ++-- .../common/transport/register/MLRegisterModelInputTest.java | 5 +++-- .../transport/register/MLRegisterModelResponseTest.java | 3 ++- .../ml/common/transport/sync/MLSyncUpResponseTest.java | 3 ++- .../ml/common/transport/task/MLTaskGetResponseTest.java | 3 ++- .../common/transport/undeploy/MLUndeployModelInputTest.java | 3 ++- .../transport/undeploy/MLUndeployModelNodesResponseTest.java | 3 ++- .../ml/cluster/MLCommonsClusterManagerEventListener.java | 2 +- .../java/org/opensearch/ml/rest/MLCommonsRestTestCase.java | 4 ++-- .../test/java/org/opensearch/ml/utils/IntegTestUtils.java | 4 ++-- 33 files changed, 70 insertions(+), 52 deletions(-) diff --git a/common/src/test/java/org/opensearch/ml/common/TestHelper.java b/common/src/test/java/org/opensearch/ml/common/TestHelper.java index 4123d9482b..e1c5c9d03d 100644 --- a/common/src/test/java/org/opensearch/ml/common/TestHelper.java +++ b/common/src/test/java/org/opensearch/ml/common/TestHelper.java @@ -10,6 +10,7 @@ import org.opensearch.common.xcontent.LoggingDeprecationHandler; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.ToXContentObject; @@ -27,7 +28,7 @@ public static void testParse(ToXContentObject obj, Function void testParse(ToXContentObject obj, Function function, boolean wrapWithObject) throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); if (wrapWithObject) { builder.startObject(); } @@ -49,7 +50,7 @@ public static void testParseFromString(ToXContentObject obj, String jsonStr, } public static String contentObjectToString(ToXContentObject obj) throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); obj.toXContent(builder, ToXContent.EMPTY_PARAMS); return xContentBuilderToString(builder); } diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/BooleanValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/BooleanValueTest.java index 691f69de71..2770d09ba5 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/BooleanValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/BooleanValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -29,7 +29,7 @@ public void booleanValue() { @Test public void testToXContent() throws IOException { BooleanValue value = new BooleanValue(true); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); value.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/ColumnMetaTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/ColumnMetaTest.java index 1ea78c04cd..7f308097a0 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/ColumnMetaTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/ColumnMetaTest.java @@ -11,6 +11,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.ml.common.TestHelper; @@ -51,7 +52,7 @@ public void writeToAndReadStream() throws IOException { @Test public void testToXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); columnMeta.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/DefaultDataFrameTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/DefaultDataFrameTest.java index d4fc6dea29..acaf2c7284 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/DefaultDataFrameTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/DefaultDataFrameTest.java @@ -17,8 +17,8 @@ import org.opensearch.common.Strings; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamInput; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.ml.common.TestHelper; @@ -227,7 +227,7 @@ public void select_Exception_InvalidColumn(){ @Test public void testToXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.startObject(); defaultDataFrame.toXContent(builder); builder.endObject(); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/DoubleValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/DoubleValueTest.java index 372b0070ef..7a3c5f0a15 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/DoubleValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/DoubleValueTest.java @@ -10,8 +10,8 @@ import org.junit.Test; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import static org.junit.Assert.assertEquals; @@ -47,7 +47,7 @@ public void writeTo() throws IOException { @Test public void testToXContent() throws IOException { DoubleValue doubleValue = new DoubleValue(5.0D); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); doubleValue.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/FloatValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/FloatValueTest.java index 08f5ec81e3..db3648c8fa 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/FloatValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/FloatValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -30,7 +30,7 @@ public void floatValue() { @Test public void testToXContent() throws IOException { FloatValue floatValue = new FloatValue(2.1f); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); floatValue.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/IntValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/IntValueTest.java index 3feea82fc3..5c25002fdb 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/IntValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/IntValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -29,7 +29,7 @@ public void intValue() { @Test public void testToXContent() throws IOException { IntValue intValue = new IntValue(2); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); intValue.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/LongValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/LongValueTest.java index 97b6cbcc1c..11118b42e4 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/LongValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/LongValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -29,7 +29,7 @@ public void longValue() { @Test public void testToXContent() throws IOException { LongValue longValue = new LongValue((long)2); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); longValue.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/NullValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/NullValueTest.java index 327848a6e8..4acffc4989 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/NullValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/NullValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -30,7 +30,7 @@ public void getValue() { @Test public void testToXContent() throws IOException { NullValue value = new NullValue(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); value.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/RowTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/RowTest.java index abc4eefd86..01198c7531 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/RowTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/RowTest.java @@ -15,8 +15,8 @@ import org.junit.rules.ExpectedException; import org.opensearch.common.Strings; import org.opensearch.common.io.stream.BytesStreamOutput; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParser; @@ -133,7 +133,7 @@ public void select() { @Test public void testToXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); row.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/ShortValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/ShortValueTest.java index 6db79f115c..2fbc43bdfa 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/ShortValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/ShortValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.XContentBuilder; import java.io.IOException; @@ -29,7 +29,7 @@ public void shortValue() { @Test public void testToXContent() throws IOException { ShortValue shortValue = new ShortValue((short)2); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); shortValue.toXContent(builder); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/dataframe/StringValueTest.java b/common/src/test/java/org/opensearch/ml/common/dataframe/StringValueTest.java index 6b64c4813c..3f2ac26889 100644 --- a/common/src/test/java/org/opensearch/ml/common/dataframe/StringValueTest.java +++ b/common/src/test/java/org/opensearch/ml/common/dataframe/StringValueTest.java @@ -7,8 +7,8 @@ import org.junit.Test; import org.opensearch.common.Strings; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -34,7 +34,7 @@ public void stringValue_NullPointerException() { @Test public void testToXContent() throws IOException { StringValue value = new StringValue("str"); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); value.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/input/MLInputTest.java b/common/src/test/java/org/opensearch/ml/common/input/MLInputTest.java index 7d48cb2982..99533df552 100644 --- a/common/src/test/java/org/opensearch/ml/common/input/MLInputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/input/MLInputTest.java @@ -16,6 +16,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -147,7 +148,7 @@ public void parse_TextEmbedding_NullResultFilter() throws IOException { private void testParse(FunctionName algorithm, MLInputDataset inputDataset, String expectedInputStr, Consumer verify) throws IOException { MLInput input = MLInput.builder().inputDataset(inputDataset).algorithm(algorithm).build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); input.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/input/nlp/TextDocsMLInputTest.java b/common/src/test/java/org/opensearch/ml/common/input/nlp/TextDocsMLInputTest.java index 2a097e2047..d0e8fa583f 100644 --- a/common/src/test/java/org/opensearch/ml/common/input/nlp/TextDocsMLInputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/input/nlp/TextDocsMLInputTest.java @@ -8,6 +8,7 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -47,7 +48,7 @@ public void setUp() throws Exception { @Test public void parseTextDocsMLInput() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); input.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); System.out.println(jsonStr); diff --git a/common/src/test/java/org/opensearch/ml/common/output/MLPredictionOutputTest.java b/common/src/test/java/org/opensearch/ml/common/output/MLPredictionOutputTest.java index 1d53845cfc..3f8637e261 100644 --- a/common/src/test/java/org/opensearch/ml/common/output/MLPredictionOutputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/output/MLPredictionOutputTest.java @@ -12,6 +12,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.dataframe.ColumnMeta; @@ -48,7 +49,7 @@ public void setUp() { @Test public void toXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); output.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals("{\"task_id\":\"test_task_id\",\"status\":\"test_status\",\"prediction_result\":" + @@ -60,7 +61,7 @@ public void toXContent() throws IOException { @Test public void toXContent_EmptyOutput() throws IOException { MLPredictionOutput output = MLPredictionOutput.builder().build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); output.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals("{}", jsonStr); diff --git a/common/src/test/java/org/opensearch/ml/common/output/MLTrainingOutputTest.java b/common/src/test/java/org/opensearch/ml/common/output/MLTrainingOutputTest.java index bc51671011..d21afd9115 100644 --- a/common/src/test/java/org/opensearch/ml/common/output/MLTrainingOutputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/output/MLTrainingOutputTest.java @@ -9,6 +9,7 @@ import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -21,7 +22,7 @@ public class MLTrainingOutputTest { public void parse_MLTrain() throws IOException { MLTrainingOutput output = MLTrainingOutput.builder() .modelId("test_modelId").status("test_status").build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); output.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = Strings.toString(builder); assertEquals("{\"model_id\":\"test_modelId\",\"status\":\"test_status\"}", jsonStr); diff --git a/common/src/test/java/org/opensearch/ml/common/output/execute/samplecalculator/LocalSampleCalculatorOutputTest.java b/common/src/test/java/org/opensearch/ml/common/output/execute/samplecalculator/LocalSampleCalculatorOutputTest.java index aa40843e84..49f05e4dae 100644 --- a/common/src/test/java/org/opensearch/ml/common/output/execute/samplecalculator/LocalSampleCalculatorOutputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/output/execute/samplecalculator/LocalSampleCalculatorOutputTest.java @@ -12,6 +12,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -32,7 +33,7 @@ public void setUp() { @Test public void toXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.startObject(); output.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); @@ -43,7 +44,7 @@ public void toXContent() throws IOException { @Test public void toXContent_EmptyOutput() throws IOException { LocalSampleCalculatorOutput output = LocalSampleCalculatorOutput.builder().build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.startObject(); output.toXContent(builder, ToXContent.EMPTY_PARAMS); builder.endObject(); diff --git a/common/src/test/java/org/opensearch/ml/common/output/sample/SampleAlgoOutputTest.java b/common/src/test/java/org/opensearch/ml/common/output/sample/SampleAlgoOutputTest.java index fc464e5aa5..a1ddb7e7b2 100644 --- a/common/src/test/java/org/opensearch/ml/common/output/sample/SampleAlgoOutputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/output/sample/SampleAlgoOutputTest.java @@ -12,6 +12,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.output.MLOutputType; @@ -32,7 +33,7 @@ public void setUp() { @Test public void toXContent() throws IOException { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); output.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals("{\"sample_result\":1.0}", jsonStr); @@ -41,7 +42,7 @@ public void toXContent() throws IOException { @Test public void toXContent_EmptyOutput() throws IOException { SampleAlgoOutput output = SampleAlgoOutput.builder().build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); output.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals("{}", jsonStr); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodesResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodesResponseTest.java index 1374b99392..4f8b003d65 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodesResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelNodesResponseTest.java @@ -12,8 +12,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.transport.TransportAddress; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -73,7 +73,7 @@ public void testToXContent() throws IOException { List failures = new ArrayList<>(); MLDeployModelNodesResponse response = new MLDeployModelNodesResponse(clusterName, nodes, failures); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals( diff --git a/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelResponseTest.java index b9afc837a2..ba4ef87033 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/deploy/MLDeployModelResponseTest.java @@ -6,6 +6,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -43,7 +44,7 @@ public void testToXContent() throws IOException { // Setup MLDeployModelResponse response = new MLDeployModelResponse(taskId, status); // Run the test - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/execute/MLExecuteTaskResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/execute/MLExecuteTaskResponseTest.java index 733a7127fb..e77a90c9c9 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/execute/MLExecuteTaskResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/execute/MLExecuteTaskResponseTest.java @@ -5,6 +5,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.FunctionName; @@ -87,7 +88,7 @@ public void toXContentTest() throws IOException { .output(output) .build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/forward/MLForwardResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/forward/MLForwardResponseTest.java index b9335c8477..aebe33e153 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/forward/MLForwardResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/forward/MLForwardResponseTest.java @@ -10,6 +10,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.dataframe.DataFrame; @@ -62,7 +63,7 @@ public void testToXContent() throws IOException { // Setup MLForwardResponse response = new MLForwardResponse(status, predictionOutput); // Run the test - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/model/MLModelGetResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/model/MLModelGetResponseTest.java index 29df2a7740..62f336281d 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/model/MLModelGetResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/model/MLModelGetResponseTest.java @@ -12,6 +12,7 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.authuser.User; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.FunctionName; @@ -55,7 +56,7 @@ public void writeTo_Success() throws IOException { @Test public void toXContentTest() throws IOException { MLModelGetResponse mlModelGetResponse = MLModelGetResponse.builder().mlModel(mlModel).build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); mlModelGetResponse.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/prediction/MLPredictionTaskResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/prediction/MLPredictionTaskResponseTest.java index 18412bc677..0622183fb8 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/prediction/MLPredictionTaskResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/prediction/MLPredictionTaskResponseTest.java @@ -10,8 +10,8 @@ import org.opensearch.core.common.Strings; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.core.common.io.stream.StreamOutput; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.dataframe.DataFrameBuilder; @@ -125,7 +125,7 @@ public void toXContentTest() throws IOException { .output(output) .build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelInputTest.java b/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelInputTest.java index 48d97ba049..4f4e45bb73 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelInputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelInputTest.java @@ -12,6 +12,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.*; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -143,7 +144,7 @@ public void constructor_SuccessWithMinimalSetup() { @Test public void testToXContent() throws Exception { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); input.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = Strings.toString(builder); @@ -159,7 +160,7 @@ public void testToXContent_Incomplete() throws Exception { input.setModelConfig(null); input.setModelFormat(null); input.setModelNodeIds(null); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); input.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelResponseTest.java index 826e4b1ac5..13e1a3bb78 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/register/MLRegisterModelResponseTest.java @@ -6,6 +6,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -43,7 +44,7 @@ public void testToXContent() throws IOException { // Setup MLRegisterModelResponse response = new MLRegisterModelResponse(taskId, status); // Run the test - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/sync/MLSyncUpResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/sync/MLSyncUpResponseTest.java index 0bb334cb43..da13327fc5 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/sync/MLSyncUpResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/sync/MLSyncUpResponseTest.java @@ -8,6 +8,7 @@ import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -42,7 +43,7 @@ public void testToXContent() throws IOException { // Setup MLSyncUpResponse response = new MLSyncUpResponse(status); // Run the test - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = org.opensearch.common.Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/task/MLTaskGetResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/task/MLTaskGetResponseTest.java index 87727186bf..007082d96e 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/task/MLTaskGetResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/task/MLTaskGetResponseTest.java @@ -7,6 +7,7 @@ import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.authuser.User; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.ml.common.dataset.MLInputDataType; @@ -69,7 +70,7 @@ public void writeTo_Success() throws IOException { @Test public void toXContentTest() throws IOException { MLTaskGetResponse mlTaskGetResponse = MLTaskGetResponse.builder().mlTask(mlTask).build(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); mlTaskGetResponse.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelInputTest.java b/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelInputTest.java index d15d53ad23..db5dd965f6 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelInputTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelInputTest.java @@ -7,6 +7,7 @@ import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.common.settings.Settings; import org.opensearch.common.xcontent.*; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -35,7 +36,7 @@ public void setUp() throws Exception { @Test public void testToXContent() throws Exception { - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); input.toXContent(builder, ToXContent.EMPTY_PARAMS); assertNotNull(builder); String jsonStr = Strings.toString(builder); diff --git a/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelNodesResponseTest.java b/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelNodesResponseTest.java index c6b1251ff5..5ea3548d30 100644 --- a/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelNodesResponseTest.java +++ b/common/src/test/java/org/opensearch/ml/common/transport/undeploy/MLUndeployModelNodesResponseTest.java @@ -14,6 +14,7 @@ import org.opensearch.common.transport.TransportAddress; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; @@ -88,7 +89,7 @@ public void testToXContent() throws IOException { List failures = new ArrayList<>(); MLUndeployModelNodesResponse response = new MLUndeployModelNodesResponse(clusterName, nodes, failures); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); response.toXContent(builder, ToXContent.EMPTY_PARAMS); String jsonStr = org.opensearch.common.Strings.toString(builder); assertEquals( diff --git a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java index 050d475dd2..94c2965c46 100644 --- a/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java +++ b/plugin/src/main/java/org/opensearch/ml/cluster/MLCommonsClusterManagerEventListener.java @@ -11,7 +11,7 @@ import org.opensearch.client.Client; import org.opensearch.cluster.LocalNodeClusterManagerListener; import org.opensearch.cluster.service.ClusterService; -import org.opensearch.common.component.LifecycleListener; +import org.opensearch.common.lifecycle.LifecycleListener; import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.ml.indices.MLIndicesHandler; diff --git a/plugin/src/test/java/org/opensearch/ml/rest/MLCommonsRestTestCase.java b/plugin/src/test/java/org/opensearch/ml/rest/MLCommonsRestTestCase.java index db083fe2fe..711f602951 100644 --- a/plugin/src/test/java/org/opensearch/ml/rest/MLCommonsRestTestCase.java +++ b/plugin/src/test/java/org/opensearch/ml/rest/MLCommonsRestTestCase.java @@ -61,10 +61,10 @@ import org.opensearch.common.settings.Settings; import org.opensearch.common.unit.TimeValue; import org.opensearch.common.util.concurrent.ThreadContext; -import org.opensearch.common.xcontent.XContentType; import org.opensearch.commons.rest.SecureRestClientBuilder; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.DeprecationHandler; +import org.opensearch.core.xcontent.MediaType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentParser; import org.opensearch.ml.common.FunctionName; @@ -198,7 +198,7 @@ protected RestClient buildClient(Settings settings, HttpHost[] hosts) throws IOE @After protected void wipeAllODFEIndices() throws IOException { Response response = adminClient().performRequest(new Request("GET", "/_cat/indices?format=json&expand_wildcards=all")); - XContentType xContentType = XContentType.fromMediaType(response.getEntity().getContentType()); + MediaType xContentType = MediaType.fromMediaType(response.getEntity().getContentType()); try ( XContentParser parser = xContentType .xContent() diff --git a/plugin/src/test/java/org/opensearch/ml/utils/IntegTestUtils.java b/plugin/src/test/java/org/opensearch/ml/utils/IntegTestUtils.java index bb942cd63e..c97994c5be 100644 --- a/plugin/src/test/java/org/opensearch/ml/utils/IntegTestUtils.java +++ b/plugin/src/test/java/org/opensearch/ml/utils/IntegTestUtils.java @@ -23,9 +23,9 @@ import org.opensearch.action.search.SearchResponse; import org.opensearch.action.support.WriteRequest; import org.opensearch.common.unit.TimeValue; -import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.rest.RestStatus; +import org.opensearch.core.xcontent.MediaTypeRegistry; import org.opensearch.core.xcontent.ToXContent; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.index.query.QueryBuilder; @@ -191,7 +191,7 @@ public static void predictAndVerifyResult(String taskId, MLInputDataset inputDat MLPredictionTaskRequest predictionRequest = new MLPredictionTaskRequest(taskId, mlInput); ActionFuture predictionFuture = client().execute(MLPredictionTaskAction.INSTANCE, predictionRequest); MLTaskResponse predictionResponse = predictionFuture.actionGet(); - XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON); + XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON); builder.startObject(); MLPredictionOutput mlPredictionOutput = (MLPredictionOutput) predictionResponse.getOutput(); mlPredictionOutput.getPredictionResult().toXContent(builder, ToXContent.EMPTY_PARAMS);