Package org.mockserver.model
Class HttpResponseModifier
java.lang.Object
org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
org.mockserver.model.ObjectWithJsonToString
org.mockserver.model.HttpResponseModifier
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTo(HttpResponse response, HttpRequest request) Apply this modifier toresponse, honouring any condition and chain.booleancom.fasterxml.jackson.databind.JsonNodecom.fasterxml.jackson.databind.JsonNodeinthashCode()static HttpResponseModifierwithCondition(HttpResponseModifierCondition condition) Restrict this modifier so it only applies when the supplied condition holds against the in-flight response (and, where available, the original request).withCookies(CookiesModifier cookies) withHeaders(HeadersModifier headers) withJsonMergePatch(com.fasterxml.jackson.databind.JsonNode jsonMergePatch) Apply an RFC 7386 JSON Merge Patch document to the forwarded response body when that body is valid JSON.withJsonMergePatch(String jsonMergePatch) Convenience overload accepting the RFC 7386 JSON Merge Patch document as a JSON string.withJsonPatch(com.fasterxml.jackson.databind.JsonNode jsonPatch) Apply an RFC 6902 JSON Patch document (an array ofadd/remove/replace/move/copy/testoperations) to the forwarded response body when that body is valid JSON.withJsonPatch(String jsonPatch) Convenience overload accepting the RFC 6902 JSON Patch document as a JSON string.withModifiers(List<HttpResponseModifier> modifiers) Configure an ordered chain of modifiers.Methods inherited from class org.mockserver.model.ObjectWithJsonToString
toStringMethods inherited from class org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
fieldsExcludedFromEqualsAndHashCode
-
Constructor Details
-
HttpResponseModifier
public HttpResponseModifier()
-
-
Method Details
-
responseModifier
-
getHeaders
-
withHeaders
-
withHeaders
-
getCookies
-
withCookies
-
withCookies
-
getCondition
-
withCondition
Restrict this modifier so it only applies when the supplied condition holds against the in-flight response (and, where available, the original request). Whennullthe modifier always applies — the historical behaviour. -
getModifiers
-
withModifiers
Configure an ordered chain of modifiers. Each is applied in order to the same response, so a later modifier observes the output of the earlier ones. When a chain is present theheaders/cookiesof this (wrapping) modifier are ignored — the chain is the unit of work; the wrapping modifier'sconditionstill gates the whole chain. -
getJsonPatch
public com.fasterxml.jackson.databind.JsonNode getJsonPatch() -
withJsonPatch
Apply an RFC 6902 JSON Patch document (an array ofadd/remove/replace/move/copy/testoperations) to the forwarded response body when that body is valid JSON. Whennullthe body is left untouched. If the body is not valid JSON, or the patch cannot be applied (e.g. atestoperation fails), the body is left unchanged. -
withJsonPatch
Convenience overload accepting the RFC 6902 JSON Patch document as a JSON string.- Throws:
IllegalArgumentException- if the string is not valid JSON
-
getJsonMergePatch
public com.fasterxml.jackson.databind.JsonNode getJsonMergePatch() -
withJsonMergePatch
public HttpResponseModifier withJsonMergePatch(com.fasterxml.jackson.databind.JsonNode jsonMergePatch) Apply an RFC 7386 JSON Merge Patch document to the forwarded response body when that body is valid JSON. Members present in the patch overwrite (or, whennull, delete) the corresponding members of the body; everything else is left as-is. Whennullthe body is left untouched. If the body is not valid JSON, or the merge cannot be applied, the body is left unchanged. -
withJsonMergePatch
Convenience overload accepting the RFC 7386 JSON Merge Patch document as a JSON string.- Throws:
IllegalArgumentException- if the string is not valid JSON
-
applyTo
Apply this modifier toresponse, honouring any condition and chain.Evaluation order:
- Parameters:
response- the in-flight response to mutate in placerequest- the original request (may benullwhen not available)
-
equals
- Overrides:
equalsin classObjectWithReflectiveEqualsHashCodeToString
-
hashCode
public int hashCode()- Overrides:
hashCodein classObjectWithReflectiveEqualsHashCodeToString
-