Package net.jadler.matchers
Class HeaderRequestMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<Request>
-
- net.jadler.matchers.RequestMatcher<List<String>>
-
- net.jadler.matchers.HeaderRequestMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<Request>,org.hamcrest.SelfDescribing
public class HeaderRequestMatcher extends RequestMatcher<List<String>>
ARequestMatcherused for matching a request header.
-
-
Field Summary
-
Fields inherited from class net.jadler.matchers.RequestMatcher
pred
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedHeaderRequestMatcher(org.hamcrest.Matcher<? super List<String>> pred, String headerName)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 HeaderRequestMatcherrequestHeader(String headerName, org.hamcrest.Matcher<? super List<String>> pred)Factory method to create new instance of this matcher.protected List<String>retrieveValue(Request req)Retrieves a header (defined inHeaderRequestMatcher(org.hamcrest.Matcher, java.lang.String)) of the given request.-
Methods inherited from class net.jadler.matchers.RequestMatcher
describeMismatch, describeTo, matches
-
-
-
-
Constructor Detail
-
HeaderRequestMatcher
protected HeaderRequestMatcher(org.hamcrest.Matcher<? super List<String>> pred, String headerName)
Protected constructor useful only when subtyping. For creating instances of this class userequestHeader(java.lang.String, org.hamcrest.Matcher)instead.- Parameters:
pred- a predicate to be applied on the given request headerheaderName- name of a request header (case insensitive)
-
-
Method Detail
-
requestHeader
public static HeaderRequestMatcher requestHeader(String headerName, org.hamcrest.Matcher<? super List<String>> pred)
Factory method to create new instance of this matcher.- Parameters:
headerName- name of a request headerpred- a predicate to be applied on the request header- Returns:
- new instance of this matcher
-
retrieveValue
protected List<String> retrieveValue(Request req)
Retrieves a header (defined inHeaderRequestMatcher(org.hamcrest.Matcher, java.lang.String)) of the given request.- Specified by:
retrieveValuein classRequestMatcher<List<String>>- Parameters:
req- request to retrieve the header from- Returns:
- the request header as a list of values or
nullif there is no such a header 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
-
-