2828import org .assertj .core .util .Files ;
2929import org .junit .jupiter .api .Test ;
3030
31+ import org .springframework .beans .factory .ObjectProvider ;
3132import org .springframework .boot .autoconfigure .kafka .KafkaProperties ;
3233import org .springframework .core .io .ClassPathResource ;
3334
3435import static org .assertj .core .api .Assertions .assertThat ;
36+ import static org .mockito .Mockito .mock ;
3537
3638class KafkaBinderConfigurationPropertiesTest {
3739
3840 @ Test
41+ @ SuppressWarnings ("unchecked" )
3942 void mergedConsumerConfigurationFiltersGroupIdFromKafkaProperties () {
4043 KafkaProperties kafkaProperties = new KafkaProperties ();
4144 kafkaProperties .getConsumer ().setGroupId ("group1" );
4245 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
43- new KafkaBinderConfigurationProperties (kafkaProperties );
46+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
4447
4548 Map <String , Object > mergedConsumerConfiguration =
4649 kafkaBinderConfigurationProperties .mergedConsumerConfiguration ();
@@ -49,11 +52,12 @@ void mergedConsumerConfigurationFiltersGroupIdFromKafkaProperties() {
4952 }
5053
5154 @ Test
55+ @ SuppressWarnings ("unchecked" )
5256 void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaProperties () {
5357 KafkaProperties kafkaProperties = new KafkaProperties ();
5458 kafkaProperties .getConsumer ().setEnableAutoCommit (true );
5559 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
56- new KafkaBinderConfigurationProperties (kafkaProperties );
60+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
5761
5862 Map <String , Object > mergedConsumerConfiguration =
5963 kafkaBinderConfigurationProperties .mergedConsumerConfiguration ();
@@ -62,10 +66,11 @@ void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaProperties() {
6266 }
6367
6468 @ Test
69+ @ SuppressWarnings ("unchecked" )
6570 void mergedConsumerConfigurationFiltersGroupIdFromKafkaBinderConfigurationPropertiesConfiguration () {
6671 KafkaProperties kafkaProperties = new KafkaProperties ();
6772 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
68- new KafkaBinderConfigurationProperties (kafkaProperties );
73+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
6974 kafkaBinderConfigurationProperties
7075 .setConfiguration (Collections .singletonMap (ConsumerConfig .GROUP_ID_CONFIG , "group1" ));
7176
@@ -75,10 +80,11 @@ void mergedConsumerConfigurationFiltersGroupIdFromKafkaBinderConfigurationProper
7580 }
7681
7782 @ Test
83+ @ SuppressWarnings ("unchecked" )
7884 void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaBinderConfigurationPropertiesConfiguration () {
7985 KafkaProperties kafkaProperties = new KafkaProperties ();
8086 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
81- new KafkaBinderConfigurationProperties (kafkaProperties );
87+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
8288 kafkaBinderConfigurationProperties
8389 .setConfiguration (Collections .singletonMap (ConsumerConfig .ENABLE_AUTO_COMMIT_CONFIG , "true" ));
8490
@@ -88,10 +94,11 @@ void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaBinderConfigurat
8894 }
8995
9096 @ Test
97+ @ SuppressWarnings ("unchecked" )
9198 void mergedConsumerConfigurationFiltersGroupIdFromKafkaBinderConfigurationPropertiesConsumerProperties () {
9299 KafkaProperties kafkaProperties = new KafkaProperties ();
93100 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
94- new KafkaBinderConfigurationProperties (kafkaProperties );
101+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
95102 kafkaBinderConfigurationProperties
96103 .setConsumerProperties (Collections .singletonMap (ConsumerConfig .GROUP_ID_CONFIG , "group1" ));
97104
@@ -101,10 +108,11 @@ void mergedConsumerConfigurationFiltersGroupIdFromKafkaBinderConfigurationProper
101108 }
102109
103110 @ Test
111+ @ SuppressWarnings ("unchecked" )
104112 void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaBinderConfigurationPropertiesConsumerProps () {
105113 KafkaProperties kafkaProperties = new KafkaProperties ();
106114 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
107- new KafkaBinderConfigurationProperties (kafkaProperties );
115+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
108116 kafkaBinderConfigurationProperties
109117 .setConsumerProperties (Collections .singletonMap (ConsumerConfig .ENABLE_AUTO_COMMIT_CONFIG , "true" ));
110118
@@ -114,10 +122,11 @@ void mergedConsumerConfigurationFiltersEnableAutoCommitFromKafkaBinderConfigurat
114122 }
115123
116124 @ Test
125+ @ SuppressWarnings ("unchecked" )
117126 void certificateFilesAreConvertedToAbsolutePathsFromClassPathResources () {
118127 KafkaProperties kafkaProperties = new KafkaProperties ();
119128 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
120- new KafkaBinderConfigurationProperties (kafkaProperties );
129+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
121130 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
122131 configuration .put ("ssl.truststore.location" , "classpath:testclient.truststore" );
123132 configuration .put ("ssl.keystore.location" , "classpath:testclient.keystore" );
@@ -132,6 +141,7 @@ void certificateFilesAreConvertedToAbsolutePathsFromClassPathResources() {
132141 }
133142
134143 @ Test
144+ @ SuppressWarnings ("unchecked" )
135145 void certificateFilesAreConvertedToAbsolutePathsFromHttpResources () throws IOException {
136146 HttpServer server = HttpServer .create (new InetSocketAddress ("localhost" , 5869 ), 0 );
137147 createContextWithCertFileHandler (server , "testclient.truststore" );
@@ -141,7 +151,7 @@ void certificateFilesAreConvertedToAbsolutePathsFromHttpResources() throws IOExc
141151
142152 KafkaProperties kafkaProperties = new KafkaProperties ();
143153 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
144- new KafkaBinderConfigurationProperties (kafkaProperties );
154+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
145155 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
146156 configuration .put ("ssl.truststore.location" , "http://localhost:5869/testclient.truststore" );
147157 configuration .put ("ssl.keystore.location" , "http://localhost:5869/testclient.keystore" );
@@ -164,10 +174,11 @@ void certificateFilesAreConvertedToAbsolutePathsFromHttpResources() throws IOExc
164174 }
165175
166176 @ Test
177+ @ SuppressWarnings ("unchecked" )
167178 void certificateFilesAreConvertedToGivenAbsolutePathsFromClassPathResources () {
168179 KafkaProperties kafkaProperties = new KafkaProperties ();
169180 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
170- new KafkaBinderConfigurationProperties (kafkaProperties );
181+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
171182 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
172183 configuration .put ("ssl.truststore.location" , "classpath:testclient.truststore" );
173184 configuration .put ("ssl.keystore.location" , "classpath:testclient.keystore" );
@@ -182,10 +193,11 @@ void certificateFilesAreConvertedToGivenAbsolutePathsFromClassPathResources() {
182193 }
183194
184195 @ Test
196+ @ SuppressWarnings ("unchecked" )
185197 void certificateFilesAreMovedForSchemaRegistryConfiguration () {
186198 KafkaProperties kafkaProperties = new KafkaProperties ();
187199 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
188- new KafkaBinderConfigurationProperties (kafkaProperties );
200+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
189201 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
190202
191203 configuration .put ("schema.registry.ssl.truststore.location" , "classpath:testclient.truststore" );
@@ -213,10 +225,11 @@ void certificateFilesAreMovedForSchemaRegistryConfiguration() {
213225 }
214226
215227 @ Test
228+ @ SuppressWarnings ("unchecked" )
216229 void schemaRegistryPropertiesPropagatedToMergedProducerProperties () {
217230 KafkaProperties kafkaProperties = new KafkaProperties ();
218231 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
219- new KafkaBinderConfigurationProperties (kafkaProperties );
232+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
220233 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
221234
222235 configuration .put ("schema.registry.url" , "https://localhost:8081,https://localhost:8082" );
@@ -254,10 +267,11 @@ void schemaRegistryPropertiesPropagatedToMergedProducerProperties() {
254267 }
255268
256269 @ Test
270+ @ SuppressWarnings ("unchecked" )
257271 public void testEmptyLocationsAreIgnored () {
258272 KafkaProperties kafkaProperties = new KafkaProperties ();
259273 KafkaBinderConfigurationProperties kafkaBinderConfigurationProperties =
260- new KafkaBinderConfigurationProperties (kafkaProperties );
274+ new KafkaBinderConfigurationProperties (kafkaProperties , mock ( ObjectProvider . class ) );
261275 final Map <String , String > configuration = kafkaBinderConfigurationProperties .getConfiguration ();
262276 configuration .put ("schema.registry.ssl.truststore.location" , "" );
263277 configuration .put ("schema.registry.ssl.keystore.location" , "" );
0 commit comments