Skip to content

Add response body matchers#37

Open
Piiit wants to merge 4 commits into
mainfrom
pm-add-response-body-matchers
Open

Add response body matchers#37
Piiit wants to merge 4 commits into
mainfrom
pm-add-response-body-matchers

Conversation

@Piiit

@Piiit Piiit commented Jul 15, 2026

Copy link
Copy Markdown
Member

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

@Piiit Piiit self-assigned this Jul 15, 2026
@Piiit Piiit requested a review from mmalfertheiner July 15, 2026 07:55
return this;
}

public ResponseBodyMatchers ignoringAudition() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants