Skip to content

Commit 8aebfb5

Browse files
author
khope
committed
Add JsonPathAssertionsTest isEqualTo with @nullable
Signed-off-by: khope <[email protected]>
1 parent 085c309 commit 8aebfb5

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spring-test/src/test/java/org/springframework/test/web/servlet/client/JsonPathAssertionTests.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.util.Arrays;
2020
import java.util.List;
2121
import java.util.Map;
22+
import java.util.LinkedHashMap
2223

2324
import org.junit.jupiter.api.Test;
2425

@@ -192,6 +193,14 @@ void isArray() {
192193
.jsonPath("$.composers").isArray();
193194
}
194195

196+
@Test
197+
void isEqualToWithNull() {
198+
client.get().uri("/music/null")
199+
.exchange()
200+
.expectBody()
201+
.jsonPath("$.value").isEqualTo(null);
202+
}
203+
195204
@RestController
196205
private static class MusicController {
197206
@GetMapping("/music/instruments")
@@ -213,6 +222,12 @@ public MultiValueMap<String, Person> get() {
213222

214223
return map;
215224
}
225+
@GetMapping("/music/null")
226+
public Map<String, Object> getNull() {
227+
Map<String, Object> map = new LinkedHashMap<>();
228+
map.put("value", null);
229+
return map;
230+
}
216231
}
217232

218233
}

0 commit comments

Comments
 (0)