Skip to content

Commit

Permalink
Fixing string format change (#334) (opensearch-project#1946)
Browse files Browse the repository at this point in the history
* Fixing strings change from main OS repo.



* Fixing issues.



* Fixing changed syntax to toStirng.



* Fixing changed syntax to toStirng.



* add tosttring fix to RestSQLQueryActionCursorFallbackTest



* added unused function



---------

Signed-off-by: Mitchell Gale <Mitchell.Gale@improving.com>
  • Loading branch information
MitchellGale authored Aug 9, 2023
1 parent 5c91071 commit b57c50f
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@
import org.junit.Before;
import org.opensearch.client.Request;
import org.opensearch.client.Response;
import org.opensearch.common.Strings;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.rest.RestStatus;
import org.opensearch.core.xcontent.XContentBuilder;

/**
* SQL plugin integration test base class (migrated from SQLIntegTestCase)
Expand Down Expand Up @@ -164,7 +163,7 @@ protected static void updateClusterSetting(String settingKey, Object value, bool
.endObject()
.endObject();
Request request = new Request("PUT", "_cluster/settings");
request.setJsonEntity(Strings.toString(builder));
request.setJsonEntity(builder.toString());
Response response = client().performRequest(request);
Assert
.assertEquals(RestStatus.OK, RestStatus.fromCode(response.getStatusLine().getStatusCode()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.Strings;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.sql.legacy.query.planner.core.ExecuteParams;
import org.opensearch.sql.legacy.query.planner.physical.PhysicalOperator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import org.opensearch.action.search.ClearScrollResponse;
import org.opensearch.action.search.SearchResponse;
import org.opensearch.client.Client;
import org.opensearch.common.Strings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.Strings;
import org.opensearch.index.query.BoolQueryBuilder;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.search.SearchHit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import com.fasterxml.jackson.core.JsonFactory;
import java.io.IOException;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.common.xcontent.json.JsonXContentParser;
Expand Down Expand Up @@ -37,7 +36,7 @@ public static String format(String jsonString) throws IOException {
){
contentBuilder.copyCurrentStructure(contentParser);
}
return Strings.toString(contentBuilder);
return contentBuilder.toString();
}

private JsonPrettyFormatter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.Strings;
import org.opensearch.common.inject.Injector;
import org.opensearch.common.inject.ModulesBuilder;
import org.opensearch.common.util.concurrent.ThreadContext;
Expand Down Expand Up @@ -96,7 +95,7 @@ private static SQLQueryRequest createSqlQueryRequest(String query, Optional<Stri
builder.field("fetch_size").value(fetchSize.get());
}
builder.endObject();
JSONObject jsonContent = new JSONObject(Strings.toString(builder));
JSONObject jsonContent = new JSONObject(builder.toString());

return new SQLQueryRequest(jsonContent, query, QUERY_API_ENDPOINT,
Map.of("format", "jdbc"), cursorId.orElse(""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.opensearch.client.Client;
import org.opensearch.common.Strings;
import org.opensearch.common.xcontent.XContentType;
import org.opensearch.core.common.Strings;
import org.opensearch.index.query.AbstractQueryBuilder;
import org.opensearch.index.query.MultiMatchQueryBuilder;
import org.opensearch.search.builder.SearchSourceBuilder.ScriptField;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.opensearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
import org.opensearch.client.Requests;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.Strings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.xcontent.XContentFactory;
import org.opensearch.core.xcontent.XContentBuilder;
Expand Down Expand Up @@ -109,7 +108,7 @@ private Settings getAndFilterSettings(Map<String, ?> source) {
XContentBuilder builder = XContentFactory.jsonBuilder();
builder.map(source);
Settings.Builder settingsBuilder = Settings.builder()
.loadFromSource(Strings.toString(builder), builder.contentType());
.loadFromSource(builder.toString(), builder.contentType());
settingsBuilder.keys().removeIf(key -> {
for (String prefix : SETTINGS_PREFIX) {
if (key.startsWith(prefix)) {
Expand Down

0 comments on commit b57c50f

Please sign in to comment.