Package net.jadler.matchers
Class BodyRequestMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<Request>
-
- net.jadler.matchers.RequestMatcher<String>
-
- net.jadler.matchers.BodyRequestMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<Request>,org.hamcrest.SelfDescribing
public class BodyRequestMatcher extends RequestMatcher<String>
ARequestMatcherused for matching the request body as a string.
-
-
Field Summary
-
Fields inherited from class net.jadler.matchers.RequestMatcher
pred
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedBodyRequestMatcher(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 BodyRequestMatcherrequestBody(org.hamcrest.Matcher<? super String> pred)Factory method to create new instance of this matcher.protected StringretrieveValue(Request req)Retrieves the body of the given request-
Methods inherited from class net.jadler.matchers.RequestMatcher
describeMismatch, describeTo, matches
-
-
-
-
Constructor Detail
-
BodyRequestMatcher
protected BodyRequestMatcher(org.hamcrest.Matcher<? super String> pred)
Protected constructor useful only when subtyping. For creating instances of this class userequestBody(org.hamcrest.Matcher)instead.- Parameters:
pred- a predicate to be applied on the request body
-
-
Method Detail
-
requestBody
public static BodyRequestMatcher requestBody(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 body- Returns:
- new instance of this matcher
-
retrieveValue
protected String retrieveValue(Request req)
Retrieves the body of the given request- Specified by:
retrieveValuein classRequestMatcher<String>- Parameters:
req- request to retrieve the body from- Returns:
- request body as a string (never returns
null)
-
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
-
-