Package kong.unirest.core
Class ExpectedResponseRecord
- java.lang.Object
-
- kong.unirest.core.ExpectedResponseRecord
-
- All Implemented Interfaces:
ExpectedResponse
,ResponseBuilder
class ExpectedResponseRecord extends java.lang.Object implements ExpectedResponse, ResponseBuilder
-
-
Field Summary
Fields Modifier and Type Field Description private Expectation
expectation
private java.util.function.Function<ObjectMapper,java.lang.String>
response
private Headers
responseHeaders
private int
responseStatus
private java.lang.String
responseText
-
Constructor Summary
Constructors Constructor Description ExpectedResponseRecord(Expectation expectation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ObjectMapper
getObjectMapper(HttpRequest request, Config config)
(package private) void
setExpectation(Expectation invocation)
ExpectedResponse
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 responseExpectedResponse
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 responseprivate ExpectedResponse
thenReturn(MockResponse res)
RawResponse
toRawResponse(Config config, HttpRequest request)
void
verify()
verify that all Expectations was fulfilled at least once.void
verify(Times times)
ExpectedResponse
withHeader(java.lang.String key, java.lang.String value)
adds a header to the expected responseExpectedResponse
withHeaders(Headers value)
adds a collection of headers to the expected responseExpectedResponse
withStatus(int httpStatus)
sets the status of the expected responseExpectedResponse
withStatus(int httpStatus, java.lang.String statusMessage)
sets the status of the expected response
-
-
-
Field Detail
-
expectation
private Expectation expectation
-
response
private java.util.function.Function<ObjectMapper,java.lang.String> response
-
responseHeaders
private Headers responseHeaders
-
responseStatus
private int responseStatus
-
responseText
private java.lang.String responseText
-
-
Constructor Detail
-
ExpectedResponseRecord
ExpectedResponseRecord(Expectation expectation)
-
-
Method Detail
-
withHeader
public ExpectedResponse withHeader(java.lang.String key, java.lang.String value)
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
public ExpectedResponse withHeaders(Headers value)
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
public ExpectedResponse withStatus(int httpStatus)
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
public ExpectedResponse withStatus(int httpStatus, java.lang.String statusMessage)
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
public ExpectedResponse thenReturn(java.lang.String body)
Description copied from interface:ExpectedResponse
expect a string response- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
body
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
public ExpectedResponse thenReturn(JSONElement jsonObject)
Description copied from interface:ExpectedResponse
expect a json response- Specified by:
thenReturn
in interfaceExpectedResponse
- Parameters:
jsonObject
- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
public ExpectedResponse thenReturn(java.util.function.Supplier<java.lang.String> supplier)
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
public void verify(Times times)
- Specified by:
verify
in interfaceExpectedResponse
-
thenReturn
public ExpectedResponse thenReturn(java.lang.Object pojo)
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
private ExpectedResponse thenReturn(MockResponse res)
-
toRawResponse
public RawResponse toRawResponse(Config config, HttpRequest request)
- Specified by:
toRawResponse
in interfaceResponseBuilder
-
getObjectMapper
private ObjectMapper getObjectMapper(HttpRequest request, Config config)
-
setExpectation
void setExpectation(Expectation invocation)
-
-