Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected AbstractJsonPathAssertions(B spec, String content, String expression,
/**
* Applies {@link JsonPathExpectationsHelper#assertValue(String, Object)}.
*/
public B isEqualTo(Object expectedValue) {
public B isEqualTo(@Nullable Object expectedValue) {
this.pathHelper.assertValue(this.content, expectedValue);
return this.bodySpec;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.springframework.test.web.servlet.client;

import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -192,6 +193,14 @@ void isArray() {
.jsonPath("$.composers").isArray();
}

@Test
void isEqualToWithNull() {
client.get().uri("/music/null")
.exchange()
.expectBody()
.jsonPath("$.value").isEqualTo(null);
}

@RestController
private static class MusicController {
@GetMapping("/music/instruments")
Expand All @@ -213,6 +222,15 @@ public MultiValueMap<String, Person> get() {

return map;
}

@GetMapping("/music/null")
public Map<String, Object> getNull() {
Map<String, Object> map = new LinkedHashMap<>();

map.put("value", null);

return map;
}
}

}