@@ -81,12 +81,15 @@ class RestTemplateBuilderTests {
8181 private final RestTemplateBuilder builder = new RestTemplateBuilder ();
8282
8383 @ Mock
84+ @ SuppressWarnings ("NullAway.Init" )
8485 private HttpMessageConverter <Object > messageConverter ;
8586
8687 @ Mock
88+ @ SuppressWarnings ("NullAway.Init" )
8789 private ClientHttpRequestInterceptor interceptor ;
8890
8991 @ Test
92+ @ SuppressWarnings ("NullAway" ) // Test null check
9093 void createWhenCustomizersAreNullShouldThrowException () {
9194 RestTemplateCustomizer [] customizers = null ;
9295 assertThatIllegalArgumentException ().isThrownBy (() -> new RestTemplateBuilder (customizers ))
@@ -134,13 +137,15 @@ void rootUriShouldApplyAfterUriTemplateHandler() {
134137 }
135138
136139 @ Test
140+ @ SuppressWarnings ("NullAway" ) // Test null check
137141 void messageConvertersWhenConvertersAreNullShouldThrowException () {
138142 assertThatIllegalArgumentException ()
139143 .isThrownBy (() -> this .builder .messageConverters ((HttpMessageConverter <?>[]) null ))
140144 .withMessageContaining ("'messageConverters' must not be null" );
141145 }
142146
143147 @ Test
148+ @ SuppressWarnings ("NullAway" ) // Test null check
144149 void messageConvertersCollectionWhenConvertersAreNullShouldThrowException () {
145150 assertThatIllegalArgumentException ()
146151 .isThrownBy (() -> this .builder .messageConverters ((Set <HttpMessageConverter <?>>) null ))
@@ -162,13 +167,15 @@ void messageConvertersShouldReplaceExisting() {
162167 }
163168
164169 @ Test
170+ @ SuppressWarnings ("NullAway" ) // Test null check
165171 void additionalMessageConvertersWhenConvertersAreNullShouldThrowException () {
166172 assertThatIllegalArgumentException ()
167173 .isThrownBy (() -> this .builder .additionalMessageConverters ((HttpMessageConverter <?>[]) null ))
168174 .withMessageContaining ("'messageConverters' must not be null" );
169175 }
170176
171177 @ Test
178+ @ SuppressWarnings ("NullAway" ) // Test null check
172179 void additionalMessageConvertersCollectionWhenConvertersAreNullShouldThrowException () {
173180 assertThatIllegalArgumentException ()
174181 .isThrownBy (() -> this .builder .additionalMessageConverters ((Set <HttpMessageConverter <?>>) null ))
@@ -199,13 +206,15 @@ void defaultMessageConvertersShouldClearExisting() {
199206 }
200207
201208 @ Test
209+ @ SuppressWarnings ("NullAway" ) // Test null check
202210 void interceptorsWhenInterceptorsAreNullShouldThrowException () {
203211 assertThatIllegalArgumentException ()
204212 .isThrownBy (() -> this .builder .interceptors ((ClientHttpRequestInterceptor []) null ))
205213 .withMessageContaining ("'interceptors' must not be null" );
206214 }
207215
208216 @ Test
217+ @ SuppressWarnings ("NullAway" ) // Test null check
209218 void interceptorsCollectionWhenInterceptorsAreNullShouldThrowException () {
210219 assertThatIllegalArgumentException ()
211220 .isThrownBy (() -> this .builder .interceptors ((Set <ClientHttpRequestInterceptor >) null ))
@@ -227,13 +236,15 @@ void interceptorsShouldReplaceExisting() {
227236 }
228237
229238 @ Test
239+ @ SuppressWarnings ("NullAway" ) // Test null check
230240 void additionalInterceptorsWhenInterceptorsAreNullShouldThrowException () {
231241 assertThatIllegalArgumentException ()
232242 .isThrownBy (() -> this .builder .additionalInterceptors ((ClientHttpRequestInterceptor []) null ))
233243 .withMessageContaining ("'interceptors' must not be null" );
234244 }
235245
236246 @ Test
247+ @ SuppressWarnings ("NullAway" ) // Test null check
237248 void additionalInterceptorsCollectionWhenInterceptorsAreNullShouldThrowException () {
238249 assertThatIllegalArgumentException ()
239250 .isThrownBy (() -> this .builder .additionalInterceptors ((Set <ClientHttpRequestInterceptor >) null ))
@@ -248,6 +259,7 @@ void additionalInterceptorsShouldAddToExisting() {
248259 }
249260
250261 @ Test
262+ @ SuppressWarnings ("NullAway" ) // Test null check
251263 void requestFactoryClassWhenFactoryIsNullShouldThrowException () {
252264 assertThatIllegalArgumentException ()
253265 .isThrownBy (() -> this .builder .requestFactory ((Class <ClientHttpRequestFactory >) null ))
@@ -267,6 +279,7 @@ void requestFactoryPackagePrivateClassShouldApply() {
267279 }
268280
269281 @ Test
282+ @ SuppressWarnings ("NullAway" ) // Test null check
270283 void requestFactoryWhenSupplierIsNullShouldThrowException () {
271284 assertThatIllegalArgumentException ()
272285 .isThrownBy (() -> this .builder .requestFactory ((Supplier <ClientHttpRequestFactory >) null ))
@@ -281,6 +294,7 @@ void requestFactoryShouldApply() {
281294 }
282295
283296 @ Test
297+ @ SuppressWarnings ("NullAway" ) // Test null check
284298 void uriTemplateHandlerWhenHandlerIsNullShouldThrowException () {
285299 assertThatIllegalArgumentException ().isThrownBy (() -> this .builder .uriTemplateHandler (null ))
286300 .withMessageContaining ("'uriTemplateHandler' must not be null" );
@@ -294,6 +308,7 @@ void uriTemplateHandlerShouldApply() {
294308 }
295309
296310 @ Test
311+ @ SuppressWarnings ("NullAway" ) // Test null check
297312 void errorHandlerWhenHandlerIsNullShouldThrowException () {
298313 assertThatIllegalArgumentException ().isThrownBy (() -> this .builder .errorHandler (null ))
299314 .withMessageContaining ("'errorHandler' must not be null" );
@@ -366,12 +381,14 @@ void additionalRequestCustomizersAddsCustomizers() {
366381 }
367382
368383 @ Test
384+ @ SuppressWarnings ("NullAway" ) // Test null check
369385 void customizersWhenCustomizersAreNullShouldThrowException () {
370386 assertThatIllegalArgumentException ().isThrownBy (() -> this .builder .customizers ((RestTemplateCustomizer []) null ))
371387 .withMessageContaining ("'customizers' must not be null" );
372388 }
373389
374390 @ Test
391+ @ SuppressWarnings ("NullAway" ) // Test null check
375392 void customizersCollectionWhenCustomizersAreNullShouldThrowException () {
376393 assertThatIllegalArgumentException ()
377394 .isThrownBy (() -> this .builder .customizers ((Set <RestTemplateCustomizer >) null ))
@@ -405,13 +422,15 @@ void customizersShouldReplaceExisting() {
405422 }
406423
407424 @ Test
425+ @ SuppressWarnings ("NullAway" ) // Test null check
408426 void additionalCustomizersWhenCustomizersAreNullShouldThrowException () {
409427 assertThatIllegalArgumentException ()
410428 .isThrownBy (() -> this .builder .additionalCustomizers ((RestTemplateCustomizer []) null ))
411429 .withMessageContaining ("'customizers' must not be null" );
412430 }
413431
414432 @ Test
433+ @ SuppressWarnings ("NullAway" ) // Test null check
415434 void additionalCustomizersCollectionWhenCustomizersAreNullShouldThrowException () {
416435 assertThatIllegalArgumentException ()
417436 .isThrownBy (() -> this .builder .additionalCustomizers ((Set <RestTemplateCustomizer >) null ))
@@ -486,8 +505,10 @@ void configureRedirects() {
486505 }
487506
488507 private ClientHttpRequest createRequest (RestTemplate template ) {
489- return ReflectionTestUtils .invokeMethod (template , "createRequest" , URI .create ("http://localhost" ),
490- HttpMethod .GET );
508+ ClientHttpRequest request = ReflectionTestUtils .invokeMethod (template , "createRequest" ,
509+ URI .create ("http://localhost" ), HttpMethod .GET );
510+ assertThat (request ).isNotNull ();
511+ return request ;
491512 }
492513
493514 static class RestTemplateSubclass extends RestTemplate {
0 commit comments