Skip to content

Commit 643235d

Browse files
authored
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 7ad16ff commit 643235d

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.apache.http.HttpStatus;
1111
import org.elasticsearch.ElasticsearchException;
12+
import org.elasticsearch.client.Request;
1213
import org.elasticsearch.client.Response;
1314
import org.elasticsearch.common.CheckedFunction;
1415
import org.elasticsearch.common.settings.Settings;
@@ -128,18 +129,22 @@ private void waitForWatcher() throws Exception {
128129
() -> "Exception when waiting for [" + template + "] template to be created");
129130
}
130131

131-
boolean existsWatcherIndex = adminClient().performRequest("HEAD", ".watches").getStatusLine().getStatusCode() == 200;
132+
boolean existsWatcherIndex = adminClient()
133+
.performRequest(new Request("HEAD", ".watches"))
134+
.getStatusLine().getStatusCode() == 200;
132135
if (existsWatcherIndex == false) {
133136
return;
134137
}
135-
Response response = adminClient().performRequest("GET", ".watches/_search", Collections.singletonMap("size", "1000"));
138+
Request searchWatchesRequest = new Request("GET", ".watches/_search");
139+
searchWatchesRequest.addParameter("size", "1000");
140+
Response response = adminClient().performRequest(searchWatchesRequest);
136141
ObjectPath objectPathResponse = ObjectPath.createFromResponse(response);
137142
int totalHits = objectPathResponse.evaluate("hits.total");
138143
if (totalHits > 0) {
139144
List<Map<String, Object>> hits = objectPathResponse.evaluate("hits.hits");
140145
for (Map<String, Object> hit : hits) {
141146
String id = (String) hit.get("_id");
142-
assertOK(adminClient().performRequest("DELETE", "_xpack/watcher/watch/" + id));
147+
adminClient().performRequest(new Request("DELETE", "_xpack/watcher/watch/" + id));
143148
}
144149
}
145150
}

0 commit comments

Comments
 (0)