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>
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
ConstructorsConstructorDescriptionHttpRequestPropertiesMatcher(Configuration configuration, MockServerLogger mockServerLogger) -
Method Summary
Modifier and TypeMethodDescriptionbooleanapply(RequestDefinition requestDefinition) booleanString[]booleaninthashCode()booleanmatches(MatchDifference context, RequestDefinition requestDefinition) toString()withControlPlaneMatcher(boolean controlPlaneMatcher) Methods inherited from class org.mockserver.matchers.AbstractHttpRequestMatcher
applyNotOperators, getExpectation, getSource, isActive, isBlank, isResponseInProgress, matches, setControlPlaneMatcher, setDescription, setResponseInProgress, update, update, withSourceMethods inherited from class org.mockserver.matchers.NotMatcher
notMatcher
-
Constructor Details
-
HttpRequestPropertiesMatcher
-
-
Method Details
-
getHttpRequest
-
hasBodyMatcher
public boolean hasBodyMatcher() -
getHttpRequests
-
apply
-
withControlPlaneMatcher
-
matches
- Specified by:
matchesin interfaceHttpRequestMatcher- Specified by:
matchesin interfaceMatcher<RequestDefinition>- Specified by:
matchesin classAbstractHttpRequestMatcher
-
toString
- Overrides:
toStringin classObjectWithReflectiveEqualsHashCodeToString
-
fieldsExcludedFromEqualsAndHashCode
- Overrides:
fieldsExcludedFromEqualsAndHashCodein classObjectWithReflectiveEqualsHashCodeToString
-
equals
- Overrides:
equalsin classAbstractHttpRequestMatcher
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractHttpRequestMatcher
-