Class MockClientHttpResponse
- java.lang.Object
- org.springframework.mock.http.client.reactive.MockClientHttpResponse
- All Implemented Interfaces:
ClientHttpResponse,HttpMessage,ReactiveHttpInputMessage
public class MockClientHttpResponse extends Object implements ClientHttpResponse
Mock implementation ofClientHttpResponse.- Since:
- 5.0
- Author:
- Brian Clozel, Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description MockClientHttpResponse(int status)MockClientHttpResponse(HttpStatus status)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description reactor.core.publisher.Flux<DataBuffer>getBody()Return the body of the message as aPublisher.reactor.core.publisher.Mono<String>getBodyAsString()Return the response body aggregated and converted to a String using the charset of the Content-Type response or otherwise as "UTF-8".MultiValueMap<String,ResponseCookie>getCookies()Return a read-only map of response cookies received from the server.HttpHeadersgetHeaders()Return the headers of this message.intgetRawStatusCode()Return the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.HttpStatusgetStatusCode()Return the HTTP status code as anHttpStatusenum value.voidsetBody(String body)voidsetBody(String body, Charset charset)voidsetBody(org.reactivestreams.Publisher<DataBuffer> body)StringtoString()
Constructor Detail
MockClientHttpResponse
public MockClientHttpResponse(HttpStatus status)
MockClientHttpResponse
public MockClientHttpResponse(int status)
Method Detail
getStatusCode
public HttpStatus getStatusCode()
Description copied from interface:ClientHttpResponseReturn the HTTP status code as anHttpStatusenum value.- Specified by:
getStatusCodein interfaceClientHttpResponse- Returns:
- the HTTP status as an HttpStatus enum value (never
null) - See Also:
HttpStatus.valueOf(int)
getRawStatusCode
public int getRawStatusCode()
Description copied from interface:ClientHttpResponseReturn the HTTP status code (potentially non-standard and not resolvable through theHttpStatusenum) as an integer.- Specified by:
getRawStatusCodein interfaceClientHttpResponse- Returns:
- the HTTP status as an integer value
- See Also:
ClientHttpResponse.getStatusCode(),HttpStatus.resolve(int)
getHeaders
public HttpHeaders getHeaders()
Description copied from interface:HttpMessageReturn the headers of this message.- Specified by:
getHeadersin interfaceHttpMessage- Returns:
- a corresponding HttpHeaders object (never
null)
getCookies
public MultiValueMap<String,ResponseCookie> getCookies()
Description copied from interface:ClientHttpResponseReturn a read-only map of response cookies received from the server.- Specified by:
getCookiesin interfaceClientHttpResponse
setBody
public void setBody(org.reactivestreams.Publisher<DataBuffer> body)
getBody
public reactor.core.publisher.Flux<DataBuffer> getBody()
Description copied from interface:ReactiveHttpInputMessageReturn the body of the message as aPublisher.- Specified by:
getBodyin interfaceReactiveHttpInputMessage- Returns:
- the body content publisher
getBodyAsString
public reactor.core.publisher.Mono<String> getBodyAsString()
Return the response body aggregated and converted to a String using the charset of the Content-Type response or otherwise as "UTF-8".