|
44 | 44 | import static org.mockito.Mockito.after;
|
45 | 45 | import static org.mockito.Mockito.any;
|
46 | 46 | import static org.mockito.Mockito.anyLong;
|
| 47 | +import static org.mockito.Mockito.atMost; |
47 | 48 | import static org.mockito.Mockito.atMostOnce;
|
48 | 49 | import static org.mockito.Mockito.doAnswer;
|
49 | 50 | import static org.mockito.Mockito.mock;
|
@@ -618,7 +619,7 @@ void processesAdditionalEventWhileInDeleteModeRetry() {
|
618 | 619 | eventProcessor.handleEvent(prepareCREvent1());
|
619 | 620 | waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
|
620 | 621 | eventProcessor.handleEvent(prepareCRDeleteEvent1());
|
621 |
| - verify(reconciliationDispatcherMock, times(2)).handleExecution(any()); |
| 622 | + verify(reconciliationDispatcherMock, atMost(2)).handleExecution(any()); |
622 | 623 | waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id());
|
623 | 624 | // retry event
|
624 | 625 | eventProcessor.handleEvent(new Event(TestUtils.testCustomResource1Id()));
|
@@ -661,7 +662,26 @@ void afterRetryExhaustedAdditionalEventTriggerReconciliationWhenDeleteEventPrese
|
661 | 662 |
|
662 | 663 | @Test
|
663 | 664 | void passesResourceFromStateToDispatcher() {
|
664 |
| - // check also last state unknown |
| 665 | + eventProcessor = |
| 666 | + spy( |
| 667 | + new EventProcessor( |
| 668 | + controllerConfigTriggerAllEvent(null, rateLimiterMock), |
| 669 | + reconciliationDispatcherMock, |
| 670 | + eventSourceManagerMock, |
| 671 | + null)); |
| 672 | + when(reconciliationDispatcherMock.handleExecution(any())) |
| 673 | + .thenReturn(PostExecutionControl.defaultDispatch()); |
| 674 | + when(eventSourceManagerMock.retryEventSource()).thenReturn(mock(TimerEventSource.class)); |
| 675 | + eventProcessor.start(); |
| 676 | + |
| 677 | + eventProcessor.handleEvent(prepareCREvent1()); |
| 678 | + waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id()); |
| 679 | + |
| 680 | + eventProcessor.handleEvent(prepareCRDeleteEvent1()); |
| 681 | + waitUntilProcessingFinished(eventProcessor, TestUtils.testCustomResource1Id()); |
| 682 | + var captor = ArgumentCaptor.forClass(ExecutionScope.class); |
| 683 | + verify(reconciliationDispatcherMock, times(2)).handleExecution(captor.capture()); |
| 684 | + assertThat(captor.getAllValues().get(1).getResource()).isNotNull(); |
665 | 685 | }
|
666 | 686 |
|
667 | 687 | @Test
|
|
0 commit comments