|
23 | 23 | import static io.javaoperatorsdk.operator.TestUtils.testCustomResource;
|
24 | 24 | import static org.assertj.core.api.Assertions.assertThat;
|
25 | 25 | import static org.mockito.ArgumentMatchers.eq;
|
26 |
| -import static org.mockito.Mockito.any; |
27 |
| -import static org.mockito.Mockito.doAnswer; |
28 |
| -import static org.mockito.Mockito.doCallRealMethod; |
29 |
| -import static org.mockito.Mockito.mock; |
30 |
| -import static org.mockito.Mockito.never; |
31 |
| -import static org.mockito.Mockito.timeout; |
32 |
| -import static org.mockito.Mockito.times; |
33 |
| -import static org.mockito.Mockito.verify; |
34 |
| -import static org.mockito.Mockito.when; |
| 26 | +import static org.mockito.Mockito.*; |
35 | 27 |
|
36 | 28 | class DefaultEventHandlerTest {
|
37 | 29 |
|
@@ -187,7 +179,6 @@ public void successfulExecutionResetsTheRetry() {
|
187 | 179 | Event event = prepareCREvent();
|
188 | 180 | TestCustomResource customResource = testCustomResource();
|
189 | 181 | customResource.getMetadata().setUid(event.getRelatedCustomResourceUid());
|
190 |
| - ExecutionScope executionScope = new ExecutionScope(Arrays.asList(event), customResource, null); |
191 | 182 | PostExecutionControl postExecutionControlWithException =
|
192 | 183 | PostExecutionControl.exceptionDuringExecution(new RuntimeException("test"));
|
193 | 184 | PostExecutionControl defaultDispatchControl = PostExecutionControl.defaultDispatch();
|
@@ -222,6 +213,18 @@ public void successfulExecutionResetsTheRetry() {
|
222 | 213 | assertThat(executionScopes.get(1).getRetryInfo().isLastAttempt()).isEqualTo(false);
|
223 | 214 | }
|
224 | 215 |
|
| 216 | + @Test |
| 217 | + public void scheduleTimedEventIfInstructedByPostExecutionControl() { |
| 218 | + var testDelay = 10000l; |
| 219 | + when(eventDispatcherMock.handleExecution(any())) |
| 220 | + .thenReturn(PostExecutionControl.defaultDispatch().withReSchedule(testDelay)); |
| 221 | + |
| 222 | + defaultEventHandler.handleEvent(prepareCREvent()); |
| 223 | + |
| 224 | + verify(retryTimerEventSourceMock, timeout(SEPARATE_EXECUTION_TIMEOUT).times(1)) |
| 225 | + .scheduleOnce(any(), eq(testDelay)); |
| 226 | + } |
| 227 | + |
225 | 228 | private void waitMinimalTime() {
|
226 | 229 | try {
|
227 | 230 | Thread.sleep(50);
|
|
0 commit comments