Small improvements related to types deprecation. (#36328)
* Make sure to use deprecatedAndMaybeLog for types deprecation messages. * Introduce a common base class for Rest*Action tests.
This commit is contained in:
parent
5556204f81
commit
51e1d40dca
|
@ -89,7 +89,8 @@ public class RestMultiSearchTemplateAction extends BaseRestHandler {
|
|||
RestMultiSearchAction.parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex,
|
||||
(searchRequest, bytes) -> {
|
||||
if (searchRequest.types().length > 0) {
|
||||
deprecationLogger.deprecated(RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_template_with_types",
|
||||
RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
SearchTemplateRequest searchTemplateRequest = SearchTemplateRequest.fromXContent(bytes);
|
||||
if (searchTemplateRequest.getScript() != null) {
|
||||
|
|
|
@ -626,7 +626,8 @@ public class TermVectorsRequest extends SingleShardRequest<TermVectorsRequest> i
|
|||
termVectorsRequest.index = parser.text();
|
||||
} else if (TYPE.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||
termVectorsRequest.type = parser.text();
|
||||
deprecationLogger.deprecated(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("termvectors_with_types",
|
||||
RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
|
||||
} else if (ID.match(currentFieldName, parser.getDeprecationHandler())) {
|
||||
if (termVectorsRequest.doc != null) {
|
||||
throw new ElasticsearchParseException("failed to parse term vectors request. " +
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RestValidateQueryAction extends BaseRestHandler {
|
|||
validateQueryRequest.explain(request.paramAsBoolean("explain", false));
|
||||
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("validate_query_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
validateQueryRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RestDeleteAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
String type = request.param("type");
|
||||
if (!type.equals(MapperService.SINGLE_MAPPING_NAME)) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("delete_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
DeleteRequest deleteRequest = new DeleteRequest(request.param("index"), type, request.param("id"));
|
||||
|
|
|
@ -65,7 +65,7 @@ public class RestMultiTermVectorsAction extends BaseRestHandler {
|
|||
.index(request.param("index"));
|
||||
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("mtermvectors_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
template.type(request.param("type"));
|
||||
} else {
|
||||
template.type(MapperService.SINGLE_MAPPING_NAME);
|
||||
|
|
|
@ -74,7 +74,7 @@ public class RestTermVectorsAction extends BaseRestHandler {
|
|||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||
TermVectorsRequest termVectorsRequest;
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("termvectors_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
termVectorsRequest = new TermVectorsRequest(request.param("index"),
|
||||
request.param("type"),
|
||||
request.param("id"));
|
||||
|
|
|
@ -89,7 +89,7 @@ public class RestCountAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("count_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
countRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class RestMultiSearchAction extends BaseRestHandler {
|
|||
|
||||
parseMultiLineRequest(restRequest, multiRequest.indicesOptions(), allowExplicitIndex, (searchRequest, parser) -> {
|
||||
if (searchRequest.types().length > 0) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("msearch_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
searchRequest.source(SearchSourceBuilder.fromXContent(parser, false));
|
||||
multiRequest.add(searchRequest);
|
||||
|
|
|
@ -164,7 +164,7 @@ public class RestSearchAction extends BaseRestHandler {
|
|||
}
|
||||
|
||||
if (request.hasParam("type")) {
|
||||
deprecationLogger.deprecated(TYPES_DEPRECATION_MESSAGE);
|
||||
deprecationLogger.deprecatedAndMaybeLog("search_with_types", TYPES_DEPRECATION_MESSAGE);
|
||||
searchRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
|
||||
}
|
||||
searchRequest.routing(request.param("routing"));
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.rest.action;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* A common base class for Rest*ActionTests. Provides access to a {@link RestController}
|
||||
* that can be used to register individual REST actions, and test request handling.
|
||||
*/
|
||||
public abstract class RestActionTestCase extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
@Before
|
||||
public void setUpController() {
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
}
|
||||
|
||||
/**
|
||||
* A test {@link RestController}. This controller can be used to register and delegate
|
||||
* to handlers, but uses a mock client and cannot carry out the full request.
|
||||
*/
|
||||
protected RestController controller() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the given request to the test controller in {@link #controller()}.
|
||||
*/
|
||||
protected void dispatchRequest(RestRequest request) {
|
||||
FakeRestChannel channel = new FakeRestChannel(request, false, 1);
|
||||
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
|
||||
controller.dispatchRequest(request, channel, threadContext);
|
||||
}
|
||||
}
|
|
@ -19,33 +19,18 @@
|
|||
|
||||
package org.elasticsearch.rest.action.document;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestRequest.Method;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
||||
public class RestDeleteActionTests extends RestActionTestCase {
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
public class RestDeleteActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestDeleteAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestDeleteAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -53,19 +38,13 @@ public class RestDeleteActionTests extends ESTestCase {
|
|||
.withMethod(Method.DELETE)
|
||||
.withPath("/some_index/some_type/some_id")
|
||||
.build();
|
||||
performRequest(deprecatedRequest);
|
||||
dispatchRequest(deprecatedRequest);
|
||||
assertWarnings(RestDeleteAction.TYPES_DEPRECATION_MESSAGE);
|
||||
|
||||
RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry())
|
||||
.withMethod(Method.DELETE)
|
||||
.withPath("/some_index/_doc/some_id")
|
||||
.build();
|
||||
performRequest(validRequest);
|
||||
}
|
||||
|
||||
private void performRequest(RestRequest request) {
|
||||
RestChannel channel = new FakeRestChannel(request, false, 1);
|
||||
ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
|
||||
controller.dispatchRequest(request, channel, threadContext);
|
||||
dispatchRequest(validRequest);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,40 +19,26 @@
|
|||
|
||||
package org.elasticsearch.rest.action.document;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
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.rest.RestRequest.Method;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
public class RestMultiTermVectorsActionTests extends RestActionTestCase {
|
||||
|
||||
public class RestMultiTermVectorsActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestMultiTermVectorsAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestMultiTermVectorsAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -61,7 +47,7 @@ public class RestMultiTermVectorsActionTests extends ESTestCase {
|
|||
.withPath("/some_index/some_type/_mtermvectors")
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestMultiTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -75,7 +61,7 @@ public class RestMultiTermVectorsActionTests extends ESTestCase {
|
|||
.withParams(params)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestMultiTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -95,13 +81,7 @@ public class RestMultiTermVectorsActionTests extends ESTestCase {
|
|||
.withContent(BytesReference.bytes(content), XContentType.JSON)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestTermVectorsAction.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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,38 +19,24 @@
|
|||
|
||||
package org.elasticsearch.rest.action.document;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
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.rest.RestRequest.Method;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
public class RestTermVectorsActionTests extends RestActionTestCase {
|
||||
|
||||
public class RestTermVectorsActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestTermVectorsAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestTermVectorsAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -59,7 +45,7 @@ public class RestTermVectorsActionTests extends ESTestCase {
|
|||
.withPath("/some_index/some_type/some_id/_termvectors")
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestTermVectorsAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -75,13 +61,7 @@ public class RestTermVectorsActionTests extends ESTestCase {
|
|||
.withContent(BytesReference.bytes(content), XContentType.JSON)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestTermVectorsAction.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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,35 +19,21 @@
|
|||
|
||||
package org.elasticsearch.rest.action.search;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.rest.RestRequest.Method;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
public class RestCountActionTests extends RestActionTestCase {
|
||||
|
||||
public class RestCountActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestCountAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestCountAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -56,7 +42,7 @@ public class RestCountActionTests extends ESTestCase {
|
|||
.withPath("/some_index/some_type/_count")
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestCountAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -70,13 +56,7 @@ public class RestCountActionTests extends ESTestCase {
|
|||
.withParams(params)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestCountAction.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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,35 +19,21 @@
|
|||
|
||||
package org.elasticsearch.rest.action.search;
|
||||
|
||||
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.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
public class RestMultiSearchActionTests extends RestActionTestCase {
|
||||
|
||||
public class RestMultiSearchActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestMultiSearchAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestMultiSearchAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -60,7 +46,7 @@ public class RestMultiSearchActionTests extends ESTestCase {
|
|||
.withContent(bytesContent, XContentType.JSON)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestMultiSearchAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -74,13 +60,7 @@ public class RestMultiSearchActionTests extends ESTestCase {
|
|||
.withContent(bytesContent, XContentType.JSON)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestMultiSearchAction.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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,34 +19,20 @@
|
|||
|
||||
package org.elasticsearch.rest.action.search;
|
||||
|
||||
import org.elasticsearch.client.node.NodeClient;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadContext;
|
||||
import org.elasticsearch.indices.breaker.NoneCircuitBreakerService;
|
||||
import org.elasticsearch.rest.RestChannel;
|
||||
import org.elasticsearch.rest.RestController;
|
||||
import org.elasticsearch.rest.RestRequest;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestChannel;
|
||||
import org.elasticsearch.rest.action.RestActionTestCase;
|
||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
||||
import org.elasticsearch.usage.UsageService;
|
||||
import org.junit.Before;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
public class RestSearchActionTests extends RestActionTestCase {
|
||||
|
||||
public class RestSearchActionTests extends ESTestCase {
|
||||
private RestController controller;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
controller = new RestController(Collections.emptySet(), null,
|
||||
mock(NodeClient.class),
|
||||
new NoneCircuitBreakerService(),
|
||||
new UsageService());
|
||||
new RestSearchAction(Settings.EMPTY, controller);
|
||||
@Before
|
||||
public void setUpAction() {
|
||||
new RestSearchAction(Settings.EMPTY, controller());
|
||||
}
|
||||
|
||||
public void testTypeInPath() {
|
||||
|
@ -55,7 +41,7 @@ public class RestSearchActionTests extends ESTestCase {
|
|||
.withPath("/some_index/some_type/_search")
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestSearchAction.TYPES_DEPRECATION_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -69,13 +55,7 @@ public class RestSearchActionTests extends ESTestCase {
|
|||
.withParams(params)
|
||||
.build();
|
||||
|
||||
performRequest(request);
|
||||
dispatchRequest(request);
|
||||
assertWarnings(RestSearchAction.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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue