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 Expectationexpectationprivate java.util.function.Function<ObjectMapper,java.lang.String>responseprivate HeadersresponseHeadersprivate intresponseStatusprivate java.lang.StringresponseText
-
Constructor Summary
Constructors Constructor Description ExpectedResponseRecord(Expectation expectation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private ObjectMappergetObjectMapper(HttpRequest request, Config config)(package private) voidsetExpectation(Expectation invocation)ExpectedResponsethenReturn(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 responseExpectedResponsethenReturn(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 responseprivate ExpectedResponsethenReturn(MockResponse res)RawResponsetoRawResponse(Config config, HttpRequest request)voidverify()verify that all Expectations was fulfilled at least once.voidverify(Times times)ExpectedResponsewithHeader(java.lang.String key, java.lang.String value)adds a header to the expected responseExpectedResponsewithHeaders(Headers value)adds a collection of headers to the expected responseExpectedResponsewithStatus(int httpStatus)sets the status of the expected responseExpectedResponsewithStatus(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:ExpectedResponseadds a header to the expected response- Specified by:
withHeaderin interfaceExpectedResponse- Parameters:
key- the header key- Returns:
- this ExpectedResponse
-
withHeaders
public ExpectedResponse withHeaders(Headers value)
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
public ExpectedResponse withStatus(int httpStatus)
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
public ExpectedResponse withStatus(int httpStatus, java.lang.String statusMessage)
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
public ExpectedResponse thenReturn(java.lang.String body)
Description copied from interface:ExpectedResponseexpect a string response- Specified by:
thenReturnin interfaceExpectedResponse- Parameters:
body- the expected response body- Returns:
- The ExpectedResponse
-
thenReturn
public ExpectedResponse thenReturn(JSONElement jsonObject)
Description copied from interface:ExpectedResponseexpect a json response- Specified by:
thenReturnin 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: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
public void verify(Times times)
- Specified by:
verifyin interfaceExpectedResponse
-
thenReturn
public ExpectedResponse thenReturn(java.lang.Object pojo)
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
private ExpectedResponse thenReturn(MockResponse res)
-
toRawResponse
public RawResponse toRawResponse(Config config, HttpRequest request)
- Specified by:
toRawResponsein interfaceResponseBuilder
-
getObjectMapper
private ObjectMapper getObjectMapper(HttpRequest request, Config config)
-
setExpectation
void setExpectation(Expectation invocation)
-
-