Package kong.unirest.core
Class ExpectedResponseRecord
java.lang.Object
kong.unirest.core.ExpectedResponseRecord
- All Implemented Interfaces:
ExpectedResponse,ResponseBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Expectationprivate Function<ObjectMapper, String> private Headersprivate intprivate String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate ObjectMappergetObjectMapper(HttpRequest request, Config config) (package private) voidsetExpectation(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 ExpectedResponsethenReturn(MockResponse res) toRawResponse(Config config, HttpRequest request) voidverify()verify that all Expectations was fulfilled at least once.voidwithHeader(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:ExpectedResponseadds a header to the expected response- Specified by:
withHeaderin interfaceExpectedResponse- Parameters:
key- the header key- Returns:
- this ExpectedResponse
-
withHeaders
Description copied from interface:ExpectedResponseadds a collection of headers to the expected response- Specified by:
withHeadersin interfaceExpectedResponse- Parameters:
value- the headers- Returns:
- This ExpectedResponse
-
withStatus
Description copied from interface:ExpectedResponsesets the status of the expected response- Specified by:
withStatusin interfaceExpectedResponse- Parameters:
httpStatus- the http status code- Returns:
- this ExpectedResponse
-
withStatus
Description copied from interface:ExpectedResponsesets the status of the expected response- Specified by:
withStatusin interfaceExpectedResponse- Parameters:
httpStatus- the http status codestatusMessage- the status message- Returns:
- this ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponseexpect a string response- Specified by:
thenReturnin interfaceExpectedResponse- Parameters:
body- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponseexpect a json response- Specified by:
thenReturnin interfaceExpectedResponse- Parameters:
jsonObject- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponseA supplier for the expected body which will get invoked at the time of build the response.- Specified by:
thenReturnin interfaceExpectedResponse- Parameters:
supplier- the expected response body supplier- Returns:
- The ExpectedResponse
-
verify
public void verify()Description copied from interface:ExpectedResponseverify that all Expectations was fulfilled at least once.- Specified by:
verifyin interfaceExpectedResponse
-
verify
- Specified by:
verifyin interfaceExpectedResponse
-
thenReturn
Description copied from interface:ExpectedResponseexpect a object response as defined by a pojo using the requests / configuration object mapper- Specified by:
thenReturnin interfaceExpectedResponse- Parameters:
pojo- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
-
toRawResponse
- Specified by:
toRawResponsein interfaceResponseBuilder
-
getObjectMapper
-
setExpectation
-