Skip to content

Commit 3848bd3

Browse files
committed
fix reviewed issues
1 parent d24fd80 commit 3848bd3

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

src/main/java/it/aboutbits/springboot/testing/web/response/ResponseBodyMatchers.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ private ResponseBodyMatchers(String jsonPath) {
2929
this.jsonPath = jsonPath;
3030
}
3131

32+
public static ResponseBodyMatchers responseBody() {
33+
return new ResponseBodyMatchers("$");
34+
}
35+
36+
public static ResponseBodyMatchers responseBodyAt(String expression) {
37+
return new ResponseBodyMatchers(expression);
38+
}
39+
3240
public ResponseBodyMatchers ignoringOptionalFields(String... optionalFieldNamesToIgnore) {
3341
this.optionalFieldNamesToIgnore = optionalFieldNamesToIgnore;
3442
return this;
@@ -39,7 +47,7 @@ public ResponseBodyMatchers ignoringFields(String... fieldNamesToIgnore) {
3947
return this;
4048
}
4149

42-
public ResponseBodyMatchers ignoringAudition() {
50+
public ResponseBodyMatchers ignoringAuditFields() {
4351
this.ignoreAudition = true;
4452
return this;
4553
}
@@ -52,7 +60,7 @@ public <T> ResultMatcher containsObjectAsJson(
5260
try {
5361
var json = mvcResult.getResponse().getContentAsString();
5462
var extractedValue = JsonPath.read(json, jsonPath);
55-
T actualObject = JSON_MAPPER.readValue(JSON_MAPPER.writeValueAsString(extractedValue), targetClass);
63+
T actualObject = JSON_MAPPER.convertValue(extractedValue, targetClass);
5664

5765
var ignoredFields = new ArrayList<>(Arrays.asList(fieldNamesToIgnore));
5866
ignoredFields.addAll(Arrays.asList(optionalFieldNamesToIgnore));
@@ -87,12 +95,4 @@ private static int compareTemporalByDelta(OffsetDateTime a, OffsetDateTime b) {
8795
private static int compareTemporalByDelta(LocalDateTime a, LocalDateTime b) {
8896
return Math.abs(ChronoUnit.NANOS.between(a, b)) < 1000 ? 0 : a.compareTo(b);
8997
}
90-
91-
public static ResponseBodyMatchers responseBody() {
92-
return new ResponseBodyMatchers("$");
93-
}
94-
95-
public static ResponseBodyMatchers responseBodyAt(String expression) {
96-
return new ResponseBodyMatchers(expression);
97-
}
9898
}

0 commit comments

Comments
 (0)