Package kong.unirest.core
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 Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static ExpectedResponse
of(int status)
Create a independent expected response.ExpectedResponse
thenReturn(java.lang.Object pojo)
expect a object response as defined by a pojo using the requests / configuration object mapperExpectedResponse
thenReturn(java.lang.String body)
expect a string responseExpectedResponse
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.ExpectedResponse
thenReturn(JSONElement jsonObject)
expect a json responsevoid
verify()
verify that all Expectations was fulfilled at least once.void
verify(Times times)
ExpectedResponse
withHeader(java.lang.String key, java.lang.String value)
adds a header to the expected responseExpectedResponse
withHeaders(Headers headers)
adds a collection of headers to the expected responseExpectedResponse
withStatus(int httpStatus)
sets the status of the expected responseExpectedResponse
withStatus(int httpStatus, java.lang.String statusMessage)
sets the status of the expected response
-
-
-
Method Detail
-
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(java.lang.String key, java.lang.String value)
adds a header to the expected response- Parameters:
key
- the header keykey
- 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, java.lang.String statusMessage)
sets the status of the expected response- Parameters:
httpStatus
- the http status codestatusMessage
- the status message- Returns:
- this 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
-
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)
-
-