Package com.spotify.apollo.test.unit
Class RequestMatchers
- java.lang.Object
-
- com.spotify.apollo.test.unit.RequestMatchers
-
public final class RequestMatchers extends Object
Provides Hamcrest matcher utilities for matching requests. Intended for use withStubClientresponse matchers.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.hamcrest.Matcher<com.spotify.apollo.Request>hasHeader(String key)A matcher for aRequestwith a header presentstatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasHeader(String key, String value)A matcher for aRequestwith header matching a valuestatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasHeader(String key, org.hamcrest.Matcher<String> valueMatcher)A matcher for aRequestwith header matching a valuestatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasNoHeaders()A matcher for aRequestwith no headersstatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasNoQueryParameters()Matches aRequestthat has no query parametersstatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasPayloadMatching(org.hamcrest.Matcher<okio.ByteString> matcher)Matches aRequestwhich has a payload matching the specifiedMatcherstatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasPayloadUtf8Matching(org.hamcrest.Matcher<String> matcher)static org.hamcrest.Matcher<com.spotify.apollo.Request>hasQueryParameter(String key)Matches aRequestthat has a query parameter with the specified keystatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasQueryParameter(String key, String value)Matches aRequestthat has a query parameter with the specified valuestatic org.hamcrest.Matcher<com.spotify.apollo.Request>hasQueryParameter(String key, org.hamcrest.Matcher<Iterable<? extends String>> matcher)Matches aRequestthat has a query parameter with the specified valuesstatic org.hamcrest.Matcher<com.spotify.apollo.Request>method(String method)static org.hamcrest.Matcher<com.spotify.apollo.Request>service(String service)A matcher checking theRequest.service()fieldstatic org.hamcrest.Matcher<com.spotify.apollo.Request>service(org.hamcrest.Matcher<String> serviceMatcher)A matcher for the service field in a requeststatic org.hamcrest.Matcher<com.spotify.apollo.Request>uri(String uri)static org.hamcrest.Matcher<com.spotify.apollo.Request>uri(org.hamcrest.Matcher<String> uriMatcher)
-
-
-
Method Detail
-
uri
public static org.hamcrest.Matcher<com.spotify.apollo.Request> uri(String uri)
-
uri
public static org.hamcrest.Matcher<com.spotify.apollo.Request> uri(org.hamcrest.Matcher<String> uriMatcher)
-
method
public static org.hamcrest.Matcher<com.spotify.apollo.Request> method(String method)
-
service
public static org.hamcrest.Matcher<com.spotify.apollo.Request> service(String service)
A matcher checking theRequest.service()field- Parameters:
service- The service to check for- Returns:
- A
Matcherchecking theRequest.service()equals service
-
service
public static org.hamcrest.Matcher<com.spotify.apollo.Request> service(org.hamcrest.Matcher<String> serviceMatcher)
A matcher for the service field in a request- Parameters:
serviceMatcher- AMatcherfor the service- Returns:
- A matcher for the service field
-
hasNoHeaders
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoHeaders()
A matcher for aRequestwith no headers- Parameters:
key- The header's key to look forvalueMatcher- AMatcherfor the value at the key- Returns:
- The matcher
-
hasHeader
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasHeader(String key, org.hamcrest.Matcher<String> valueMatcher)
A matcher for aRequestwith header matching a value- Returns:
- The matcher
-
hasHeader
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasHeader(String key, String value)
A matcher for aRequestwith header matching a value- Parameters:
key- The header's keyvalue- The expected value of the header- Returns:
- The matcher
-
hasHeader
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasHeader(String key)
A matcher for aRequestwith a header present- Parameters:
key- The- Returns:
-
hasNoQueryParameters
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoQueryParameters()
Matches aRequestthat has no query parameters- Returns:
- A
Matchermatching a request with no query parameters
-
hasQueryParameter
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter(String key)
Matches aRequestthat has a query parameter with the specified key- Parameters:
key- The query parameter key the matcher will look for- Returns:
- A
Matchermatching a request with a query parameter for the specified key
-
hasQueryParameter
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter(String key, String value)
Matches aRequestthat has a query parameter with the specified value- Parameters:
key- The query parameter keyvalue- The single value of the query parameter- Returns:
- A
Matchermatching a request with a query parameter with the specified key and value
-
hasQueryParameter
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter(String key, org.hamcrest.Matcher<Iterable<? extends String>> matcher)
Matches aRequestthat has a query parameter with the specified values- Parameters:
key- The query parameter keymatcher- The matcher used to match match the query parameter values- Returns:
- A
Matchermatching a request with a query parameter with the specified key and matching values
-
hasPayloadMatching
public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasPayloadMatching(org.hamcrest.Matcher<okio.ByteString> matcher)
Matches aRequestwhich has a payload matching the specifiedMatcher- Parameters:
matcher- The matcher the payload should match- Returns:
- A
Matchermatching a request with payload matching matcher
-
-