Class RequestMatchers


  • public final class RequestMatchers
    extends Object
    Provides Hamcrest matcher utilities for matching requests. Intended for use with StubClient response 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 a Request with a header present
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasHeader​(String key, String value)
      A matcher for a Request with header matching a value
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasHeader​(String key, org.hamcrest.Matcher<String> valueMatcher)
      A matcher for a Request with header matching a value
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoHeaders()
      A matcher for a Request with no headers
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoQueryParameters()
      Matches a Request that has no query parameters
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasPayloadMatching​(org.hamcrest.Matcher<okio.ByteString> matcher)
      Matches a Request which has a payload matching the specified Matcher
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasPayloadUtf8Matching​(org.hamcrest.Matcher<String> matcher)
      Matches a Request which has a payload with a String value matching the specified Matcher
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter​(String key)
      Matches a Request that has a query parameter with the specified key
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter​(String key, String value)
      Matches a Request that has a query parameter with the specified value
      static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter​(String key, org.hamcrest.Matcher<Iterable<? extends String>> matcher)
      Matches a Request that has a query parameter with the specified values
      static org.hamcrest.Matcher<com.spotify.apollo.Request> method​(String method)  
      static org.hamcrest.Matcher<com.spotify.apollo.Request> service​(String service)
      A matcher checking the Request.service() field
      static org.hamcrest.Matcher<com.spotify.apollo.Request> service​(org.hamcrest.Matcher<String> serviceMatcher)
      A matcher for the service field in a request
      static 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 the Request.service() field
        Parameters:
        service - The service to check for
        Returns:
        A Matcher checking the Request.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 - A Matcher for the service
        Returns:
        A matcher for the service field
      • hasNoHeaders

        public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoHeaders()
        A matcher for a Request with no headers
        Parameters:
        key - The header's key to look for
        valueMatcher - A Matcher for 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 a Request with 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 a Request with header matching a value
        Parameters:
        key - The header's key
        value - 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 a Request with a header present
        Parameters:
        key - The
        Returns:
      • hasNoQueryParameters

        public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasNoQueryParameters()
        Matches a Request that has no query parameters
        Returns:
        A Matcher matching a request with no query parameters
      • hasQueryParameter

        public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasQueryParameter​(String key)
        Matches a Request that has a query parameter with the specified key
        Parameters:
        key - The query parameter key the matcher will look for
        Returns:
        A Matcher matching 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 a Request that has a query parameter with the specified value
        Parameters:
        key - The query parameter key
        value - The single value of the query parameter
        Returns:
        A Matcher matching 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 a Request that has a query parameter with the specified values
        Parameters:
        key - The query parameter key
        matcher - The matcher used to match match the query parameter values
        Returns:
        A Matcher matching 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 a Request which has a payload matching the specified Matcher
        Parameters:
        matcher - The matcher the payload should match
        Returns:
        A Matcher matching a request with payload matching matcher
      • hasPayloadUtf8Matching

        public static org.hamcrest.Matcher<com.spotify.apollo.Request> hasPayloadUtf8Matching​(org.hamcrest.Matcher<String> matcher)
        Matches a Request which has a payload with a String value matching the specified Matcher
        Parameters:
        matcher - The matcher matching the expected String value
        Returns:
        A Matcher matching a Request with payload string matching the value