Package kong.unirest.core
Interface Expectation
- All Known Implementing Classes:
Invocation
public interface Expectation
A expectation for a particular method/path
-
Method Summary
Modifier and TypeMethodDescriptionA expected body for a requestbody
(BodyMatcher matcher) A matcher for the body for a requestA expected header for a requestqueryString
(String key, String value) A expected header for a requestexpect a null responsethenReturn
(Object pojo) expect a object response as defined by a pojo using the requests / configuration object mapperthenReturn
(String body) expect a string responsevoid
thenReturn
(Function<HttpRequest<?>, ExpectedResponse> fun) Allows for a full override of the way a expected response is built.thenReturn
(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 responsevoid
verify()
verify that all Expectations was fulfilled at least once.void
-
Method Details
-
header
A expected header for a request- Parameters:
key
- the header keyvalue
- the header value- Returns:
- this Expectation
-
queryString
A expected header for a request- Parameters:
key
- the query keyvalue
- the query value- Returns:
- this Expectation
-
body
A expected body for a request- Parameters:
body
- the expected body- Returns:
- this Expectation
-
body
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
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
-
thenReturn
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
-
times
-