Skip to content

Commit 9e8c640

Browse files
committed
Make JsonPathAssertions#isEqualTo parameter nullable
Closes gh-35445
1 parent ebb8e34 commit 9e8c640

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

spring-test/src/main/java/org/springframework/test/web/reactive/server/JsonPathAssertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class JsonPathAssertions {
5656
/**
5757
* Applies {@link JsonPathExpectationsHelper#assertValue(String, Object)}.
5858
*/
59-
public WebTestClient.BodyContentSpec isEqualTo(Object expectedValue) {
59+
public WebTestClient.BodyContentSpec isEqualTo(@Nullable Object expectedValue) {
6060
this.pathHelper.assertValue(this.content, expectedValue);
6161
return this.bodySpec;
6262
}

spring-test/src/test/java/org/springframework/test/util/JsonPathExpectationsHelperTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class JsonPathExpectationsHelperTests {
5757
'whitespace': ' ',
5858
'emptyString': '',
5959
'emptyArray': [],
60-
'emptyMap': {}
60+
'emptyMap': {},
61+
'nullValue': null
6162
}""";
6263

6364
private static final String SIMPSONS = """
@@ -249,6 +250,11 @@ void assertValue() {
249250
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5);
250251
}
251252

253+
@Test
254+
void assertNullValue() {
255+
new JsonPathExpectationsHelper("$.nullValue").assertValue(CONTENT, (Object) null);
256+
}
257+
252258
@Test // SPR-14498
253259
void assertValueWithNumberConversion() {
254260
new JsonPathExpectationsHelper("$.num").assertValue(CONTENT, 5.0);

0 commit comments

Comments
 (0)