Package kong.unirest.core
Interface Expectation
-
- All Known Implementing Classes:
Invocation
public interface Expectation
A expectation for a particular method/path
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Expectation
body(java.lang.String body)
A expected body for a requestExpectation
body(BodyMatcher matcher)
A matcher for the body for a requestExpectation
header(java.lang.String key, java.lang.String value)
A expected header for a requestExpectation
queryString(java.lang.String key, java.lang.String value)
A expected header for a requestExpectedResponse
thenReturn()
expect a null responseExpectedResponse
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 responsevoid
thenReturn(java.util.function.Function<HttpRequest<?>,ExpectedResponse> fun)
Allows for a full override of the way a expected response is built.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.ExpectedResponse
thenReturn(JSONElement jsonObject)
expect a json responseExpectation
times(Times never)
void
verify()
verify that all Expectations was fulfilled at least once.void
verify(Times times)
-
-
-
Method Detail
-
header
Expectation header(java.lang.String key, java.lang.String value)
A expected header for a request- Parameters:
key
- the header keyvalue
- the header value- Returns:
- this Expectation
-
queryString
Expectation queryString(java.lang.String key, java.lang.String value)
A expected header for a request- Parameters:
key
- the query keyvalue
- the query value- Returns:
- this Expectation
-
body
Expectation body(java.lang.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(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
-
thenReturn
void thenReturn(java.util.function.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)
-
-