Interface Expectation

All Known Implementing Classes:
Invocation

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

    • header

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

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

      Expectation body(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(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(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(Supplier<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(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)
    • times

      Expectation times(Times never)