Interface ExpectedResponse

All Known Implementing Classes:
ExpectedResponseRecord

public interface ExpectedResponse
The expected response of a assertion. Contains things like response status, body and headers.
  • Method Details

    • of

      static ExpectedResponse of(int status)
      Create a independent expected response. useful for systems creating test-doubles rather than strict mocking
      Parameters:
      status - the response status.
      Returns:
      a new expected response with this status.
    • withHeader

      ExpectedResponse withHeader(String key, String value)
      adds a header to the expected response
      Parameters:
      key - the header key
      key - the header value
      Returns:
      this ExpectedResponse
    • withHeaders

      ExpectedResponse withHeaders(Headers headers)
      adds a collection of headers to the expected response
      Parameters:
      headers - the headers
      Returns:
      This ExpectedResponse
    • withStatus

      ExpectedResponse withStatus(int httpStatus)
      sets the status of the expected response
      Parameters:
      httpStatus - the http status code
      Returns:
      this ExpectedResponse
    • withStatus

      ExpectedResponse withStatus(int httpStatus, String statusMessage)
      sets the status of the expected response
      Parameters:
      httpStatus - the http status code
      statusMessage - the status message
      Returns:
      this 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
    • 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)