32
32
import static org .awaitility .Awaitility .await ;
33
33
import static org .mockito .ArgumentMatchers .eq ;
34
34
import static org .mockito .ArgumentMatchers .isNull ;
35
- import static org .mockito .Mockito .*;
36
-
35
+ import static org .mockito .Mockito .after ;
36
+ import static org .mockito .Mockito .any ;
37
+ import static org .mockito .Mockito .anyLong ;
38
+ import static org .mockito .Mockito .doAnswer ;
39
+ import static org .mockito .Mockito .mock ;
40
+ import static org .mockito .Mockito .never ;
41
+ import static org .mockito .Mockito .spy ;
42
+ import static org .mockito .Mockito .timeout ;
43
+ import static org .mockito .Mockito .times ;
44
+ import static org .mockito .Mockito .verify ;
45
+ import static org .mockito .Mockito .when ;
46
+
47
+ @ SuppressWarnings ({"rawtypes" , "unchecked" })
37
48
class EventProcessorTest {
38
49
39
50
private static final Logger log = LoggerFactory .getLogger (EventProcessorTest .class );
@@ -42,16 +53,16 @@ class EventProcessorTest {
42
53
public static final int SEPARATE_EXECUTION_TIMEOUT = 450 ;
43
54
public static final String TEST_NAMESPACE = "default-event-handler-test" ;
44
55
45
- private ReconciliationDispatcher reconciliationDispatcherMock =
56
+ private final ReconciliationDispatcher reconciliationDispatcherMock =
46
57
mock (ReconciliationDispatcher .class );
47
- private EventSourceManager eventSourceManagerMock = mock (EventSourceManager .class );
48
- private TimerEventSource retryTimerEventSourceMock = mock (TimerEventSource .class );
49
- private ControllerResourceEventSource controllerResourceEventSourceMock =
58
+ private final EventSourceManager eventSourceManagerMock = mock (EventSourceManager .class );
59
+ private final TimerEventSource retryTimerEventSourceMock = mock (TimerEventSource .class );
60
+ private final ControllerResourceEventSource controllerResourceEventSourceMock =
50
61
mock (ControllerResourceEventSource .class );
51
- private Metrics metricsMock = mock (Metrics .class );
62
+ private final Metrics metricsMock = mock (Metrics .class );
52
63
private EventProcessor eventProcessor ;
53
64
private EventProcessor eventProcessorWithRetry ;
54
- private RateLimiter rateLimiterMock = mock (RateLimiter .class );
65
+ private final RateLimiter rateLimiterMock = mock (RateLimiter .class );
55
66
56
67
@ BeforeEach
57
68
void setup () {
@@ -89,7 +100,7 @@ void skipProcessingIfLatestCustomResourceNotInCache() {
89
100
}
90
101
91
102
@ Test
92
- void ifExecutionInProgressWaitsUntilItsFinished () throws InterruptedException {
103
+ void ifExecutionInProgressWaitsUntilItsFinished () {
93
104
ResourceID resourceUid = eventAlreadyUnderProcessing ();
94
105
95
106
eventProcessor .handleEvent (nonCREvent (resourceUid ));
@@ -204,7 +215,7 @@ void scheduleTimedEventIfInstructedByPostExecutionControl() {
204
215
eventProcessor .handleEvent (prepareCREvent ());
205
216
206
217
verify (retryTimerEventSourceMock , timeout (SEPARATE_EXECUTION_TIMEOUT ).times (1 ))
207
- .scheduleOnce (any (), eq (testDelay ));
218
+ .scheduleOnce (( HasMetadata ) any (), eq (testDelay ));
208
219
}
209
220
210
221
@ Test
@@ -220,7 +231,7 @@ void reScheduleOnlyIfNotExecutedEventsReceivedMeanwhile() throws InterruptedExce
220
231
221
232
verify (retryTimerEventSourceMock ,
222
233
after ((long ) (FAKE_CONTROLLER_EXECUTION_DURATION * 1.5 )).times (0 ))
223
- .scheduleOnce (any (), eq (testDelay ));
234
+ .scheduleOnce (( HasMetadata ) any (), eq (testDelay ));
224
235
}
225
236
226
237
@ Test
@@ -335,7 +346,7 @@ void newResourceAfterMissedDeleteEvent() {
335
346
}
336
347
337
348
@ Test
338
- void rateLimitsReconciliationSubmission () throws InterruptedException {
349
+ void rateLimitsReconciliationSubmission () {
339
350
// the refresh period value does not matter here
340
351
var refreshPeriod = Duration .ofMillis (100 );
341
352
var event = prepareCREvent ();
@@ -347,10 +358,10 @@ void rateLimitsReconciliationSubmission() throws InterruptedException {
347
358
eventProcessor .handleEvent (event );
348
359
verify (reconciliationDispatcherMock , after (FAKE_CONTROLLER_EXECUTION_DURATION ).times (1 ))
349
360
.handleExecution (any ());
350
- verify (retryTimerEventSourceMock , times (0 )).scheduleOnce (any (), anyLong ());
361
+ verify (retryTimerEventSourceMock , times (0 )).scheduleOnce (( HasMetadata ) any (), anyLong ());
351
362
352
363
eventProcessor .handleEvent (event );
353
- verify (retryTimerEventSourceMock , times (1 )).scheduleOnce (any (), anyLong ());
364
+ verify (retryTimerEventSourceMock , times (1 )).scheduleOnce (( HasMetadata ) any (), anyLong ());
354
365
}
355
366
356
367
private ResourceID eventAlreadyUnderProcessing () {
0 commit comments