Package kong.unirest.core
Class ExpectedResponseRecord
java.lang.Object
kong.unirest.core.ExpectedResponseRecord
- All Implemented Interfaces:
ExpectedResponse
,ResponseBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Expectation
private Function
<ObjectMapper, String> private Headers
private int
private String
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ObjectMapper
getObjectMapper
(HttpRequest request, Config config) (package private) void
setExpectation
(Expectation invocation) 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 responseprivate ExpectedResponse
thenReturn
(MockResponse res) toRawResponse
(Config config, HttpRequest request) void
verify()
verify that all Expectations was fulfilled at least once.void
withHeader
(String key, String value) adds a header to the expected responsewithHeaders
(Headers value) 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
-
Field Details
-
expectation
-
response
-
responseHeaders
-
responseStatus
private int responseStatus -
responseText
-
-
Constructor Details
-
ExpectedResponseRecord
ExpectedResponseRecord(Expectation expectation)
-
-
Method Details
-
withHeader
Description copied from interface:ExpectedResponse
adds a header to the expected response- Specified by:
withHeader
in interfaceExpectedResponse
- Parameters:
key
- the header key- Returns:
- this ExpectedResponse
-
withHeaders
Description copied from interface:ExpectedResponse
adds a collection of headers to the expected response- Specified by:
withHeaders
in interfaceExpectedResponse
- Parameters:
value
- the headers- Returns:
- This ExpectedResponse
-
withStatus
Description copied from interface:ExpectedResponse
sets the status of the expected response- Specified by:
withStatus
in interfaceExpectedResponse
- Parameters:
httpStatus
- the http status code- Returns:
- this ExpectedResponse
-
withStatus
Description copied from interface:ExpectedResponse
sets the status of the expected response- Specified by:
withStatus
in interfaceExpectedResponse
- Parameters:
httpStatus
- the http status codestatusMessage
- the status message- Returns:
- this ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponse
expect a string response- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
body
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponse
expect a json response- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
jsonObject
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponse
A supplier for the expected body which will get invoked at the time of build the response.- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
supplier
- the expected response body supplier- Returns:
- The ExpectedResponse
-
verify
public void verify()Description copied from interface:ExpectedResponse
verify that all Expectations was fulfilled at least once.- Specified by:
verify
in interfaceExpectedResponse
-
verify
- Specified by:
verify
in interfaceExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponse
expect a object response as defined by a pojo using the requests / configuration object mapper- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
pojo
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
-
toRawResponse
- Specified by:
toRawResponse
in interfaceResponseBuilder
-
getObjectMapper
-
setExpectation
-