Skip to content
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

Merged
merged 1 commit into from May 29, 2015

Conversation

cbuescher
Copy link
Member

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

import java.util.HashMap;
import java.util.Map;

public class IndexRequestBuilderTest extends ElasticsearchSingleNodeTest {
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member Author

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?

Copy link
Member

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 :)

@javanna
Copy link
Member

javanna commented May 28, 2015

left one comment around testing, looks good besides that

@cbuescher
Copy link
Member Author

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.

@javanna
Copy link
Member

javanna commented May 29, 2015

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
cbuescher added a commit that referenced this pull request May 29, 2015
Fix typed parameters in IndexRequestBuilder and CreateIndexRequestBuilder
@cbuescher cbuescher merged commit 29fbcd2 into elastic:master May 29, 2015
@kevinkluge kevinkluge removed the review label May 29, 2015
@cbuescher cbuescher deleted the fix/10825 branch March 20, 2024 20:15
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.

Typed parameters in Java index API
4 participants