|
@@ -27,7 +27,10 @@ import org.elasticsearch.action.support.TransportAction;
|
|
|
import org.elasticsearch.client.node.NodeClient;
|
|
|
import org.elasticsearch.common.bytes.BytesArray;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
+import org.elasticsearch.common.util.concurrent.ThreadContext;
|
|
|
import org.elasticsearch.common.xcontent.XContentType;
|
|
|
+import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
|
|
+import org.elasticsearch.rest.RestChannel;
|
|
|
import org.elasticsearch.rest.RestController;
|
|
|
import org.elasticsearch.rest.RestRequest;
|
|
|
import org.elasticsearch.search.AbstractSearchTestCase;
|
|
@@ -56,7 +59,8 @@ public class RestValidateQueryActionTests extends AbstractSearchTestCase {
|
|
|
private static NodeClient client = new NodeClient(Settings.EMPTY, threadPool);
|
|
|
|
|
|
private static UsageService usageService = new UsageService();
|
|
|
- private static RestController controller = new RestController(emptySet(), null, client, null, usageService);
|
|
|
+ private static RestController controller = new RestController(emptySet(), null, client,
|
|
|
+ new NoneCircuitBreakerService(), usageService);
|
|
|
private static RestValidateQueryAction action = new RestValidateQueryAction(Settings.EMPTY, controller);
|
|
|
|
|
|
/**
|
|
@@ -148,4 +152,33 @@ public class RestValidateQueryActionTests extends AbstractSearchTestCase {
|
|
|
.withContent(new BytesArray(content), XContentType.JSON)
|
|
|
.build();
|
|
|
}
|
|
|
+
|
|
|
+ public void testTypeInPath() {
|
|
|
+ RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
|
|
|
+ .withMethod(RestRequest.Method.GET)
|
|
|
+ .withPath("/some_index/some_type/_validate/query")
|
|
|
+ .build();
|
|
|
+
|
|
|
+ performRequest(request);
|
|
|
+ assertWarnings(RestValidateQueryAction.TYPES_DEPRECATION_MESSAGE);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void testTypeParameter() {
|
|
|
+ Map<String, String> params = new HashMap<>();
|
|
|
+ params.put("type", "some_type");
|
|
|
+ RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
|
|
|
+ .withMethod(RestRequest.Method.GET)
|
|
|
+ .withPath("_validate/query")
|
|
|
+ .withParams(params)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ performRequest(request);
|
|
|
+ assertWarnings(RestValidateQueryAction.TYPES_DEPRECATION_MESSAGE);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void performRequest(RestRequest request) {
|
|
|
+ RestChannel channel = new FakeRestChannel(request, false, 1);
|
|
|
+ ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
|
|
|
+ controller.dispatchRequest(request, channel, threadContext);
|
|
|
+ }
|
|
|
}
|