Interface Expectation

  • All Known Implementing Classes:
    Invocation

    public interface Expectation
    A expectation for a particular method/path
    • Method Detail

      • header

        Expectation header​(java.lang.String key,
                           java.lang.String value)
        A expected header for a request
        Parameters:
        key - the header key
        value - the header value
        Returns:
        this Expectation
      • queryString

        Expectation queryString​(java.lang.String key,
                                java.lang.String value)
        A expected header for a request
        Parameters:
        key - the query key
        value - the query value
        Returns:
        this Expectation
      • body

        Expectation body​(java.lang.String body)
        A expected body for a request
        Parameters:
        body - the expected body
        Returns:
        this Expectation
      • body

        Expectation body​(BodyMatcher matcher)
        A matcher for the body for a request
        Parameters:
        matcher - the matcher
        Returns:
        this Expectation
      • thenReturn

        ExpectedResponse thenReturn()
        expect a null response
        Returns:
        The ExpectedResponse
      • thenReturn

        ExpectedResponse thenReturn​(java.lang.String body)
        expect a string response
        Parameters:
        body - the expected response body
        Returns:
        The ExpectedResponse
      • thenReturn

        ExpectedResponse thenReturn​(JSONElement jsonObject)
        expect a json response
        Parameters:
        jsonObject - the expected response body
        Returns:
        The ExpectedResponse
      • thenReturn

        ExpectedResponse thenReturn​(java.lang.Object pojo)
        expect a object response as defined by a pojo using the requests / configuration object mapper
        Parameters:
        pojo - the expected response body
        Returns:
        The ExpectedResponse
      • thenReturn

        ExpectedResponse thenReturn​(java.util.function.Supplier<java.lang.String> supplier)
        A supplier for the expected body which will get invoked at the time of build the response.
        Parameters:
        supplier - the expected response body supplier
        Returns:
        The ExpectedResponse
      • thenReturn

        void thenReturn​(java.util.function.Function<HttpRequest<?>,​ExpectedResponse> fun)
        Allows for a full override of the way a expected response is built. useful in building more complicated test-doubles of services that implement logic
        Parameters:
        fun - the function to convert a request to a response
      • verify

        void verify()
        verify that all Expectations was fulfilled at least once.
        Throws:
        UnirestAssertion - when all expectations have not been fulfilled
      • verify

        void verify​(Times times)