Package kong.unirest.core
Class Invocation
java.lang.Object
kong.unirest.core.Invocation
- All Implemented Interfaces:
Expectation
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Boolean
private BodyMatcher
private MatchStatus
private Headers
private Headers
private ExpectedResponseRecord
private Times
private Function
<HttpRequest<?>, ExpectedResponse> private List
<HttpRequest> private Routes
-
Constructor Summary
ConstructorsConstructorDescriptionInvocation
(Routes routes) Invocation
(Routes routes, HttpRequest request) Invocation
(Routes routes, Invocation other) -
Method Summary
Modifier and TypeMethodDescriptionprivate Headers
A expected body for a requestbody
(BodyMatcher matcher) A matcher for the body for a requestprivate String
details()
(package private) RawResponse
getResponse
(Config config, HttpRequest request) boolean
boolean
hasExpectedHeader
(String key, String value) boolean
private boolean
A expected header for a requestvoid
log
(HttpRequest request) private Integer
queryString
(String key, String value) A expected header for a requestprivate int
scoreBody
(HttpRequest request) private int
scoreHeaders
(HttpRequest request) scoreMatch
(HttpRequest request) private int
scoreQuery
(HttpRequest request) expect 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 responseprivate static <T,
M extends T>
Optional<M> private boolean
uniBodyMatches
(String body, Body o) void
verify()
verify that all Expectations was fulfilled at least once.void
-
Field Details
-
routes
-
requests
-
expectedHeaders
-
expectedQueryParams
-
expected
-
expectedBody
-
expectedBodyStatus
-
expectedResponse
-
functionalResponse
-
expectedTimes
-
-
Constructor Details
-
Invocation
-
Invocation
-
Invocation
Invocation(Routes routes, Invocation other) -
Invocation
Invocation()
-
-
Method Details
-
thenReturn
Description copied from interface:Expectation
expect a string response- Specified by:
thenReturn
in interfaceExpectation
- Parameters:
body
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:Expectation
expect a json response- Specified by:
thenReturn
in interfaceExpectation
- Parameters:
jsonObject
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:Expectation
expect a object response as defined by a pojo using the requests / configuration object mapper- Specified by:
thenReturn
in interfaceExpectation
- Parameters:
pojo
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:Expectation
A supplier for the expected body which will get invoked at the time of build the response.- Specified by:
thenReturn
in interfaceExpectation
- Parameters:
supplier
- the expected response body supplier- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:Expectation
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- Specified by:
thenReturn
in interfaceExpectation
- Parameters:
fun
- the function to convert a request to a response
-
getResponse
-
allHeaders
-
log
-
header
Description copied from interface:Expectation
A expected header for a request- Specified by:
header
in interfaceExpectation
- Parameters:
key
- the header keyvalue
- the header value- Returns:
- this Expectation
-
queryString
Description copied from interface:Expectation
A expected header for a request- Specified by:
queryString
in interfaceExpectation
- Parameters:
key
- the query keyvalue
- the query value- Returns:
- this Expectation
-
body
Description copied from interface:Expectation
A expected body for a request- Specified by:
body
in interfaceExpectation
- Parameters:
body
- the expected body- Returns:
- this Expectation
-
body
Description copied from interface:Expectation
A matcher for the body for a request- Specified by:
body
in interfaceExpectation
- Parameters:
matcher
- the matcher- Returns:
- this Expectation
-
thenReturn
Description copied from interface:Expectation
expect a null response- Specified by:
thenReturn
in interfaceExpectation
- Returns:
- The ExpectedResponse
-
verify
public void verify()Description copied from interface:Expectation
verify that all Expectations was fulfilled at least once.- Specified by:
verify
in interfaceExpectation
-
verify
- Specified by:
verify
in interfaceExpectation
-
times
- Specified by:
times
in interfaceExpectation
-
details
-
hasExpectedHeader
-
getBodyStream
-
hasBody
-
uniBodyMatches
-
hasField
-
hasField
-
requestSize
-
getRequests
-
isExpected
-
scoreMatch
-
scoreBody
-
matchBody
-
scoreHeaders
-
scoreQuery
-
tryCast
-