Skip to content

Conversation

@dadoonet
Copy link
Contributor

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?

Copy link
Member

@tlrx tlrx left a 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.

Copy link
Member

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

Copy link
Member

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.

Copy link
Member

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.
@dadoonet dadoonet force-pushed the pr/delete-from-xcontent branch from 1453094 to 0315dcc Compare January 19, 2017 15:09
@dadoonet
Copy link
Contributor Author

@tlrx updated based on new changes and your comments

Copy link
Member

@tlrx tlrx left a 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());
Copy link
Member

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?

Copy link
Contributor Author

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
@dadoonet
Copy link
Contributor Author

@tlrx updated with your comments.

@dadoonet dadoonet merged commit 5be8bd7 into elastic:master Jan 20, 2017
@dadoonet dadoonet deleted the pr/delete-from-xcontent branch January 20, 2017 08:29
@dadoonet
Copy link
Contributor Author

Thank you Tanguy!

dadoonet added a commit to dadoonet/elasticsearch that referenced this pull request Jan 20, 2017
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
@dadoonet dadoonet removed the v5.3.0 label Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants