Skip to content

Commit

Permalink
Fix compilation errors after recent core pushes
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Gaievski <gaievski@amazon.com>
  • Loading branch information
martin-gaievski committed Aug 1, 2023
1 parent 6bfc1d3 commit fe80f66
Show file tree
Hide file tree
Showing 33 changed files with 70 additions and 52 deletions.
5 changes: 3 additions & 2 deletions common/src/test/java/org/opensearch/ml/common/TestHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +28,7 @@ public static <T> void testParse(ToXContentObject obj, Function<XContentParser,

public static <T> void testParse(ToXContentObject obj, Function<XContentParser, T> function, boolean wrapWithObject)
throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = MediaTypeRegistry.contentBuilder(XContentType.JSON);
if (wrapWithObject) {
builder.startObject();
}
Expand All @@ -49,7 +50,7 @@ public static <T> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -147,7 +148,7 @@ public void parse_TextEmbedding_NullResultFilter() throws IOException {
private void testParse(FunctionName algorithm, MLInputDataset inputDataset, String expectedInputStr,
Consumer<MLInput> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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\":" +
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -73,7 +73,7 @@ public void testToXContent() throws IOException {

List<FailedNodeException> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit fe80f66

Please sign in to comment.