|
9 | 9 |
|
10 | 10 | import org.apache.http.HttpStatus; |
11 | 11 | import org.elasticsearch.ElasticsearchException; |
| 12 | +import org.elasticsearch.client.Request; |
12 | 13 | import org.elasticsearch.client.Response; |
13 | 14 | import org.elasticsearch.common.CheckedFunction; |
14 | 15 | import org.elasticsearch.common.settings.Settings; |
@@ -128,18 +129,22 @@ private void waitForWatcher() throws Exception { |
128 | 129 | () -> "Exception when waiting for [" + template + "] template to be created"); |
129 | 130 | } |
130 | 131 |
|
131 | | - boolean existsWatcherIndex = adminClient().performRequest("HEAD", ".watches").getStatusLine().getStatusCode() == 200; |
| 132 | + boolean existsWatcherIndex = adminClient() |
| 133 | + .performRequest(new Request("HEAD", ".watches")) |
| 134 | + .getStatusLine().getStatusCode() == 200; |
132 | 135 | if (existsWatcherIndex == false) { |
133 | 136 | return; |
134 | 137 | } |
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); |
136 | 141 | ObjectPath objectPathResponse = ObjectPath.createFromResponse(response); |
137 | 142 | int totalHits = objectPathResponse.evaluate("hits.total"); |
138 | 143 | if (totalHits > 0) { |
139 | 144 | List<Map<String, Object>> hits = objectPathResponse.evaluate("hits.hits"); |
140 | 145 | for (Map<String, Object> hit : hits) { |
141 | 146 | 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)); |
143 | 148 | } |
144 | 149 | } |
145 | 150 | } |
|
0 commit comments