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
Modifier and TypeMethodDescriptionstatic ExpectedResponseof(int status) Create a independent expected response.thenReturn(Object pojo) expect a object response as defined by a pojo using the requests / configuration object mapperthenReturn(String body) expect a string responsethenReturn(Supplier<String> supplier) A supplier for the expected body which will get invoked at the time of build the response.thenReturn(JSONElement jsonObject) expect a json responsevoidverify()verify that all Expectations was fulfilled at least once.voidwithHeader(String key, String value) adds a header to the expected responsewithHeaders(Headers headers) adds a collection of headers to the expected responsewithStatus(int httpStatus) sets the status of the expected responsewithStatus(int httpStatus, String statusMessage) sets the status of the expected response
-
Method Details
-
of
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
adds a header to the expected response- Parameters:
key- the header keykey- the header value- Returns:
- this ExpectedResponse
-
withHeaders
adds a collection of headers to the expected response- Parameters:
headers- the headers- Returns:
- This ExpectedResponse
-
withStatus
sets the status of the expected response- Parameters:
httpStatus- the http status code- Returns:
- this ExpectedResponse
-
withStatus
sets the status of the expected response- Parameters:
httpStatus- the http status codestatusMessage- the status message- Returns:
- this ExpectedResponse
-
thenReturn
expect a string response- Parameters:
body- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
expect a json response- Parameters:
jsonObject- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
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
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
-