Package kong.unirest.core
Interface Expectation
-
- All Known Implementing Classes:
Invocation
public interface ExpectationA expectation for a particular method/path
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Expectationbody(java.lang.String body)A expected body for a requestExpectationbody(BodyMatcher matcher)A matcher for the body for a requestExpectationheader(java.lang.String key, java.lang.String value)A expected header for a requestExpectationqueryString(java.lang.String key, java.lang.String value)A expected header for a requestExpectedResponsethenReturn()expect a null responseExpectedResponsethenReturn(java.lang.Object pojo)expect a object response as defined by a pojo using the requests / configuration object mapperExpectedResponsethenReturn(java.lang.String body)expect a string responsevoidthenReturn(java.util.function.Function<HttpRequest<?>,ExpectedResponse> fun)Allows for a full override of the way a expected response is built.ExpectedResponsethenReturn(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.ExpectedResponsethenReturn(JSONElement jsonObject)expect a json responseExpectationtimes(Times never)voidverify()verify that all Expectations was fulfilled at least once.voidverify(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)
-
-