Class HttpResponseMatcher
HttpResponse against a template HttpResponse.
Each template field constrains the match only when it is set (non-null/non-blank). A null or empty template matches any response.
Body matching shares the exact dispatch used by request matching via BodyMatching, so a
response body matcher has full parity with a request body matcher: XML/form actual bodies are
converted to JSON for the JSON family of matchers, an optional template body matches an absent
response body, multipart and binary (including original/compressed) bodies are handled, and an
absent actual body against a JSON/XML matcher is a clean non-match rather than a swallowed NPE.
Cookie matching mirrors the request matcher: when the template declares structured cookies they
are matched (sub-set semantics, extra response cookies allowed, notted values supported) via the
same HashMapMatcher the request side uses.
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResponseMatcher(Configuration configuration, MockServerLogger mockServerLogger, HttpResponse template) -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(MatchDifference context, HttpResponse actual) Returnstruewhen the actual response matches the template, recording per-field differences intocontextwhen it is non-null.booleanmatches(HttpResponse actual) Returnstruewhen the actual response matches the template.
-
Constructor Details
-
HttpResponseMatcher
public HttpResponseMatcher(Configuration configuration, MockServerLogger mockServerLogger, HttpResponse template)
-
-
Method Details
-
matches
Returnstruewhen the actual response matches the template. A null template matches everything. -
matches
Returnstruewhen the actual response matches the template, recording per-field differences intocontextwhen it is non-null. The boolean result is identical tomatches(HttpResponse).Response fields are bucketed onto existing
MatchDifference.Fieldconstants rather than introducing new enum constants:Fieldis the shared field vocabulary established by the request matcher, and any code that enumeratesField.values()would observe a longer array if response-only constants were added. statusCode and reasonPhrase both record underMatchDifference.Field.OPERATION(a neutral bucket); headers, cookies and body use their naturalMatchDifference.Field.HEADERS,MatchDifference.Field.COOKIESandMatchDifference.Field.BODYbuckets.
-