Package net.jadler.matchers
Class ParameterRequestMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<Request>
-
- net.jadler.matchers.RequestMatcher<List<String>>
-
- net.jadler.matchers.ParameterRequestMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<Request>,org.hamcrest.SelfDescribing
public class ParameterRequestMatcher extends RequestMatcher<List<String>>
ARequestMatcherused for matching a request parameter.
-
-
Field Summary
-
Fields inherited from class net.jadler.matchers.RequestMatcher
pred
-
-
Constructor Summary
Constructors Constructor Description ParameterRequestMatcher(org.hamcrest.Matcher<? super List<String>> pred, String paramName)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 ParameterRequestMatcherrequestParameter(String paramName, org.hamcrest.Matcher<? super List<String>> pred)Factory method to create new instance of this matcher.protected List<String>retrieveValue(Request req)Retrieves a parameter (defined inParameterRequestMatcher(org.hamcrest.Matcher, java.lang.String)) of the given request.-
Methods inherited from class net.jadler.matchers.RequestMatcher
describeMismatch, describeTo, matches
-
-
-
-
Constructor Detail
-
ParameterRequestMatcher
public ParameterRequestMatcher(org.hamcrest.Matcher<? super List<String>> pred, String paramName)
Protected constructor useful only when subtyping. For creating instances of this class userequestParameter(java.lang.String, org.hamcrest.Matcher)instead.- Parameters:
pred- a predicate to be applied on the given request parameterparamName- name of a request parameter (case sensitive)
-
-
Method Detail
-
requestParameter
public static ParameterRequestMatcher requestParameter(String paramName, org.hamcrest.Matcher<? super List<String>> pred)
Factory method to create new instance of this matcher.- Parameters:
paramName- name of a request parameterpred- a predicate to be applied on the request parameter- Returns:
- new instance of this matcher
-
retrieveValue
protected List<String> retrieveValue(Request req)
Retrieves a parameter (defined inParameterRequestMatcher(org.hamcrest.Matcher, java.lang.String)) of the given request. The values are percent-encoded.- Specified by:
retrieveValuein classRequestMatcher<List<String>>- Parameters:
req- request to retrieve the parameter from- Returns:
- the request parameter as a list of values or
nullif there is no such a parameter in the request
-
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<List<String>>- Returns:
- matcher description
-
-