Package com.easypost.easyvcr
Class MatchRules
java.lang.Object
com.easypost.easyvcr.MatchRules
Rule set for matching requests against recorded requests.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd a rule to compare the base URLs of the requests.byBody()Add a rule to compare the bodies of the requests.byBody(List<CensorElement> ignoredElements)Add a rule to compare the bodies of the requests.Add a rule to compare the entire requests.Add a rule to compare the full URLs (including query parameters) of the requests.byFullUrl(boolean exact)Add a rule to compare the full URLs (including query parameters) of the requests.Add a rule to compare a specific header of the requests.Add a rule to compare the headers of the requests.byHeaders(boolean exact)Add a rule to compare the headers of the requests.byMethod()Add a rule to compare the HTTP methods of the requests.static MatchRulesregular()Default rule is to match on the method and URL.booleanrequestsMatch(Request receivedRequest, Request recordedRequest)Execute rules to determine if the received request matches the recorded request.static MatchRulesstrict()Default strict rule is to match on the method, URL and body.
-
Constructor Details
-
MatchRules
public MatchRules()Construct a new MatchRules factory.
-
-
Method Details
-
regular
Default rule is to match on the method and URL.- Returns:
- Default MatchRules object.
-
strict
Default strict rule is to match on the method, URL and body.- Returns:
- Default strict MatchRules object.
-
byBaseUrl
Add a rule to compare the base URLs of the requests.- Returns:
- This MatchRules factory.
-
byBody
Add a rule to compare the bodies of the requests.- Parameters:
ignoredElements- List of body elements to ignore when comparing the requests.- Returns:
- This MatchRules factory.
-
byBody
Add a rule to compare the bodies of the requests.- Returns:
- This MatchRules factory.
-
byEverything
Add a rule to compare the entire requests. Note, this rule is very strict, and will fail if the requests are not identical (including duration). It is highly recommended to use the other rules to compare the requests.- Returns:
- This MatchRules factory.
-
byFullUrl
Add a rule to compare the full URLs (including query parameters) of the requests. Default: query parameter order does not matter.- Returns:
- This MatchRules factory.
-
byFullUrl
Add a rule to compare the full URLs (including query parameters) of the requests.- Parameters:
exact- If true, query parameters must be in the same exact order to match. If false, query parameter order doesn't matter.- Returns:
- This MatchRules factory.
-
byHeader
Add a rule to compare a specific header of the requests.- Parameters:
name- Key of the header to compare.- Returns:
- This MatchRules factory.
-
byHeaders
Add a rule to compare the headers of the requests. Default: headers strictness is set to false.- Returns:
- This MatchRules factory.
-
byHeaders
Add a rule to compare the headers of the requests.- Parameters:
exact- If true, both requests must have the exact same headers. If false, as long as the evaluated request has all the headers of the matching request (and potentially more), the match is considered valid.- Returns:
- This MatchRules factory.
-
byMethod
Add a rule to compare the HTTP methods of the requests.- Returns:
- This MatchRules factory.
-
requestsMatch
Execute rules to determine if the received request matches the recorded request.- Parameters:
receivedRequest- Request to find a match for.recordedRequest- Request to compare against.- Returns:
- True if the received request matches the recorded request, false otherwise.
-