diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java index acea1d3ae61..f758846b037 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java @@ -56,7 +56,7 @@ public class JsonPathAssertions { /** * Applies {@link JsonPathExpectationsHelper#assertValue(String, Object)}. */ - public WebTestClient.BodyContentSpec isEqualTo(Object expectedValue) { + public WebTestClient.BodyContentSpec isEqualTo(@Nullable Object expectedValue) { this.pathHelper.assertValue(this.content, expectedValue); return this.bodySpec; } diff --git a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java index 21cdc4a1d4e..964da8655cc 100644 --- a/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java +++ b/spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java @@ -57,7 +57,8 @@ class JsonPathExpectationsHelperTests { 'whitespace': ' ', 'emptyString': '', 'emptyArray': [], - 'emptyMap': {} + 'emptyMap': {}, + 'nullValue': null }"""; private static final String SIMPSONS = """ @@ -249,6 +250,11 @@ class JsonPathExpectationsHelperTests { new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5); } + @Test + void assertNullValue() { + new JsonPathExpectationsHelper("$.nullValue").assertValue(CONTENT, (Object) null); + } + @Test // SPR-14498 void assertValueWithNumberConversion() { new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5.0);