Skip to content

Commit a1c7c0b

Browse files
committed
Upgrade to AssertJ 3.25.1
Closes gh-38997
1 parent c19c18f commit a1c7c0b

File tree

18 files changed

+62
-43
lines changed

18 files changed

+62
-43
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ org.gradle.caching=true
44
org.gradle.parallel=true
55
org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8
66

7-
assertjVersion=3.24.2
7+
assertjVersion=3.25.1
88
commonsCodecVersion=1.16.0
99
hamcrestVersion=2.2
1010
jacksonVersion=2.15.3

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/mongo/MongoMetricsAutoConfigurationTests.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import io.micrometer.core.instrument.binder.mongodb.MongoConnectionPoolTagsProvider;
3030
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsCommandListener;
3131
import io.micrometer.core.instrument.binder.mongodb.MongoMetricsConnectionPoolListener;
32+
import org.assertj.core.api.InstanceOfAssertFactories;
3233
import org.junit.jupiter.api.Test;
3334

3435
import org.springframework.boot.actuate.autoconfigure.metrics.test.MetricsRun;
@@ -62,7 +63,7 @@ void whenThereIsAMeterRegistryThenMetricsCommandListenerIsAdded() {
6263
assertThat(context).hasSingleBean(MongoMetricsCommandListener.class);
6364
assertThat(getActualMongoClientSettingsUsedToConstructClient(context))
6465
.extracting(MongoClientSettings::getCommandListeners)
65-
.asList()
66+
.asInstanceOf(InstanceOfAssertFactories.LIST)
6667
.containsExactly(context.getBean(MongoMetricsCommandListener.class));
6768
assertThat(getMongoCommandTagsProviderUsedToConstructListener(context))
6869
.isInstanceOf(DefaultMongoCommandTagsProvider.class);
@@ -168,7 +169,7 @@ private ContextConsumer<AssertableApplicationContext> assertThatMetricsCommandLi
168169
assertThat(context).doesNotHaveBean(MongoMetricsCommandListener.class);
169170
assertThat(getActualMongoClientSettingsUsedToConstructClient(context))
170171
.extracting(MongoClientSettings::getCommandListeners)
171-
.asList()
172+
.asInstanceOf(InstanceOfAssertFactories.LIST)
172173
.isEmpty();
173174
};
174175
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/tracing/BraveAutoConfigurationTests.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -333,13 +333,13 @@ void compositeSpanHandlerUsesFilterPredicateAndReportersInOrder() {
333333
.getBean(CompositeSpanHandlerComponentsConfiguration.class);
334334
CompositeSpanHandler composite = context.getBean(CompositeSpanHandler.class);
335335
assertThat(composite).extracting("spanFilters")
336-
.asList()
336+
.asInstanceOf(InstanceOfAssertFactories.LIST)
337337
.containsExactly(components.filter1, components.filter2);
338338
assertThat(composite).extracting("filters")
339-
.asList()
339+
.asInstanceOf(InstanceOfAssertFactories.LIST)
340340
.containsExactly(components.predicate2, components.predicate1);
341341
assertThat(composite).extracting("reporters")
342-
.asList()
342+
.asInstanceOf(InstanceOfAssertFactories.LIST)
343343
.containsExactly(components.reporter1, components.reporter3, components.reporter2);
344344
});
345345
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626

2727
import jakarta.validation.Valid;
2828
import jakarta.validation.constraints.NotEmpty;
29+
import org.assertj.core.api.InstanceOfAssertFactories;
2930
import org.junit.jupiter.api.Test;
3031
import org.junit.jupiter.api.io.TempDir;
3132
import reactor.core.publisher.Mono;
@@ -143,7 +144,8 @@ void errorEndpointIsUsedWithRestControllerEndpointOnBindingError() {
143144
(value) -> assertThat(value).asString().contains("MethodArgumentNotValidException"));
144145
assertThat(body).hasEntrySatisfying("message",
145146
(value) -> assertThat(value).asString().contains("Validation failed"));
146-
assertThat(body).hasEntrySatisfying("errors", (value) -> assertThat(value).asList().isNotEmpty());
147+
assertThat(body).hasEntrySatisfying("errors",
148+
(value) -> assertThat(value).asInstanceOf(InstanceOfAssertFactories.LIST).isNotEmpty());
147149
}));
148150
}
149151

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
import javax.management.MBeanInfo;
2727
import javax.management.ReflectionException;
2828

29+
import org.assertj.core.api.InstanceOfAssertFactories;
2930
import org.junit.jupiter.api.Test;
3031
import reactor.core.publisher.Flux;
3132
import reactor.core.publisher.Mono;
@@ -165,7 +166,7 @@ void invokeWhenFluxResultShouldCollectToMonoListAndBlockOnMono() throws MBeanExc
165166
new TestJmxOperation((arguments) -> Flux.just("flux", "result")));
166167
EndpointMBean bean = new EndpointMBean(this.responseMapper, null, endpoint);
167168
Object result = bean.invoke("testOperation", NO_PARAMS, NO_SIGNATURE);
168-
assertThat(result).asList().containsExactly("flux", "result");
169+
assertThat(result).asInstanceOf(InstanceOfAssertFactories.LIST).containsExactly("flux", "result");
169170
}
170171

171172
@Test

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfigurationTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,7 +83,7 @@ void shouldUseCustomConnectionDetailsWhenDefined() {
8383
.doesNotHaveBean(PropertiesCouchbaseConnectionDetails.class);
8484
Cluster cluster = context.getBean(Cluster.class);
8585
assertThat(cluster.core()).extracting("connectionString.hosts")
86-
.asList()
86+
.asInstanceOf(InstanceOfAssertFactories.LIST)
8787
.extractingResultOf("host")
8888
.containsExactly("couchbase.example.com");
8989
});
@@ -109,7 +109,7 @@ void connectionDetailsShouldOverrideProperties() {
109109
assertThat(context).hasSingleBean(ClusterEnvironment.class).hasSingleBean(Cluster.class);
110110
Cluster cluster = context.getBean(Cluster.class);
111111
assertThat(cluster.core()).extracting("connectionString.hosts")
112-
.asList()
112+
.asInstanceOf(InstanceOfAssertFactories.LIST)
113113
.extractingResultOf("host")
114114
.containsExactly("couchbase.example.com");
115115
});

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/graphql/GraphQlAutoConfigurationTests.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,7 +126,9 @@ void shouldConfigureDataFetcherExceptionResolvers() {
126126
assertThat(graphQL.getQueryStrategy()).extracting("dataFetcherExceptionHandler")
127127
.satisfies((exceptionHandler) -> {
128128
assertThat(exceptionHandler.getClass().getName()).endsWith("ExceptionResolversExceptionHandler");
129-
assertThat(exceptionHandler).extracting("resolvers").asList().hasSize(2);
129+
assertThat(exceptionHandler).extracting("resolvers")
130+
.asInstanceOf(InstanceOfAssertFactories.LIST)
131+
.hasSize(2);
130132
});
131133
});
132134
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/kafka/KafkaAutoConfigurationIntegrationTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
2828
import org.apache.kafka.streams.kstream.KStream;
2929
import org.apache.kafka.streams.kstream.KTable;
3030
import org.apache.kafka.streams.kstream.Materialized;
31+
import org.assertj.core.api.InstanceOfAssertFactories;
3132
import org.junit.jupiter.api.AfterEach;
3233
import org.junit.jupiter.api.Test;
3334
import org.junit.jupiter.api.condition.DisabledOnOs;
@@ -115,7 +116,7 @@ void testEndToEndWithRetryTopics() throws Exception {
115116
assertThat(listener).extracting(RetryListener::getKey, RetryListener::getReceived)
116117
.containsExactly("foo", "bar");
117118
assertThat(listener).extracting(RetryListener::getTopics)
118-
.asList()
119+
.asInstanceOf(InstanceOfAssertFactories.LIST)
119120
.hasSize(5)
120121
.containsSequence("testRetryTopic", "testRetryTopic-retry-0", "testRetryTopic-retry-1",
121122
"testRetryTopic-retry-2");

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/pulsar/PulsarAutoConfigurationTests.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import org.apache.pulsar.client.api.ReaderBuilder;
2828
import org.apache.pulsar.client.api.interceptor.ProducerInterceptor;
2929
import org.apache.pulsar.common.schema.SchemaType;
30+
import org.assertj.core.api.InstanceOfAssertFactories;
3031
import org.junit.jupiter.api.Nested;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.api.condition.EnabledForJreRange;
@@ -287,7 +288,7 @@ void whenHasUseDefinedProducerInterceptorInjectsBean() {
287288
this.contextRunner.withBean("customProducerInterceptor", ProducerInterceptor.class, () -> interceptor)
288289
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
289290
.extracting("interceptors")
290-
.asList()
291+
.asInstanceOf(InstanceOfAssertFactories.LIST)
291292
.contains(interceptor));
292293
}
293294

@@ -296,7 +297,7 @@ void whenHasUseDefinedProducerInterceptorsInjectsBeansInCorrectOrder() {
296297
this.contextRunner.withUserConfiguration(InterceptorTestConfiguration.class)
297298
.run((context) -> assertThat(context).getBean(PulsarTemplate.class)
298299
.extracting("interceptors")
299-
.asList()
300+
.asInstanceOf(InstanceOfAssertFactories.LIST)
300301
.containsExactly(context.getBean("interceptorBar"), context.getBean("interceptorFoo")));
301302
}
302303

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/oauth2/resource/servlet/OAuth2ResourceServerAutoConfigurationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -424,7 +424,7 @@ void autoConfigurationWhenJwkSetUriAndIntrospectionUriAvailable() {
424424
assertThat(context).hasSingleBean(OpaqueTokenIntrospector.class);
425425
assertThat(context).hasSingleBean(JwtDecoder.class);
426426
assertThat(getBearerTokenFilter(context)).extracting("authenticationManagerResolver.arg$1.providers")
427-
.asList()
427+
.asInstanceOf(InstanceOfAssertFactories.LIST)
428428
.hasAtLeastOneElementOfType(JwtAuthenticationProvider.class);
429429
});
430430
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizationAutoConfigurationTests.java

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
1818

1919
import java.util.Collections;
2020

21+
import org.assertj.core.api.InstanceOfAssertFactories;
2122
import org.junit.jupiter.api.Test;
2223

2324
import org.springframework.boot.autoconfigure.AutoConfigurations;
@@ -42,7 +43,7 @@ void autoConfiguresTransactionManagerCustomizers() {
4243
this.contextRunner.run((context) -> {
4344
TransactionManagerCustomizers customizers = context.getBean(TransactionManagerCustomizers.class);
4445
assertThat(customizers).extracting("customizers")
45-
.asList()
46+
.asInstanceOf(InstanceOfAssertFactories.LIST)
4647
.hasSize(2)
4748
.hasAtLeastOneElementOfType(TransactionProperties.class)
4849
.hasAtLeastOneElementOfType(ExecutionListenersTransactionManagerCustomizer.class);
@@ -54,7 +55,9 @@ void autoConfiguredTransactionManagerCustomizersBacksOff() {
5455
this.contextRunner.withUserConfiguration(CustomTransactionManagerCustomizersConfiguration.class)
5556
.run((context) -> {
5657
TransactionManagerCustomizers customizers = context.getBean(TransactionManagerCustomizers.class);
57-
assertThat(customizers).extracting("customizers").asList().isEmpty();
58+
assertThat(customizers).extracting("customizers")
59+
.asInstanceOf(InstanceOfAssertFactories.LIST)
60+
.isEmpty();
5861
});
5962
}
6063

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/WebFluxAutoConfigurationTests.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -198,7 +198,9 @@ void shouldMapResourcesToCustomPath() {
198198
SimpleUrlHandlerMapping hm = context.getBean("resourceHandlerMapping", SimpleUrlHandlerMapping.class);
199199
assertThat(hm.getUrlMap().get("/static/**")).isInstanceOf(ResourceWebHandler.class);
200200
ResourceWebHandler staticHandler = (ResourceWebHandler) hm.getUrlMap().get("/static/**");
201-
assertThat(staticHandler).extracting("locationValues").asList().hasSize(4);
201+
assertThat(staticHandler).extracting("locationValues")
202+
.asInstanceOf(InstanceOfAssertFactories.LIST)
203+
.hasSize(4);
202204
});
203205
}
204206

@@ -599,7 +601,7 @@ void userConfigurersCanBeOrderedBeforeOrAfterTheAutoConfiguredConfigurer() {
599601
.withBean(LowPrecedenceConfigurer.class, LowPrecedenceConfigurer::new)
600602
.run((context) -> assertThat(context.getBean(DelegatingWebFluxConfiguration.class))
601603
.extracting("configurers.delegates")
602-
.asList()
604+
.asInstanceOf(InstanceOfAssertFactories.LIST)
603605
.extracting((configurer) -> (Class) configurer.getClass())
604606
.containsExactly(HighPrecedenceConfigurer.class, WebFluxConfig.class, LowPrecedenceConfigurer.class));
605607
}

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/AbstractJsonMarshalTesterTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,6 +28,7 @@
2828
import java.util.List;
2929
import java.util.Map;
3030

31+
import org.assertj.core.api.InstanceOfAssertFactories;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.api.io.TempDir;
3334

@@ -152,7 +153,7 @@ void readReaderShouldReturnObject() throws Exception {
152153
void parseListShouldReturnContent() throws Exception {
153154
ResolvableType type = ResolvableTypes.get("listOfExampleObject");
154155
AbstractJsonMarshalTester<Object> tester = createTester(type);
155-
assertThat(tester.parse(ARRAY_JSON)).asList().containsOnly(OBJECT);
156+
assertThat(tester.parse(ARRAY_JSON)).asInstanceOf(InstanceOfAssertFactories.LIST).containsOnly(OBJECT);
156157
}
157158

158159
@Test

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/GsonTesterIntegrationTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import com.google.gson.Gson;
24+
import org.assertj.core.api.InstanceOfAssertFactories;
2425
import org.junit.jupiter.api.BeforeEach;
2526
import org.junit.jupiter.api.Test;
2627

@@ -61,7 +62,7 @@ void typicalTest() throws Exception {
6162
@Test
6263
void typicalListTest() throws Exception {
6364
String example = "[" + JSON + "]";
64-
assertThat(this.listJson.parse(example)).asList().hasSize(1);
65+
assertThat(this.listJson.parse(example)).asInstanceOf(InstanceOfAssertFactories.LIST).hasSize(1);
6566
assertThat(this.listJson.parse(example).getObject().get(0).getName()).isEqualTo("Spring");
6667
}
6768

spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/JacksonTesterIntegrationTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import com.fasterxml.jackson.databind.MapperFeature;
2626
import com.fasterxml.jackson.databind.ObjectMapper;
2727
import com.fasterxml.jackson.databind.json.JsonMapper;
28+
import org.assertj.core.api.InstanceOfAssertFactories;
2829
import org.junit.jupiter.api.Test;
2930

3031
import org.springframework.core.io.ByteArrayResource;
@@ -63,7 +64,7 @@ void typicalTest() throws Exception {
6364
void typicalListTest() throws Exception {
6465
JacksonTester.initFields(this, new ObjectMapper());
6566
String example = "[" + JSON + "]";
66-
assertThat(this.listJson.parse(example)).asList().hasSize(1);
67+
assertThat(this.listJson.parse(example)).asInstanceOf(InstanceOfAssertFactories.LIST).hasSize(1);
6768
assertThat(this.listJson.parse(example).getObject().get(0).getName()).isEqualTo("Spring");
6869
}
6970

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigDataEnvironmentTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@
2727
import java.util.Map;
2828
import java.util.function.Supplier;
2929

30+
import org.assertj.core.api.InstanceOfAssertFactories;
3031
import org.junit.jupiter.api.Disabled;
3132
import org.junit.jupiter.api.Test;
3233
import org.junit.jupiter.api.TestInfo;
@@ -354,7 +355,7 @@ public Enumeration<URL> getResources(String name) throws IOException {
354355
TestConfigDataEnvironment configDataEnvironment = new TestConfigDataEnvironment(this.logFactory,
355356
this.bootstrapContext, this.environment, resourceLoader, this.additionalProfiles, null);
356357
assertThat(configDataEnvironment).extracting("loaders.loaders")
357-
.asList()
358+
.asInstanceOf(InstanceOfAssertFactories.LIST)
358359
.extracting((item) -> (Class) item.getClass())
359360
.containsOnly(SeparateClassLoaderConfigDataLoader.class);
360361
}

0 commit comments

Comments
 (0)