From 061284043d3e5a0fe9fc47b28671078ec04f5d35 Mon Sep 17 00:00:00 2001 From: Mitchell Gale Date: Wed, 9 Aug 2023 08:59:24 -0700 Subject: [PATCH] Fixing string format change (#334) (#1943) * 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 --- .../test/java/org/opensearch/sql/legacy/RestIntegTestCase.java | 3 +-- .../legacy/query/planner/physical/node/join/BlockHashJoin.java | 2 +- .../sql/legacy/query/planner/physical/node/scroll/Scroll.java | 2 +- .../org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java | 3 +-- .../legacy/plugin/RestSQLQueryActionCursorFallbackTest.java | 3 +-- .../org/opensearch/sql/legacy/unittest/QueryFunctionsTest.java | 2 +- .../opensearch/sql/plugin/rest/RestQuerySettingsAction.java | 3 +-- 7 files changed, 7 insertions(+), 11 deletions(-) diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java index 50440facb6..dd48d82114 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/RestIntegTestCase.java @@ -44,7 +44,6 @@ import org.junit.Before; import org.opensearch.client.Request; import org.opensearch.client.Response; -import org.opensearch.common.Strings; import org.opensearch.common.xcontent.XContentFactory; import org.opensearch.core.rest.RestStatus; import org.opensearch.core.xcontent.XContentBuilder; @@ -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())); diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java index cfb6265e52..19c0ae41d2 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/join/BlockHashJoin.java @@ -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; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java index 840acb1b17..2d781d7c3d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/planner/physical/node/scroll/Scroll.java @@ -12,9 +12,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; diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java index 827f968bde..ecc86877ee 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/utils/JsonPrettyFormatter.java @@ -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; @@ -37,7 +36,7 @@ public static String format(String jsonString) throws IOException { ){ contentBuilder.copyCurrentStructure(contentParser); } - return Strings.toString(contentBuilder); + return contentBuilder.toString(); } private JsonPrettyFormatter() { diff --git a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java index 2afcdc93f4..64e5d161b7 100644 --- a/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java +++ b/legacy/src/test/java/org/opensearch/sql/legacy/plugin/RestSQLQueryActionCursorFallbackTest.java @@ -20,7 +20,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; @@ -93,7 +92,7 @@ private static SQLQueryRequest createSqlQueryRequest(String query, Optional 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)) {