|
16 | 16 |
|
17 | 17 | package org.springframework.core.retry.support;
|
18 | 18 |
|
19 |
| -import java.util.Arrays; |
| 19 | +import java.util.List; |
20 | 20 |
|
21 | 21 | import org.junit.jupiter.api.Test;
|
22 | 22 |
|
|
30 | 30 | * Tests for {@link CompositeRetryListener}.
|
31 | 31 | *
|
32 | 32 | * @author Mahmoud Ben Hassine
|
| 33 | + * @since 7.0 |
33 | 34 | */
|
34 |
| -class ComposedRetryListenerTests { |
| 35 | +class CompositeRetryListenerTests { |
35 | 36 |
|
36 | 37 | private final RetryListener listener1 = mock();
|
37 | 38 | private final RetryListener listener2 = mock();
|
| 39 | + private final RetryExecution retryExecution = mock(); |
| 40 | + |
| 41 | + private final CompositeRetryListener compositeRetryListener = |
| 42 | + new CompositeRetryListener(List.of(listener1, listener2)); |
38 | 43 |
|
39 |
| - private final CompositeRetryListener composedRetryListener = new CompositeRetryListener(Arrays.asList(listener1, listener2)); |
40 | 44 |
|
41 | 45 | @Test
|
42 | 46 | void beforeRetry() {
|
43 |
| - RetryExecution retryExecution = mock(); |
44 |
| - this.composedRetryListener.beforeRetry(retryExecution); |
| 47 | + compositeRetryListener.beforeRetry(retryExecution); |
45 | 48 |
|
46 |
| - verify(this.listener1).beforeRetry(retryExecution); |
47 |
| - verify(this.listener2).beforeRetry(retryExecution); |
| 49 | + verify(listener1).beforeRetry(retryExecution); |
| 50 | + verify(listener2).beforeRetry(retryExecution); |
48 | 51 | }
|
49 | 52 |
|
50 | 53 | @Test
|
51 |
| - void onSuccess() { |
| 54 | + void onRetrySuccess() { |
52 | 55 | Object result = new Object();
|
53 |
| - RetryExecution retryExecution = mock(); |
54 |
| - this.composedRetryListener.onRetrySuccess(retryExecution, result); |
| 56 | + compositeRetryListener.onRetrySuccess(retryExecution, result); |
55 | 57 |
|
56 |
| - verify(this.listener1).onRetrySuccess(retryExecution, result); |
57 |
| - verify(this.listener2).onRetrySuccess(retryExecution, result); |
| 58 | + verify(listener1).onRetrySuccess(retryExecution, result); |
| 59 | + verify(listener2).onRetrySuccess(retryExecution, result); |
58 | 60 | }
|
59 | 61 |
|
60 | 62 | @Test
|
61 |
| - void onFailure() { |
| 63 | + void onRetryFailure() { |
62 | 64 | Exception exception = new Exception();
|
63 |
| - RetryExecution retryExecution = mock(); |
64 |
| - this.composedRetryListener.onRetryFailure(retryExecution, exception); |
| 65 | + compositeRetryListener.onRetryFailure(retryExecution, exception); |
65 | 66 |
|
66 |
| - verify(this.listener1).onRetryFailure(retryExecution, exception); |
67 |
| - verify(this.listener2).onRetryFailure(retryExecution, exception); |
| 67 | + verify(listener1).onRetryFailure(retryExecution, exception); |
| 68 | + verify(listener2).onRetryFailure(retryExecution, exception); |
68 | 69 | }
|
69 | 70 |
|
70 | 71 | @Test
|
71 |
| - void onMaxAttempts() { |
| 72 | + void onRetryPolicyExhaustion() { |
72 | 73 | Exception exception = new Exception();
|
73 |
| - RetryExecution retryExecution = mock(); |
74 |
| - this.composedRetryListener.onRetryPolicyExhaustion(retryExecution, exception); |
| 74 | + compositeRetryListener.onRetryPolicyExhaustion(retryExecution, exception); |
75 | 75 |
|
76 |
| - verify(this.listener1).onRetryPolicyExhaustion(retryExecution, exception); |
77 |
| - verify(this.listener2).onRetryPolicyExhaustion(retryExecution, exception); |
| 76 | + verify(listener1).onRetryPolicyExhaustion(retryExecution, exception); |
| 77 | + verify(listener2).onRetryPolicyExhaustion(retryExecution, exception); |
78 | 78 | }
|
79 | 79 |
|
80 | 80 | }
|
0 commit comments