-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add fromxcontent methods to delete response #22680
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
Conversation
tlrx
left a comment
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.
This looks good, it's indeed very similar to IndexResponse/IndexResponseTests.
I'd like to merge #22586 before this go in, so that we can mutualize some code in the tests. There will be a light modification in the ConstructingObjectParser as well but nothing big.
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.
You can remove this comment
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.
I'm about to change this in #22586 so that DeleteResponse/IndexResponse/UpdateResponse don't have to repeat all these checks. There will be a assertDocWriteResponse() method, and here we only have to check for UpdateResponse specific fields.
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.
found?
This commit adds the parsing fromXContent() methods to the IndexResponse class. It's a pale copy of what has been done in elastic#22229.
1453094 to
0315dcc
Compare
|
@tlrx updated based on new changes and your comments |
tlrx
left a comment
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.
Thanks @dadoonet! This is getting very close, I just left a last comment.
| // Print the parsed object out and test that the output is the same as the original output | ||
| BytesReference parsedDeleteResponseBytes = toXContent(parsedDeleteResponse, xContentType); | ||
| try (XContentParser parser = createParser(xContentType.xContent(), parsedDeleteResponseBytes)) { | ||
| assertDocWriteResponse(deleteResponse, parser.map()); |
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.
You still need to check the parsed value of the found field, right?
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.
ha right!
And optimize imports
|
@tlrx updated with your comments. |
|
Thank you Tanguy! |
This commit adds the parsing fromXContent() methods to the DeleteResponse class. The method is based on a ObjectParser because it is easier to use when parsing parent abstract classes like DocWriteResponse. It also changes the ReplicationResponse.ShardInfo so that it now implements ToXContentObject. This way, the ShardInfo.fromXContent() method can be used by the DeleteResponse's ObjectParser. Backport of elastic#22680 in 5.x branch
This commit adds the parsing fromXContent() methods to the IndexResponse class.
It's a pale copy of what has been done in #22229.
There are a lot of code in common between IndexResponse and DeleteResponse including in tests.
Do we want to keep it as it is or avoid code duplication?