File tree Expand file tree Collapse file tree
src/main/java/it/aboutbits/springboot/testing/web/response Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package it .aboutbits .springboot .testing .web .response ;
22
33import com .jayway .jsonpath .JsonPath ;
4+ import org .jspecify .annotations .NullMarked ;
45import org .springframework .test .web .servlet .ResultMatcher ;
56import tools .jackson .databind .json .JsonMapper ;
67
1516import static org .assertj .core .api .Assertions .assertThatCode ;
1617import static org .assertj .core .api .Assertions .fail ;
1718
19+ @ NullMarked
1820public final class ResponseBodyMatchers {
19- private static final JsonMapper jsonMapper = new JsonMapper ();
21+ private static final JsonMapper JSON_MAPPER = new JsonMapper ();
2022 private final String jsonPath ;
2123
2224 private String [] fieldNamesToIgnore = new String [0 ];
@@ -50,7 +52,7 @@ public <T> ResultMatcher containsObjectAsJson(
5052 try {
5153 var json = mvcResult .getResponse ().getContentAsString ();
5254 var extractedValue = JsonPath .read (json , jsonPath );
53- T actualObject = jsonMapper .readValue (jsonMapper .writeValueAsString (extractedValue ), targetClass );
55+ T actualObject = JSON_MAPPER .readValue (JSON_MAPPER .writeValueAsString (extractedValue ), targetClass );
5456
5557 var ignoredFields = new ArrayList <>(Arrays .asList (fieldNamesToIgnore ));
5658 ignoredFields .addAll (Arrays .asList (optionalFieldNamesToIgnore ));
You can’t perform that action at this time.
0 commit comments