Package net.jadler.matchers
Class RawBodyRequestMatcher
- java.lang.Object
-
- org.hamcrest.BaseMatcher<Request>
-
- net.jadler.matchers.RequestMatcher<byte[]>
-
- net.jadler.matchers.RawBodyRequestMatcher
-
- All Implemented Interfaces:
org.hamcrest.Matcher<Request>,org.hamcrest.SelfDescribing
public class RawBodyRequestMatcher extends RequestMatcher<byte[]>
ARequestMatcherused for matching the request body as an array of bytes.
-
-
Field Summary
-
Fields inherited from class net.jadler.matchers.RequestMatcher
pred
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRawBodyRequestMatcher(org.hamcrest.Matcher<byte[]> 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 RawBodyRequestMatcherrequestRawBody(org.hamcrest.Matcher<byte[]> pred)Factory method to create new instance of this matcher.protected byte[]retrieveValue(Request req)Retrieves the body of the given request-
Methods inherited from class net.jadler.matchers.RequestMatcher
describeMismatch, describeTo, matches
-
-
-
-
Constructor Detail
-
RawBodyRequestMatcher
protected RawBodyRequestMatcher(org.hamcrest.Matcher<byte[]> pred)
Protected constructor useful only when subtyping. For creating instances of this class userequestRawBody(org.hamcrest.Matcher)instead.- Parameters:
pred- a predicate to be applied on the request body
-
-
Method Detail
-
requestRawBody
public static RawBodyRequestMatcher requestRawBody(org.hamcrest.Matcher<byte[]> 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 byte[] retrieveValue(Request req) throws Exception
Retrieves the body of the given request- Specified by:
retrieveValuein classRequestMatcher<byte[]>- Parameters:
req- request to retrieve the body from- Returns:
- request body as an array of bytes (never returns
null) - Throws:
Exception- when something goes wrong. This exception will be handler correctly by Jadler.
-
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<byte[]>- Returns:
- matcher description
-
-