-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Removing isCreated and isFound from the Java API #19645
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
|
Can one of the admins verify this patch? |
|
This should be for v6 only, so we'll have to wait until we master moves to v6 |
|
If it is just the Java methods that is ok for 5.0 I think. I'll look in a On Jul 28, 2016 8:06 AM, "Clinton Gormley" notifications@github.com wrote:
|
| UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").doc("field1", "value1"); | ||
| UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); | ||
| assertThat(updateResponse.isCreated(), equalTo(false)); | ||
| assertThat(updateResponse.getOperation(), not(DocWriteResponse.Operation.CREATE)); |
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'd prefer assertEquals(DocWriteResponse.Operation.INDEX, updateResponse.getOperations());.
I prefer equality here because it is a stronger test. If we have the information we may as well use it. I don't like using Hamcrest for strait equality because it can get overly complicated and I don't mind switching the argument order to match normal junit.
|
@clintongormley this only removes these from the Java API and keeps the REST API. We've been fairly willing to make breaking changes like this in the 5.0 process in the past (like |
| UpdateRequest updateRequest = new UpdateRequest(indexOrAlias, "type", "id").upsert("field", "value").doc("field1", "value1"); | ||
| UpdateResponse updateResponse = internalCluster().coordOnlyNodeClient().update(updateRequest).actionGet(); | ||
| assertThat(updateResponse.isCreated(), equalTo(true)); | ||
| assertThat(updateResponse.getOperation(), equalTo(DocWriteResponse.Operation.CREATE)); |
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.
Personally I'd do this with assertEquals as well but you can absolutely keep this if you prefer it. We certainly don't have a standard for when hamcrest is a good idea. I expect there are folks in the Elasticsearch project who prefer hamcrest all the time so they can have consistent argument ordering. I don't, only using it for more complex assertions. But, yeah, if you like hamcrest then keep it this way.
|
It looks like we're talking about whether this should be in 6.0 or 5.0. I thought 5.0 but maybe I was wrong. If it has to wait until 6.0 that means we'll leave it stalled until we branch 5.0 from master. As far as code review, I left a few line notes:
None of these are major. The middle one'd be a fair amount of work but only if you want to do it. The non-test changes all look good to me. |
|
Another thing: can you rename The reason we want to rename it is that |
Ignore that. I'll open up another issue. I had a voice chat with a few people and I'll open up another issue. |
88f6cb5 to
1c444bc
Compare
1c444bc to
2d5a473
Compare
|
|
@nik9000 is it still a good idea to change all the hamcrest matchers to assertEquals if the other parts of the test have assertThat/equalTo? I've changed the ones where assertEquals seemed to be the majority to try and be consistent. Let me know if you want the others to be changed too? |
It is up to you. I'd do it for the lines that I touched but you certainly don't have to. |
|
OK. It looks good to me and I can merge it if @clintongormley is ok with it going into 5.0 and you ( @a2lin ) are done with it. |
|
I am done with it, but I haven't run gradle check on this yet to make sure the tests pass. |
|
I'll probably do that in about 8 hours as I'm out of morning-time :) |
|
@elasticmachine , test this |
|
Jenkins caught this: Maybe there is more, not sure. |
fb28254 to
e3450c9
Compare
|
@nik9000 I think this code should pass CI now. I've also made the assertEquals change. |
|
I've pulled this back to I'll review again. |
|
Sure, I'll give #19664 a shot. Thanks for the reviews! |
Closes #19631.
This is cleanup work from #19566, where @nik9000 suggested trying to nuke the isCreated and isFound methods. I've combined nuking the two methods with removing UpdateHelper.Operation in favor of DocWriteResponse.Operation here.