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
Fix typed parameters in IndexRequestBuilder and CreateIndexRequestBuilder #11382
Conversation
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class IndexRequestBuilderTest extends ElasticsearchSingleNodeTest { |
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.
do we really need a node here? I don't think we are sending any request? Should it just extend ElasticsearchTestCase
?
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 had problems creating empty IndexRequestBuilder without a client (IndexRequestBuilder(ElasticsearchClient client, IndexAction action)
), if there's any dummy client implementation I can pass in there that would probably possible. Used the ElasticsearchSingleNodeTest because of its handy creation of the IndexRequestBuilder. Will dig around a but if I find other solutions. Let me know if you have an idea.
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 found a workaround using an inner DummyClient implements ElasticsearchClient
class, but that bloats the test. It's really fast though. Would be an ideal use case for Mockito or Jmock, not sure if I already asked around if we can use that in core?
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 think we have at least one similar test that does the same, we can maybe share the dummy client to minimize the code repetition. It's not that we cannot use mockito, we could, we would need to have a bigger discussion around it, some people are in favour of that and some others are totally against it. I personally don't think mockito would solve all our problems, we should strive to make elasticsearch more unit testable, easier to say that to do though :)
left one comment around testing, looks good besides that |
I changed the tests to use an existing NoOpClient to make it a proper unit test case. To facilitate that I moved the formerly private test client to its own class alongside the original test it came from. This way I can use it in my own test setup. |
looks great thanks a lot @cbuescher |
…lder IndexRequestBuilder#setSource as well as CreateIndexRequestBuilder#setSettings and CreateIndexRequestBuilder#setSouce() will not work with Map<String, String> argument although the API looks like it should. This PR fixes the problem introducing correct wildcard parameters and adds tests. Closes elastic#10825
Fix typed parameters in IndexRequestBuilder and CreateIndexRequestBuilder
IndexRequestBuilder#setSource as well as CreateIndexRequestBuilder#setSettings and CreateIndexRequestBuilder#setSouce will not work with
Map<String, String>
argument although the API looks like it should. This PR fixes the problem introducing correct wildcard parameters and adds tests.Closes #10825