Skip to content

Commit ffddbb5

Browse files
committed
Upgrade to AssertJ 3.25.0
1 parent a3c11fc commit ffddbb5

File tree

5 files changed

+20
-15
lines changed

5 files changed

+20
-15
lines changed

framework-platform/framework-platform.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ dependencies {
109109
api("org.aspectj:aspectjrt:1.9.21")
110110
api("org.aspectj:aspectjtools:1.9.21")
111111
api("org.aspectj:aspectjweaver:1.9.21")
112-
api("org.assertj:assertj-core:3.24.2")
112+
api("org.assertj:assertj-core:3.25.0")
113113
api("org.awaitility:awaitility:4.2.0")
114114
api("org.bouncycastle:bcpkix-jdk18on:1.72")
115115
api("org.codehaus.jettison:jettison:1.5.4")

spring-beans/src/test/java/org/springframework/beans/factory/config/YamlProcessorTests.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.Map;
2424
import java.util.Set;
2525

26+
import org.assertj.core.api.InstanceOfAssertFactories;
2627
import org.junit.jupiter.api.Test;
2728
import org.yaml.snakeyaml.composer.ComposerException;
2829
import org.yaml.snakeyaml.parser.ParserException;
@@ -145,10 +146,11 @@ void flattenedMapIsSameAsPropertiesButOrdered() {
145146
void standardTypesSupportedByDefault() {
146147
setYaml("value: !!set\n ? first\n ? second");
147148
this.processor.process((properties, map) -> {
148-
assertThat(properties).containsExactly(entry("value[0]", "first"), entry("value[1]", "second"));
149-
assertThat(map.get("value")).isInstanceOf(Set.class);
150-
Set<String> set = (Set<String>) map.get("value");
151-
assertThat(set).containsExactly("first", "second");
149+
// Assert on Properties as a Map due to bug in AssertJ 3.25.0
150+
Map<Object, Object> propsAsMap = new LinkedHashMap<>(properties);
151+
assertThat(propsAsMap).containsExactly(entry("value[0]", "first"), entry("value[1]", "second"));
152+
assertThat(map.get("value")).asInstanceOf(InstanceOfAssertFactories.type(Set.class))
153+
.satisfies(set -> assertThat(set).containsExactly("first", "second"));
152154
});
153155
}
154156

spring-context/src/test/java/org/springframework/context/annotation/ImportSelectorTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-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.
@@ -51,6 +51,7 @@
5151
import org.springframework.util.MultiValueMap;
5252

5353
import static org.assertj.core.api.Assertions.assertThat;
54+
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
5455
import static org.mockito.ArgumentMatchers.any;
5556
import static org.mockito.ArgumentMatchers.eq;
5657
import static org.mockito.Mockito.inOrder;
@@ -126,7 +127,7 @@ public void importSelectorsWithGroup() {
126127
ordered.verify(beanFactory).registerBeanDefinition(eq("d"), any());
127128
assertThat(TestImportGroup.instancesCount.get()).isEqualTo(1);
128129
assertThat(TestImportGroup.imports).hasSize(1);
129-
assertThat(TestImportGroup.imports.values()).element(0).asList().hasSize(2);
130+
assertThat(TestImportGroup.imports.values()).element(0).asInstanceOf(LIST).hasSize(2);
130131
}
131132

132133
@Test

spring-core-test/src/test/java/org/springframework/aot/agent/RecordedInvocationTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-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.
@@ -19,6 +19,7 @@
1919

2020
import java.lang.reflect.Method;
2121

22+
import org.assertj.core.api.ThrowableAssert.ThrowingCallableWithValue;
2223
import org.junit.jupiter.api.BeforeEach;
2324
import org.junit.jupiter.api.Test;
2425

@@ -63,7 +64,7 @@ void buildValidStaticInvocation() {
6364

6465
@Test
6566
void staticInvocationShouldThrowWhenGetInstance() {
66-
assertThatThrownBy(staticInvocation::getInstance).isInstanceOf(IllegalStateException.class);
67+
assertThatThrownBy((ThrowingCallableWithValue) staticInvocation::getInstance).isInstanceOf(IllegalStateException.class);
6768
assertThatThrownBy(staticInvocation::getInstanceTypeReference).isInstanceOf(IllegalStateException.class);
6869
}
6970

spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ExceptionHandlerExceptionResolverTests.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-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.
@@ -64,6 +64,7 @@
6464
import org.springframework.web.testfixture.servlet.MockHttpServletResponse;
6565

6666
import static org.assertj.core.api.Assertions.assertThat;
67+
import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
6768

6869
/**
6970
* Test fixture with {@link ExceptionHandlerExceptionResolver}.
@@ -75,7 +76,7 @@
7576
* @author Rodolphe Lecocq
7677
*/
7778
@SuppressWarnings("unused")
78-
public class ExceptionHandlerExceptionResolverTests {
79+
class ExceptionHandlerExceptionResolverTests {
7980

8081
private static int DEFAULT_RESOLVER_COUNT;
8182

@@ -89,15 +90,15 @@ public class ExceptionHandlerExceptionResolverTests {
8990

9091

9192
@BeforeAll
92-
public static void setupOnce() {
93+
static void setupOnce() {
9394
ExceptionHandlerExceptionResolver resolver = new ExceptionHandlerExceptionResolver();
9495
resolver.afterPropertiesSet();
9596
DEFAULT_RESOLVER_COUNT = resolver.getArgumentResolvers().getResolvers().size();
9697
DEFAULT_HANDLER_COUNT = resolver.getReturnValueHandlers().getHandlers().size();
9798
}
9899

99100
@BeforeEach
100-
public void setup() throws Exception {
101+
void setup() throws Exception {
101102
this.resolver = new ExceptionHandlerExceptionResolver();
102103
this.resolver.setWarnLogCategory(this.resolver.getClass().getName());
103104
this.request = new MockHttpServletRequest("GET", "/");
@@ -146,9 +147,9 @@ void setCustomReturnValueHandlers() {
146147
@Test
147148
void setResponseBodyAdvice() {
148149
this.resolver.setResponseBodyAdvice(Collections.singletonList(new JsonViewResponseBodyAdvice()));
149-
assertThat(this.resolver).extracting("responseBodyAdvice").asList().hasSize(1);
150+
assertThat(this.resolver).extracting("responseBodyAdvice").asInstanceOf(LIST).hasSize(1);
150151
this.resolver.setResponseBodyAdvice(Collections.singletonList(new CustomResponseBodyAdvice()));
151-
assertThat(this.resolver).extracting("responseBodyAdvice").asList().hasSize(2);
152+
assertThat(this.resolver).extracting("responseBodyAdvice").asInstanceOf(LIST).hasSize(2);
152153
}
153154

154155
@Test

0 commit comments

Comments
 (0)