Fix mocking for final ConsumerRecord
https://build.spring.io/browse/SK-SK11X-30/ https://build.spring.io/browse/SK-SK10X-36/ ``` org.mockito.exceptions.base.MockitoException: org.mockito.exceptions.base.MockitoException: Cannot mock/spy class org.apache.kafka.clients.consumer.ConsumerRecord Mockito cannot mock/spy following: - final classes - anonymous classes - primitive types ``` **Cherry-pick to 1.0.x**
This commit is contained in:
@@ -46,8 +46,7 @@ public class RetryingMessageListenerAdapterTests {
|
||||
context.set(c);
|
||||
return null;
|
||||
});
|
||||
@SuppressWarnings("unchecked")
|
||||
ConsumerRecord<String, String> record = mock(ConsumerRecord.class);
|
||||
ConsumerRecord<String, String> record = new ConsumerRecord<>("mockTopic", 0, 0, null, null);
|
||||
adapter.onMessage(record);
|
||||
assertThat(context.get()).isNotNull();
|
||||
assertThat(context.get().getAttribute(RetryingMessageListenerAdapter.CONTEXT_ACKNOWLEDGMENT)).isNull();
|
||||
@@ -65,8 +64,7 @@ public class RetryingMessageListenerAdapterTests {
|
||||
context.set(c);
|
||||
return null;
|
||||
});
|
||||
@SuppressWarnings("unchecked")
|
||||
ConsumerRecord<String, String> record = mock(ConsumerRecord.class);
|
||||
ConsumerRecord<String, String> record = new ConsumerRecord<>("mockTopic", 0, 0, null, null);
|
||||
Acknowledgment ack = mock(Acknowledgment.class);
|
||||
adapter.onMessage(record, ack);
|
||||
assertThat(context.get()).isNotNull();
|
||||
|
||||
Reference in New Issue
Block a user