@@ -283,22 +283,29 @@ void injectsExpectedBeans() {
283
283
}
284
284
285
285
@ Test
286
- void whenHasUseDefinedProducerInterceptorInjectsBean () {
286
+ < T > void whenHasUseDefinedProducerInterceptorInjectsBean () {
287
287
ProducerInterceptor interceptor = mock (ProducerInterceptor .class );
288
288
this .contextRunner .withBean ("customProducerInterceptor" , ProducerInterceptor .class , () -> interceptor )
289
- .run ((context ) -> assertThat (context ).getBean (PulsarTemplate .class )
290
- .extracting ("interceptors" )
291
- .asList ()
292
- .contains (interceptor ));
289
+ .run ((context ) -> {
290
+ PulsarTemplate <?> pulsarTemplate = context .getBean (PulsarTemplate .class );
291
+ Customizers <ProducerBuilderCustomizer <T >, ProducerBuilder <T >> customizers = Customizers
292
+ .of (ProducerBuilder .class , ProducerBuilderCustomizer ::customize );
293
+ assertThat (customizers .fromField (pulsarTemplate , "interceptorsCustomizers" ))
294
+ .callsInOrder (ProducerBuilder ::intercept , interceptor );
295
+ });
293
296
}
294
297
295
298
@ Test
296
- void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder () {
297
- this .contextRunner .withUserConfiguration (InterceptorTestConfiguration .class )
298
- .run ((context ) -> assertThat (context ).getBean (PulsarTemplate .class )
299
- .extracting ("interceptors" )
300
- .asList ()
301
- .containsExactly (context .getBean ("interceptorBar" ), context .getBean ("interceptorFoo" )));
299
+ <T > void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder () {
300
+ this .contextRunner .withUserConfiguration (InterceptorTestConfiguration .class ).run ((context ) -> {
301
+ ProducerInterceptor interceptorFoo = context .getBean ("interceptorFoo" , ProducerInterceptor .class );
302
+ ProducerInterceptor interceptorBar = context .getBean ("interceptorBar" , ProducerInterceptor .class );
303
+ PulsarTemplate <?> pulsarTemplate = context .getBean (PulsarTemplate .class );
304
+ Customizers <ProducerBuilderCustomizer <T >, ProducerBuilder <T >> customizers = Customizers
305
+ .of (ProducerBuilder .class , ProducerBuilderCustomizer ::customize );
306
+ assertThat (customizers .fromField (pulsarTemplate , "interceptorsCustomizers" ))
307
+ .callsInOrder (ProducerBuilder ::intercept , interceptorBar , interceptorFoo );
308
+ });
302
309
}
303
310
304
311
@ Test
0 commit comments