Skip to content

Commit

Permalink
Add test testCommitAsync_NullCallback as testCommitAsyncWithNullCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
cadonna committed Dec 6, 2023
1 parent 5649288 commit 66a61d9
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
import org.apache.kafka.common.utils.Timer;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Mockito;

Expand Down Expand Up @@ -219,6 +220,25 @@ public void testCommitSyncLeaderEpochUpdate() {
verify(metadata).updateLastSeenEpochIfNewer(t1, 1);
}

@Test
public void testCommitAsyncWithNullCallback() {
consumer = setup();
final TopicPartition t0 = new TopicPartition("t0", 2);
final TopicPartition t1 = new TopicPartition("t0", 3);
HashMap<TopicPartition, OffsetAndMetadata> offsets = new HashMap<>();
offsets.put(t0, new OffsetAndMetadata(10L));
offsets.put(t1, new OffsetAndMetadata(20L));

consumer.commitAsync(offsets, null);

final ArgumentCaptor<CommitApplicationEvent> commitEventCaptor = ArgumentCaptor.forClass(CommitApplicationEvent.class);
verify(applicationEventHandler).add(commitEventCaptor.capture());
final CommitApplicationEvent commitEvent = commitEventCaptor.getValue();
assertEquals(offsets, commitEvent.offsets());
assertDoesNotThrow(() -> commitEvent.future().complete(null));
assertDoesNotThrow(() -> consumer.commitAsync(offsets, null));
}

@Test
public void testCommitAsyncLeaderEpochUpdate() {
consumer = setup();
Expand Down

0 comments on commit 66a61d9

Please sign in to comment.