Package net.jadler.matchers
Class QueryStringRequestMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<Request>
-
- net.jadler.matchers.RequestMatcher<String>
-
- net.jadler.matchers.QueryStringRequestMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<Request>,org.hamcrest.SelfDescribing
public class QueryStringRequestMatcher extends RequestMatcher<String>
ARequestMatcherused for matching the request query string.
-
-
Field Summary
-
Fields inherited from class net.jadler.matchers.RequestMatcher
pred
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedQueryStringRequestMatcher(org.hamcrest.Matcher<? super String> pred)Protected constructor useful only when subtyping.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringprovideDescription()Provides a description of this matcher in form of a string consisting of "noun verb", where noun describes the value retrieved usingRequestMatcher.retrieveValue(net.jadler.Request)and verb is usually a correct form of to be.static QueryStringRequestMatcherrequestQueryString(org.hamcrest.Matcher<? super String> pred)Factory method to create new instance of this matcher.StringretrieveValue(Request req)Retrieves the query string value of the given request.-
Methods inherited from class net.jadler.matchers.RequestMatcher
describeMismatch, describeTo, matches
-
-
-
-
Constructor Detail
-
QueryStringRequestMatcher
protected QueryStringRequestMatcher(org.hamcrest.Matcher<? super String> pred)
Protected constructor useful only when subtyping. For creating instances of this class userequestQueryString(org.hamcrest.Matcher)instead.- Parameters:
pred- a predicate to be applied on the query string
-
-
Method Detail
-
requestQueryString
public static QueryStringRequestMatcher requestQueryString(org.hamcrest.Matcher<? super String> pred)
Factory method to create new instance of this matcher.- Parameters:
pred- a predicate to be applied on the request query string- Returns:
- new instance of this matcher
-
retrieveValue
public String retrieveValue(Request req)
Retrieves the query string value of the given request. The value is percent-encoded.- Specified by:
retrieveValuein classRequestMatcher<String>- Parameters:
req- request to retrieve the query string from- Returns:
- query string value:
nullfor requests without a query string part (no ? character)- an empty string for request with an empty query string part (? is present but there is no actual query string value)
- query string value (without the leading ? character) for requests with a query string part
-
provideDescription
protected String provideDescription()
Provides a description of this matcher in form of a string consisting of "noun verb", where noun describes the value retrieved using
RequestMatcher.retrieveValue(net.jadler.Request)and verb is usually a correct form of to be.If the
RequestMatcher.retrieveValue(net.jadler.Request)provided a request method, this method would return method is string for example.- Specified by:
provideDescriptionin classRequestMatcher<String>- Returns:
- matcher description
-
-