- a
filterwhich controls whether the rule is applied to the generated stub. This is optional - if omitted the template will always be applied. - a
templatewhich generates request matchers to apply to the stub
filter which matches the recorded request will be used to generate
matchers, which will be added in turn to the generated stub.
When more than one rule could both match and specify different matchers for the same element (for instance the first
specifies that the Content-Type header is equalTo "application/json", and the second that the Content-Type
header contains "json"), the last defined rule will win.
Finally a check is made that the generated stub would still match the recorded request from which it was generated. If
it would not the entire stub is discarded and no stub is generated at all for that request.
Templating
Where matchers have a right hand side the{{ recordedValue }} macro may be used to capture what that value had
on the recorded request. For instance, the following rule:
request
Limitations
-
At present no logic other than replacement of the
{{ recordedValue }}macro can be applied in the template, though request matchers can be hard coded. -
The
{{ recordedValue }}macro cannot currently be used in anequalToJson,equalToXmlormatchingrequest matcher. -
The
filteronly contains arequestmatcher - it is not yet possible to apply rules conditionally based on the response. -
The
templateonly contains arequestmatcher - it is not yet possible to define changes to the response definition in these rules.