Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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 = XContentFactory.jsonBuilder();
if (wrapWithObject) {
builder.startObject();
}
Expand All @@ -46,7 +46,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 = XContentFactory.jsonBuilder();
obj.toXContent(builder, ToXContent.EMPTY_PARAMS);
return xContentBuilderToString(builder);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
value.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void writeToAndReadStream() throws IOException {

@Test
public void testToXContent() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
columnMeta.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
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 = XContentFactory.jsonBuilder();
builder.startObject();
defaultDataFrame.toXContent(builder);
builder.endObject();
Expand Down
Original file line number Diff line number Diff line change
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 = XContentFactory.jsonBuilder();
doubleValue.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
floatValue.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
intValue.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
longValue.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
value.toXContent(builder, ToXContent.EMPTY_PARAMS);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void select() {

@Test
public void testToXContent() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
row.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
shortValue.toXContent(builder);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = XContentFactory.jsonBuilder();
value.toXContent(builder, ToXContent.EMPTY_PARAMS);

assertNotNull(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,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 = XContentFactory.jsonBuilder();
input.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void setUp() throws Exception {

@Test
public void parseTextDocsMLInput() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
input.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
parseMLInput(jsonStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void setUp() {
}
@Test
public void toXContent() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
assertEquals("{\"task_id\":\"test_task_id\",\"status\":\"test_status\",\"prediction_result\":" +
Expand All @@ -58,7 +58,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 = XContentFactory.jsonBuilder();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
assertEquals("{}", jsonStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,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 = XContentFactory.jsonBuilder();
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 @@ -31,7 +31,7 @@ public void setUp() {

@Test
public void toXContent() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.startObject();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
Expand All @@ -42,7 +42,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 = XContentFactory.jsonBuilder();
builder.startObject();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
builder.endObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void setUp() {

@Test
public void toXContent() throws IOException {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
assertEquals("{\"sample_result\":1.0}", jsonStr);
Expand All @@ -40,7 +40,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 = XContentFactory.jsonBuilder();
output.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
assertEquals("{}", jsonStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void writeTo_Success() throws IOException {
@Test
public void toXContentTest() throws IOException {
MLConnectorGetResponse mlConnectorGetResponse = MLConnectorGetResponse.builder().mlConnector(connector).build();
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
mlConnectorGetResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void constructorMLCreateConnectorInput_NullProtocol() {

@Test
public void testToXContent_FullFields() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
mlCreateConnectorInput.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand All @@ -150,7 +150,7 @@ public void testToXContent_FullFields() throws Exception {

@Test
public void testToXContent_NullFields() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
mlCreateDryRunConnectorInput.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.opensearch.Version;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;
import org.opensearch.ml.common.FunctionName;
import org.opensearch.ml.common.MLTask;
import org.opensearch.ml.common.MLTaskState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.Strings;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.xcontent.ToXContent;
Expand Down Expand Up @@ -76,7 +76,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 = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
String jsonStr = Strings.toString(builder);
assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testToXContent() throws IOException {
// Setup
MLDeployModelResponse response = new MLDeployModelResponse(taskId, status);
// Run the test
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void toXContentTest() throws IOException {
.output(output)
.build();

XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testToXContent() throws IOException {
// Setup
MLForwardResponse response = new MLForwardResponse(status, predictionOutput);
// Run the test
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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 = XContentFactory.jsonBuilder();
mlModelGetResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void toXContentTest() throws IOException {
.output(output)
.build();

XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void constructor_SuccessWithMinimalSetup() {

@Test
public void testToXContent() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
input.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand All @@ -161,7 +161,7 @@ public void testToXContent_Incomplete() throws Exception {
input.setModelConfig(null);
input.setModelFormat(null);
input.setModelNodeIds(null);
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
input.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testToXContent() throws IOException {
// Setup
MLRegisterModelResponse response = new MLRegisterModelResponse(taskId, status);
// Run the test
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.opensearch.Version;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void testToXContent() throws IOException {
// Setup
MLSyncUpResponse response = new MLSyncUpResponse(status);
// Run the test
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
response.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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 = XContentFactory.jsonBuilder();
mlTaskGetResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void setUp() throws Exception {

@Test
public void testToXContent() throws Exception {
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
XContentBuilder builder = XContentFactory.jsonBuilder();
input.toXContent(builder, ToXContent.EMPTY_PARAMS);
assertNotNull(builder);
String jsonStr = Strings.toString(builder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.opensearch.Version;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.common.io.stream.BytesStreamOutput;
import org.opensearch.core.common.io.stream.StreamInput;
import org.opensearch.common.transport.TransportAddress;
import org.opensearch.core.common.transport.TransportAddress;

import java.io.IOException;
import java.net.InetAddress;
Expand Down
Loading