25
25
import static org .mockito .Mockito .mock ;
26
26
import static org .mockito .Mockito .times ;
27
27
28
+ import java .lang .annotation .ElementType ;
29
+ import java .lang .annotation .Retention ;
30
+ import java .lang .annotation .RetentionPolicy ;
31
+ import java .lang .annotation .Target ;
28
32
import java .lang .reflect .Method ;
29
33
import java .util .Collections ;
30
34
@@ -61,6 +65,8 @@ class RetryTopicConfigurationProviderTests {
61
65
62
66
private final Method nonAnnotatedMethod = getAnnotatedMethod ("nonAnnotatedMethod" );
63
67
68
+ private final Method metaAnnotatedMethod = getAnnotatedMethod ("metaAnnotatedMethod" );
69
+
64
70
private Method getAnnotatedMethod (String methodName ) {
65
71
try {
66
72
return this .getClass ().getDeclaredMethod (methodName );
@@ -136,6 +142,20 @@ void shouldFindNone() {
136
142
137
143
}
138
144
145
+ @ Test
146
+ void shouldProvideFromMetaAnnotation () {
147
+
148
+ // setup
149
+ willReturn (kafkaOperations ).given (beanFactory ).getBean ("retryTopicDefaultKafkaTemplate" , KafkaOperations .class );
150
+
151
+ // given
152
+ RetryTopicConfigurationProvider provider = new RetryTopicConfigurationProvider (beanFactory );
153
+ RetryTopicConfiguration configuration = provider .findRetryConfigurationFor (topics , metaAnnotatedMethod , bean );
154
+
155
+ // then
156
+ then (this .beanFactory ).should (times (0 )).getBeansOfType (RetryTopicConfiguration .class );
157
+
158
+ }
139
159
140
160
@ Test
141
161
void shouldNotConfigureIfBeanFactoryNull () {
@@ -157,4 +177,14 @@ public void annotatedMethod() {
157
177
public void nonAnnotatedMethod () {
158
178
// NoOps
159
179
}
180
+
181
+ @ Target ({ElementType .METHOD })
182
+ @ Retention (RetentionPolicy .RUNTIME )
183
+ @ RetryableTopic
184
+ static @interface MetaAnnotatedRetryableTopic { }
185
+
186
+ @ MetaAnnotatedRetryableTopic
187
+ public void metaAnnotatedMethod () {
188
+ // NoOps
189
+ }
160
190
}
0 commit comments