|
6 | 6 | package org.elasticsearch.xpack.core.ml.integration;
|
7 | 7 |
|
8 | 8 | import org.apache.logging.log4j.Logger;
|
9 |
| -import org.elasticsearch.client.Request; |
10 |
| -import org.elasticsearch.client.Response; |
11 | 9 | import org.elasticsearch.client.RestClient;
|
12 | 10 | import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
13 | 11 | import org.elasticsearch.test.rest.ESRestTestCase;
|
@@ -37,12 +35,9 @@ public void clearMlMetadata() throws IOException {
|
37 | 35 |
|
38 | 36 | @SuppressWarnings("unchecked")
|
39 | 37 | private void deleteAllDatafeeds() throws IOException {
|
40 |
| - final Request datafeedsRequest = new Request("GET", "/_xpack/ml/datafeeds"); |
41 |
| - datafeedsRequest.addParameter("filter_path", "datafeeds"); |
42 |
| - final Response datafeedsResponse = adminClient.performRequest(datafeedsRequest); |
43 |
| - @SuppressWarnings("unchecked") |
| 38 | + final Map<String, Object> datafeedsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/datafeeds")); |
44 | 39 | final List<Map<String, Object>> datafeeds =
|
45 |
| - (List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", testCase.entityAsMap(datafeedsResponse)); |
| 40 | + (List<Map<String, Object>>) XContentMapValues.extractValue("datafeeds", datafeedsAsMap); |
46 | 41 | if (datafeeds == null) {
|
47 | 42 | return;
|
48 | 43 | }
|
@@ -79,12 +74,10 @@ private void deleteAllDatafeeds() throws IOException {
|
79 | 74 | }
|
80 | 75 |
|
81 | 76 | private void deleteAllJobs() throws IOException {
|
82 |
| - final Request jobsRequest = new Request("GET", "/_xpack/ml/anomaly_detectors"); |
83 |
| - jobsRequest.addParameter("filter_path", "jobs"); |
84 |
| - final Response response = adminClient.performRequest(jobsRequest); |
| 77 | + final Map<String, Object> jobsAsMap = testCase.entityAsMap(adminClient.performRequest("GET", "/_xpack/ml/anomaly_detectors")); |
85 | 78 | @SuppressWarnings("unchecked")
|
86 | 79 | final List<Map<String, Object>> jobConfigs =
|
87 |
| - (List<Map<String, Object>>) XContentMapValues.extractValue("jobs", testCase.entityAsMap(response)); |
| 80 | + (List<Map<String, Object>>) XContentMapValues.extractValue("jobs", jobsAsMap); |
88 | 81 | if (jobConfigs == null) {
|
89 | 82 | return;
|
90 | 83 | }
|
|
0 commit comments