@@ -79,9 +79,6 @@ class DeadLetterPublishingRecovererFactoryTests {
79
79
@ Mock
80
80
private KafkaOperations <?, ?> kafkaOperations ;
81
81
82
- @ Mock
83
- private KafkaOperations <?, ?> kafkaOperations2 ;
84
-
85
82
@ Mock
86
83
private ListenableFuture <?> listenableFuture ;
87
84
@@ -106,11 +103,10 @@ void shouldSendMessage() {
106
103
given (destinationTopic .isNoOpsTopic ()).willReturn (false );
107
104
given (destinationTopic .getDestinationName ()).willReturn (testRetryTopic );
108
105
given (destinationTopic .getDestinationPartitions ()).willReturn (3 );
109
- given (destinationTopicResolver .getDestinationTopicByName (testTopic )).willReturn (destinationTopic );
110
106
given (destinationTopicResolver .getDestinationTopicByName (testRetryTopic )).willReturn (destinationTopic );
111
107
given (destinationTopic .getDestinationDelay ()).willReturn (1000L );
112
- willReturn (this .kafkaOperations2 ).given (destinationTopic ).getKafkaOperations ();
113
- given (kafkaOperations2 .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
108
+ willReturn (this .kafkaOperations ).given (destinationTopic ).getKafkaOperations ();
109
+ given (kafkaOperations .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
114
110
this .consumerRecord .headers ().add (RetryTopicHeaders .DEFAULT_HEADER_ORIGINAL_TIMESTAMP , originalTimestampBytes );
115
111
116
112
DeadLetterPublishingRecovererFactory factory = new DeadLetterPublishingRecovererFactory (this .destinationTopicResolver );
@@ -120,7 +116,7 @@ void shouldSendMessage() {
120
116
deadLetterPublishingRecoverer .accept (this .consumerRecord , e );
121
117
122
118
// then
123
- then (kafkaOperations2 ).should (times (1 )).send (producerRecordCaptor .capture ());
119
+ then (kafkaOperations ).should (times (1 )).send (producerRecordCaptor .capture ());
124
120
ProducerRecord producerRecord = producerRecordCaptor .getValue ();
125
121
assertThat (producerRecord .topic ()).isEqualTo (testRetryTopic );
126
122
assertThat (producerRecord .value ()).isEqualTo (value );
@@ -151,9 +147,8 @@ void shouldIncreaseAttempts() {
151
147
given (destinationTopic .getDestinationName ()).willReturn (testRetryTopic );
152
148
given (destinationTopic .getDestinationPartitions ()).willReturn (1 );
153
149
given (destinationTopicResolver .getDestinationTopicByName (testRetryTopic )).willReturn (destinationTopic );
154
- given (destinationTopicResolver .getDestinationTopicByName (testTopic )).willReturn (destinationTopic );
155
- willReturn (kafkaOperations2 ).given (destinationTopic ).getKafkaOperations ();
156
- given (kafkaOperations2 .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
150
+ willReturn (kafkaOperations ).given (destinationTopic ).getKafkaOperations ();
151
+ given (kafkaOperations .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
157
152
158
153
DeadLetterPublishingRecovererFactory factory = new DeadLetterPublishingRecovererFactory (this .destinationTopicResolver );
159
154
@@ -162,7 +157,7 @@ void shouldIncreaseAttempts() {
162
157
deadLetterPublishingRecoverer .accept (consumerRecord , e );
163
158
164
159
// then
165
- then (kafkaOperations2 ).should (times (1 )).send (producerRecordCaptor .capture ());
160
+ then (kafkaOperations ).should (times (1 )).send (producerRecordCaptor .capture ());
166
161
ProducerRecord producerRecord = producerRecordCaptor .getValue ();
167
162
Header attemptsHeader = producerRecord .headers ().lastHeader (RetryTopicHeaders .DEFAULT_HEADER_ATTEMPTS );
168
163
assertThat (attemptsHeader ).isNotNull ();
@@ -182,10 +177,8 @@ void shouldAddOriginalTimestampHeader() {
182
177
given (destinationTopic .getDestinationName ()).willReturn (testRetryTopic );
183
178
given (destinationTopic .getDestinationPartitions ()).willReturn (1 );
184
179
given (destinationTopicResolver .getDestinationTopicByName (testRetryTopic )).willReturn (destinationTopic );
185
- long nextExecutionTimestamp = this .nowTimestamp + destinationTopic .getDestinationDelay ();
186
- given (destinationTopicResolver .getDestinationTopicByName (testTopic )).willReturn (destinationTopic );
187
- willReturn (this .kafkaOperations2 ).given (destinationTopic ).getKafkaOperations ();
188
- given (kafkaOperations2 .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
180
+ willReturn (this .kafkaOperations ).given (destinationTopic ).getKafkaOperations ();
181
+ given (kafkaOperations .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
189
182
190
183
DeadLetterPublishingRecovererFactory factory = new DeadLetterPublishingRecovererFactory (this .destinationTopicResolver );
191
184
@@ -194,7 +187,7 @@ void shouldAddOriginalTimestampHeader() {
194
187
deadLetterPublishingRecoverer .accept (consumerRecord , e );
195
188
196
189
// then
197
- then (kafkaOperations2 ).should (times (1 )).send (producerRecordCaptor .capture ());
190
+ then (kafkaOperations ).should (times (1 )).send (producerRecordCaptor .capture ());
198
191
ProducerRecord producerRecord = producerRecordCaptor .getValue ();
199
192
Header originalTimestampHeader = producerRecord .headers ().lastHeader (RetryTopicHeaders .DEFAULT_HEADER_ORIGINAL_TIMESTAMP );
200
193
assertThat (originalTimestampHeader ).isNotNull ();
@@ -215,10 +208,8 @@ void shouldNotReplaceOriginalTimestampHeader() {
215
208
given (destinationTopic .getDestinationName ()).willReturn (testRetryTopic );
216
209
given (destinationTopic .getDestinationPartitions ()).willReturn (1 );
217
210
given (destinationTopicResolver .getDestinationTopicByName (testRetryTopic )).willReturn (destinationTopic );
218
- long nextExecutionTimestamp = this .nowTimestamp + destinationTopic .getDestinationDelay ();
219
- given (destinationTopicResolver .getDestinationTopicByName (testTopic )).willReturn (destinationTopic );
220
- willReturn (this .kafkaOperations2 ).given (destinationTopic ).getKafkaOperations ();
221
- given (kafkaOperations2 .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
211
+ willReturn (this .kafkaOperations ).given (destinationTopic ).getKafkaOperations ();
212
+ given (kafkaOperations .send (any (ProducerRecord .class ))).willReturn (listenableFuture );
222
213
223
214
DeadLetterPublishingRecovererFactory factory = new DeadLetterPublishingRecovererFactory (this .destinationTopicResolver );
224
215
@@ -227,7 +218,7 @@ void shouldNotReplaceOriginalTimestampHeader() {
227
218
deadLetterPublishingRecoverer .accept (consumerRecord , e );
228
219
229
220
// then
230
- then (kafkaOperations2 ).should (times (1 )).send (producerRecordCaptor .capture ());
221
+ then (kafkaOperations ).should (times (1 )).send (producerRecordCaptor .capture ());
231
222
ProducerRecord producerRecord = producerRecordCaptor .getValue ();
232
223
Header originalTimestampHeader = producerRecord .headers ().lastHeader (RetryTopicHeaders .DEFAULT_HEADER_ORIGINAL_TIMESTAMP );
233
224
assertThat (originalTimestampHeader ).isNotNull ();
@@ -249,7 +240,7 @@ void shouldNotSendMessageIfNoOpsDestination() {
249
240
deadLetterPublishingRecoverer .accept (this .consumerRecord , e );
250
241
251
242
// then
252
- then (kafkaOperations2 ).should (times (0 )).send (any (ProducerRecord .class ));
243
+ then (kafkaOperations ).should (times (0 )).send (any (ProducerRecord .class ));
253
244
}
254
245
255
246
@ Test
@@ -264,7 +255,7 @@ void shouldThrowIfKafkaBackoffException() {
264
255
.isThrownBy (() -> deadLetterPublishingRecoverer .accept (this .consumerRecord , e ));
265
256
266
257
// then
267
- then (kafkaOperations2 ).should (times (0 )).send (any (ProducerRecord .class ));
258
+ then (kafkaOperations ).should (times (0 )).send (any (ProducerRecord .class ));
268
259
}
269
260
270
261
@ Test
0 commit comments