Package org.mockserver.matchers
Class HttpRequestPropertiesMatcher
- java.lang.Object
-
- org.mockserver.model.ObjectWithReflectiveEqualsHashCodeToString
-
- org.mockserver.matchers.NotMatcher<RequestDefinition>
-
- org.mockserver.matchers.AbstractHttpRequestMatcher
-
- org.mockserver.matchers.HttpRequestPropertiesMatcher
-
- All Implemented Interfaces:
HttpRequestMatcher,Matcher<RequestDefinition>
public class HttpRequestPropertiesMatcher extends AbstractHttpRequestMatcher
Matches HTTP request properties against expectation criteria.Null/Blank Matcher Behavior: When a specific matcher (e.g., method, path, headers) is null or blank, it matches all values for that property. This allows expectations to match broadly without specifying every field. For example:
- No method matcher → matches any HTTP method (GET, POST, etc.)
- No path matcher → matches any request path
- No header matcher → matches requests with any headers
This "filter" behavior improves UX: unspecified fields act as wildcards, so users can create simple expectations without boilerplate "match anything" patterns.
- Author:
- jamesdbloom
-
-
Field Summary
-
Fields inherited from class org.mockserver.matchers.AbstractHttpRequestMatcher
BECAUSE, COLON_NEW_LINES, configuration, controlPlaneMatcher, DID_NOT_MATCH, didNotMatchExpectationBecause, didNotMatchExpectationWithoutBecause, didNotMatchRequestBecause, expectation, EXPECTATION, EXPECTATION_DID_MATCH, MATCHED, matcherDescription, mockServerLogger, REQUEST_DID_MATCH, REQUEST_DID_NOT_MATCH, REQUEST_MATCHER
-
-
Constructor Summary
Constructors Constructor Description HttpRequestPropertiesMatcher(Configuration configuration, MockServerLogger mockServerLogger)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapply(RequestDefinition requestDefinition)booleanequals(Object o)String[]fieldsExcludedFromEqualsAndHashCode()HttpRequestgetHttpRequest()List<HttpRequest>getHttpRequests()booleanhasBodyMatcher()inthashCode()booleanmatches(MatchDifference context, RequestDefinition requestDefinition)StringtoString()HttpRequestPropertiesMatcherwithControlPlaneMatcher(boolean controlPlaneMatcher)-
Methods inherited from class org.mockserver.matchers.AbstractHttpRequestMatcher
applyNotOperators, getExpectation, getSource, isActive, isBlank, isResponseInProgress, matches, setControlPlaneMatcher, setDescription, setResponseInProgress, update, update, withSource
-
Methods inherited from class org.mockserver.matchers.NotMatcher
notMatcher
-
-
-
-
Constructor Detail
-
HttpRequestPropertiesMatcher
public HttpRequestPropertiesMatcher(Configuration configuration, MockServerLogger mockServerLogger)
-
-
Method Detail
-
getHttpRequest
public HttpRequest getHttpRequest()
-
hasBodyMatcher
public boolean hasBodyMatcher()
-
getHttpRequests
public List<HttpRequest> getHttpRequests()
-
apply
public boolean apply(RequestDefinition requestDefinition)
-
withControlPlaneMatcher
public HttpRequestPropertiesMatcher withControlPlaneMatcher(boolean controlPlaneMatcher)
-
matches
public boolean matches(MatchDifference context, RequestDefinition requestDefinition)
- Specified by:
matchesin interfaceHttpRequestMatcher- Specified by:
matchesin interfaceMatcher<RequestDefinition>- Specified by:
matchesin classAbstractHttpRequestMatcher
-
toString
public String toString()
- Overrides:
toStringin classObjectWithReflectiveEqualsHashCodeToString
-
fieldsExcludedFromEqualsAndHashCode
public String[] fieldsExcludedFromEqualsAndHashCode()
- Overrides:
fieldsExcludedFromEqualsAndHashCodein classObjectWithReflectiveEqualsHashCodeToString
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classAbstractHttpRequestMatcher
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractHttpRequestMatcher
-
-