From b70c9d711cc30884294a6df8a8f682e39d9d4c78 Mon Sep 17 00:00:00 2001 From: Khushboo Rajput Date: Tue, 28 Mar 2023 17:00:38 -0700 Subject: [PATCH] Fixing xcontent imports in Tests Signed-off-by: Khushboo Rajput --- .../PerformanceAnalyzerClusterConfigActionTests.java | 7 +++++-- .../config/PerformanceAnalyzerConfigActionTests.java | 7 +++++-- ...rformanceAnalyzerOverridesClusterConfigActionTests.java | 2 +- .../http_action/whoami/WhoAmITests.java | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerClusterConfigActionTests.java b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerClusterConfigActionTests.java index 3f890d09..f53155dc 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerClusterConfigActionTests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerClusterConfigActionTests.java @@ -21,9 +21,10 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentFactory; import org.opensearch.indices.breaker.BreakerSettings; import org.opensearch.indices.breaker.CircuitBreakerService; import org.opensearch.indices.breaker.HierarchyCircuitBreakerService; @@ -178,7 +179,9 @@ private FakeRestRequest buildRequest(String requestPath) throws IOException { return new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) .withMethod(RestRequest.Method.POST) .withPath(requestPath) - .withContent(BytesReference.bytes(builder), builder.contentType()) + .withContent( + BytesReference.bytes(builder), + XContentType.fromMediaType(builder.contentType())) .build(); } } diff --git a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerConfigActionTests.java b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerConfigActionTests.java index d8563880..1d251846 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerConfigActionTests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerConfigActionTests.java @@ -22,9 +22,10 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.common.xcontent.XContentFactory; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentFactory; import org.opensearch.indices.breaker.BreakerSettings; import org.opensearch.indices.breaker.CircuitBreakerService; import org.opensearch.indices.breaker.HierarchyCircuitBreakerService; @@ -310,7 +311,9 @@ private FakeRestRequest buildRequest(String requestPath, boolean shouldEnable) return new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY) .withMethod(RestRequest.Method.POST) .withPath(requestPath) - .withContent(BytesReference.bytes(builder), builder.contentType()) + .withContent( + BytesReference.bytes(builder), + XContentType.fromMediaType(builder.contentType())) .build(); } } diff --git a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerOverridesClusterConfigActionTests.java b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerOverridesClusterConfigActionTests.java index b1819e4b..df2fb2c2 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerOverridesClusterConfigActionTests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/http_action/config/PerformanceAnalyzerOverridesClusterConfigActionTests.java @@ -22,8 +22,8 @@ import org.opensearch.common.settings.ClusterSettings; import org.opensearch.common.settings.Settings; import org.opensearch.common.util.concurrent.ThreadContext; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.NamedXContentRegistry; -import org.opensearch.core.xcontent.XContentType; import org.opensearch.indices.breaker.BreakerSettings; import org.opensearch.indices.breaker.CircuitBreakerService; import org.opensearch.indices.breaker.HierarchyCircuitBreakerService; diff --git a/src/test/java/org/opensearch/performanceanalyzer/http_action/whoami/WhoAmITests.java b/src/test/java/org/opensearch/performanceanalyzer/http_action/whoami/WhoAmITests.java index 37adec03..5aa5dd0f 100644 --- a/src/test/java/org/opensearch/performanceanalyzer/http_action/whoami/WhoAmITests.java +++ b/src/test/java/org/opensearch/performanceanalyzer/http_action/whoami/WhoAmITests.java @@ -18,8 +18,8 @@ import org.opensearch.action.ActionListener; import org.opensearch.action.support.ActionFilters; import org.opensearch.common.io.stream.Writeable.Reader; +import org.opensearch.common.xcontent.XContentType; import org.opensearch.core.xcontent.XContentBuilder; -import org.opensearch.core.xcontent.XContentType; import org.opensearch.indices.IndicesService; import org.opensearch.performanceanalyzer.OpenSearchResources; import org.opensearch.tasks.Task;