-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Increase code coverage for DirectDruidClientTest
#18861
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
Replaces mocks with more concrete test helpers that will invoke and exercise the internals of DirectDruidClient response handler, etc. Also, add a new unit test for ResourceExceededException that wasn't previously exercised.
jtuglu1
left a comment
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.
LGTM – once the minor comments are handled.
| return initHttpClientWithFuture(new TestHttpClient(objectMapper, future), false); | ||
| } | ||
|
|
||
| private HttpClient initHttpClientWithFuture(TestHttpClient httpClient, boolean throwQueryError) |
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.
can we name this something different? It has the same name as the above method but different signature. Maybe something like initHttpClientFromExistingClient.
| } | ||
|
|
||
| @Test | ||
| public void testQueryTimeoutBeforeFuture() throws IOException, InterruptedException |
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.
Removing the mocks I believe removes InterruptedException – let's clean that up too while we're here.
Come to think of it, I'm not quite sure why a linter wouldn't catch this. We should add this as a rule.
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.
Removed InterruptedException from this test method.
Come to think of it, I'm not quite sure why a linter wouldn't catch this. We should add this as a rule.
hmm, I vaguely recall that we did have IntelliJ checks to catch this kind of issue, but they were removed at some point. I'm not sure if pmc/checkstyle can be configured to catch this.
| .andReturn(SettableFuture.create()) | ||
| .atLeastOnce(); | ||
| // A simple HttpClient that records requests and returns queued futures per call. | ||
| class SequencedHttpClient implements HttpClient |
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.
Can we move this to member class? This might be helpful for other tests.
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.
Sure, I’ve moved it to a separate test class under the same root as TestHttpClient.
Test-only change:
HttpResponseHandlerto be exercised.This PR has: