Fixing a Kafka binder unit test failure
Latest version of Mockito (5.3.0) used in Spring Boot 3.1.0, apparently needs the specific Collection type when capturing values via the ArgumentCaptor. Earlier versisons didn't mandate this.
This commit is contained in:
@@ -305,15 +305,29 @@ public class KafkaBinderUnitTests {
|
||||
Binding<MessageChannel> messageChannelBinding = binder.bindConsumer(topic, group,
|
||||
channel, consumerProperties);
|
||||
assertThat(latch.await(10, TimeUnit.SECONDS)).isTrue();
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<Set<TopicPartition>> captor = ArgumentCaptor.forClass(Set.class);
|
||||
if (earliest) {
|
||||
verify(consumer).seekToBeginning(captor.capture());
|
||||
|
||||
if (!groupManage) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<Set<TopicPartition>> captor = ArgumentCaptor.forClass(Set.class);
|
||||
if (earliest) {
|
||||
verify(consumer).seekToBeginning(captor.capture());
|
||||
}
|
||||
else {
|
||||
verify(consumer).seekToEnd(captor.capture());
|
||||
}
|
||||
assertThat(captor.getValue()).containsExactlyInAnyOrderElementsOf(partitions);
|
||||
}
|
||||
else {
|
||||
verify(consumer).seekToEnd(captor.capture());
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<TopicPartition>> captor = ArgumentCaptor.forClass(List.class);
|
||||
if (earliest) {
|
||||
verify(consumer).seekToBeginning(captor.capture());
|
||||
}
|
||||
else {
|
||||
verify(consumer).seekToEnd(captor.capture());
|
||||
}
|
||||
assertThat(captor.getValue()).containsExactlyInAnyOrderElementsOf(partitions);
|
||||
}
|
||||
assertThat(captor.getValue()).containsExactlyInAnyOrderElementsOf(partitions);
|
||||
messageChannelBinding.unbind();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user