From 6d824586bb04a31f75407f9f325c01f6de085c36 Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Mon, 20 Oct 2025 15:31:43 +0200 Subject: [PATCH] Polishing contribution Fixes gh-35659 --- .../java/org/springframework/http/HttpStatusTests.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java index 5eabdde97a0..3864953fb60 100644 --- a/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java +++ b/spring-web/src/test/java/org/springframework/http/HttpStatusTests.java @@ -28,7 +28,9 @@ import org.springframework.util.MultiValueMap; import static org.assertj.core.api.Assertions.assertThat; /** + * Tests for {@link HttpStatus}. * @author Arjen Poutsma + * @author Brian Clozel */ class HttpStatusTests { @@ -109,12 +111,18 @@ class HttpStatusTests { @Test - void fromMapToEnum() { + void fromMapToEnum() throws Exception { for (Map.Entry> entry : statusCodes.entrySet()) { int value = entry.getKey(); HttpStatus status = HttpStatus.valueOf(value); assertThat(status.value()).as("Invalid value").isEqualTo(value); assertThat(entry.getValue()).as("Invalid name for [" + value + "]").contains(status.name()); + Deprecated deprecatedAnnotation = HttpStatus.class.getField(status.name()).getAnnotation(Deprecated.class); + if (deprecatedAnnotation != null) { + assertThat(statusCodes.get(entry.getKey())) + .as("Should not resolve deprecated enum value when non-deprecated exists") + .hasSize(1); + } } }