You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "philipnee (via GitHub)" <gi...@apache.org> on 2023/08/02 05:21:17 UTC
[GitHub] [kafka] philipnee commented on a diff in pull request #14123: MINOR: Fix committed API in the PrototypeAsyncConsumer timeout
philipnee commented on code in PR #14123:
URL: https://github.com/apache/kafka/pull/14123#discussion_r1281407606
##########
clients/src/test/java/org/apache/kafka/clients/consumer/internals/PrototypeAsyncConsumerTest.java:
##########
@@ -150,15 +151,33 @@ public void testCommitAsync_UserSuppliedCallback() {
}
@Test
- @SuppressWarnings("unchecked")
public void testCommitted() {
Set<TopicPartition> mockTopicPartitions = mockTopicPartitionOffset().keySet();
- mockConstruction(OffsetFetchApplicationEvent.class, (mock, ctx) -> {
- when(mock.complete(any())).thenReturn(new HashMap<>());
- });
- consumer = newConsumer(time, new StringDeserializer(), new StringDeserializer());
- assertDoesNotThrow(() -> consumer.committed(mockTopicPartitions, Duration.ofMillis(1)));
- verify(eventHandler).add(ArgumentMatchers.isA(OffsetFetchApplicationEvent.class));
+ CompletableFuture<Map<TopicPartition, OffsetAndMetadata>> committedFuture = new CompletableFuture<>();
+ try (MockedConstruction<OffsetFetchApplicationEvent> mockConstruction =
Review Comment:
We need to close the mockConstruction object in the end because it is a thread-lock controller. If we don't close it, it would remain active and causes undesirable behavior for other tests. I'm using mockConstruction to mock the construction of the event object, are there better ways to mimic/mock the behavior the event construction and method calls there?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org