|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.elasticsearch.rest.action.document; |
| 21 | + |
| 22 | +import org.elasticsearch.client.node.NodeClient; |
| 23 | +import org.elasticsearch.common.settings.Settings; |
| 24 | +import org.elasticsearch.common.util.concurrent.ThreadContext; |
| 25 | +import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; |
| 26 | +import org.elasticsearch.rest.RestChannel; |
| 27 | +import org.elasticsearch.rest.RestController; |
| 28 | +import org.elasticsearch.rest.RestRequest; |
| 29 | +import org.elasticsearch.rest.RestRequest.Method; |
| 30 | +import org.elasticsearch.test.ESTestCase; |
| 31 | +import org.elasticsearch.test.rest.FakeRestChannel; |
| 32 | +import org.elasticsearch.test.rest.FakeRestRequest; |
| 33 | +import org.elasticsearch.usage.UsageService; |
| 34 | + |
| 35 | +import java.util.Collections; |
| 36 | + |
| 37 | +import static org.mockito.Mockito.mock; |
| 38 | + |
| 39 | +public class RestTermVectorsActionTests extends ESTestCase { |
| 40 | + private RestController controller; |
| 41 | + |
| 42 | + public void setUp() throws Exception { |
| 43 | + super.setUp(); |
| 44 | + controller = new RestController(Collections.emptySet(), null, |
| 45 | + mock(NodeClient.class), |
| 46 | + new NoneCircuitBreakerService(), |
| 47 | + new UsageService()); |
| 48 | + new RestTermVectorsAction(Settings.EMPTY, controller); |
| 49 | + } |
| 50 | + |
| 51 | + public void testDeprecatedEndpoint() { |
| 52 | + RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) |
| 53 | + .withMethod(Method.POST) |
| 54 | + .withPath("/some_index/some_type/some_id/_termvector") |
| 55 | + .build(); |
| 56 | + |
| 57 | + performRequest(request); |
| 58 | + assertWarnings("[POST /{index}/{type}/{id}/_termvector] is deprecated! Use" + |
| 59 | + " [POST /{index}/{type}/{id}/_termvectors] instead."); |
| 60 | + } |
| 61 | + |
| 62 | + private void performRequest(RestRequest request) { |
| 63 | + RestChannel channel = new FakeRestChannel(request, false, 1); |
| 64 | + ThreadContext threadContext = new ThreadContext(Settings.EMPTY); |
| 65 | + controller.dispatchRequest(request, channel, threadContext); |
| 66 | + } |
| 67 | +} |
0 commit comments