-
Notifications
You must be signed in to change notification settings - Fork 25k
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
improve FetchSourceContext and add unit tests #77346
improve FetchSourceContext and add unit tests #77346
Conversation
@nik9000 can you help to review this PR? |
Pinging @elastic/es-search (Team:Search) |
public class FetchSourceContextTests extends AbstractSerializingTestCase<FetchSourceContext> { | ||
@Override | ||
protected FetchSourceContext doParseInstance(XContentParser parser) throws IOException { | ||
return FetchSourceContext.fromXContent(parser); |
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.
When I wrote some tests that recently had the NPE on this sort of thing I would do:
ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
FetchSourceContext result = FetchSourceContext.fromXContent(parser);
ensureExpectedToken(XContentParser.Token.END_OBJECT, parser.nextToken(), parser);
return parser;
That way I don't have to modify the production code for the test. I think it's probably the right thing to do here too.
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.
if fetchSource equals false, the XContent is not object, nor json, it is a value of false.
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.
Indeed it does!
@elasticmachine, test this please |
@elasticmachine, update branch |
@elasticmachine pdate branch |
@elasticmachine update branch |
@elasticmachine, test this please |
Good bot. |
Thanks @weizijun! I'll backport this to 7.x now. |
Co-authored-by: Elastic Machine <[email protected]>
Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: weizijun <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
improve FetchSourceContext and add unit tests