Uh oh!
There was an error while loading. Please reload this page.
Add response body matchers - #37
Conversation
| return this; | ||
| } | ||
| public ResponseBodyMatchers ignoringAudition() { |
There was a problem hiding this comment.
ignoringAudition()/ignoreAudition look like a typo — the fields being excluded (createdAt, createdBy, updatedAt, updatedBy) are audit fields, not "audition" fields. Worth renaming to ignoringAuditFields()/ignoreAuditFields.
| try { | ||
| var json = mvcResult.getResponse().getContentAsString(); | ||
| var extractedValue = JsonPath.read(json, jsonPath); | ||
| T actualObject = JSON_MAPPER.readValue(JSON_MAPPER.writeValueAsString(extractedValue), targetClass); |
There was a problem hiding this comment.
According to AI you could use JSON_MAPPER.convertValue(extractedValue, targetClass) instead of serializing to a string and re-parsing — same result, avoids a redundant JSON round-trip. Can you check that proposal?
There was a problem hiding this comment.
Tested it in Aichner and EMVA and it works. So I will change it as suggested
| } | ||
| public ResponseBodyMatchers ignoringAuditFields() { | ||
| this.ignoreAudition = true; |
There was a problem hiding this comment.
| this.ignoreAudition = true; | |
| this.ignoringAuditFields = true; |
Uh oh!
There was an error while loading. Please reload this page.
I know that we return the response object and test against that directly with normal assert methods in newer projects, but in older ones we use this body matcher instead. I found a bug in EMVA and instead of fixing it also in Aichner, it would be better to move it to the lib and deprecate both copy/paste implementations in each project