-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Rest Api Compatibility] Typed and xpack graph explore api #74185
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e95dd9c
[Rest Api Compatibility] Typed and xpack graph explore api
pgomulka c97dd78
Merge branch 'master' into compat/graph_api
elasticmachine 7fcd002
Merge remote-tracking branch 'upstream/master' into compat/graph_api
pgomulka a0925b5
code review followup. Cover all deprecated endpoints (method/path) in…
pgomulka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...n/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.graph.rest.action; | ||
|
||
import org.elasticsearch.common.bytes.BytesArray; | ||
import org.elasticsearch.common.xcontent.XContentType; | ||
import org.elasticsearch.core.RestApiVersion; | ||
import org.elasticsearch.core.Tuple; | ||
import org.elasticsearch.protocol.xpack.graph.GraphExploreRequest; | ||
import org.elasticsearch.protocol.xpack.graph.GraphExploreResponse; | ||
import org.elasticsearch.rest.RestRequest; | ||
import org.elasticsearch.test.rest.FakeRestRequest; | ||
import org.elasticsearch.test.rest.RestActionTestCase; | ||
import org.junit.Before; | ||
import org.mockito.Mockito; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.hamcrest.Matchers.instanceOf; | ||
|
||
public class RestGraphActionTests extends RestActionTestCase { | ||
private final List<String> compatibleMediaType = Collections.singletonList(randomCompatibleMediaType(RestApiVersion.V_7)); | ||
|
||
@Before | ||
public void setUpAction() { | ||
controller().registerHandler(new RestGraphAction()); | ||
verifyingClient.setExecuteVerifier((actionType, request) -> { | ||
assertThat(request, instanceOf(GraphExploreRequest.class)); | ||
return Mockito.mock(GraphExploreResponse.class); | ||
}); | ||
} | ||
|
||
public void testTypeInPath() { | ||
for (Tuple<RestRequest.Method, String> methodAndPath : | ||
List.of( | ||
Tuple.tuple(RestRequest.Method.GET, "/some_index/some_type/_graph/explore"), | ||
Tuple.tuple(RestRequest.Method.POST, "/some_index/some_type/_graph/explore"), | ||
Tuple.tuple(RestRequest.Method.GET, "/some_index/some_type/_xpack/graph/_explore"), | ||
Tuple.tuple(RestRequest.Method.POST, "/some_index/some_type/_xpack/graph/_explore") | ||
)) { | ||
|
||
RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) | ||
.withHeaders(Map.of("Accept", compatibleMediaType, "Content-Type", | ||
Collections.singletonList(compatibleMediaType(XContentType.VND_JSON, RestApiVersion.V_7)))) | ||
.withMethod(methodAndPath.v1()) | ||
.withPath(methodAndPath.v2()) | ||
.withContent(new BytesArray("{}"), null) | ||
.build(); | ||
|
||
dispatchRequest(request); | ||
assertWarnings(RestGraphAction.TYPES_DEPRECATION_MESSAGE); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a test for the
_xpath
variant as well?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point, in fact not all endpoints are correctly deprecated. /{index}/{type}/_xpack/graph/_explore api was indicating to use /{index}/{type}/_graph/explore
I will update this on 7.x and then update this PR too