Skip to content

Commit 3e217dc

Browse files
committed
Switch x-pack/plugin to new style Requests (#32327)
In #29623 we added `Request` object flavored requests to the low level REST client and in #30315 we deprecated the old `performRequest`s. This changes all calls in the `x-pack/plugin` project to use the new versions.
1 parent 17361dc commit 3e217dc

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

x-pack/plugin/src/test/java/org/elasticsearch/xpack/test/rest/XPackRestIT.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
99
import org.apache.http.HttpStatus;
1010
import org.elasticsearch.ElasticsearchException;
11+
import org.elasticsearch.client.Request;
1112
import org.elasticsearch.client.Response;
1213
import org.elasticsearch.common.CheckedFunction;
13-
import org.elasticsearch.common.collect.MapBuilder;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.common.util.concurrent.ThreadContext;
1616
import org.elasticsearch.common.xcontent.support.XContentMapValues;
@@ -128,15 +128,17 @@ private void waitForWatcher() throws Exception {
128128
() -> "Exception when waiting for [" + template + "] template to be created");
129129
}
130130

131-
Map<String, String> params = MapBuilder.<String, String>newMapBuilder().put("size", "1000").put("ignore", "404").map();
132-
Response response = adminClient().performRequest("GET", ".watches/_search", params);
131+
Request searchWatchesRequest = new Request("GET", ".watches/_search");
132+
searchWatchesRequest.addParameter("size", "1000");
133+
searchWatchesRequest.addParameter("ignore", "404");
134+
Response response = adminClient().performRequest(searchWatchesRequest);
133135
ObjectPath objectPathResponse = ObjectPath.createFromResponse(response);
134136
Integer totalHits = objectPathResponse.evaluate("hits.total");
135137
if (totalHits != null && totalHits > 0) {
136138
List<Map<String, Object>> hits = objectPathResponse.evaluate("hits.hits");
137139
for (Map<String, Object> hit : hits) {
138140
String id = (String) hit.get("_id");
139-
assertOK(adminClient().performRequest("DELETE", "_xpack/watcher/watch/" + id));
141+
adminClient().performRequest(new Request("DELETE", "_xpack/watcher/watch/" + id));
140142
}
141143
}
142144
}

0 commit comments

Comments
 (0)