Class OperationResponseFactory
java.lang.Object
org.springframework.restdocs.operation.OperationResponseFactory
A factory for creating
OperationResponses
.- Author:
- Andy Wilkinson, Clyde Stubbs
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreate
(org.springframework.http.HttpStatusCode status, org.springframework.http.HttpHeaders headers, byte[] content) Creates a newOperationResponse
without cookies.create
(org.springframework.http.HttpStatusCode status, org.springframework.http.HttpHeaders headers, byte[] content, Collection<ResponseCookie> cookies) Creates a newOperationResponse
.createFrom
(OperationResponse original, byte[] newContent) Creates a newOperationResponse
based on the givenoriginal
but with the givennewContent
.createFrom
(OperationResponse original, org.springframework.http.HttpHeaders newHeaders) Creates a newOperationResponse
based on the givenoriginal
but with the givennewHeaders
.
-
Constructor Details
-
OperationResponseFactory
public OperationResponseFactory()
-
-
Method Details
-
create
public OperationResponse create(org.springframework.http.HttpStatusCode status, org.springframework.http.HttpHeaders headers, byte[] content) Creates a newOperationResponse
without cookies. If the response has any content, the givenheaders
will be augmented to ensure that they include aContent-Length
header.- Parameters:
status
- the status of the responseheaders
- the request's headerscontent
- the content of the request- Returns:
- the
OperationResponse
- Since:
- 3.0.0
-
create
public OperationResponse create(org.springframework.http.HttpStatusCode status, org.springframework.http.HttpHeaders headers, byte[] content, Collection<ResponseCookie> cookies) Creates a newOperationResponse
. If the response has any content, the givenheaders
will be augmented to ensure that they include aContent-Length
header.- Parameters:
status
- the status of the responseheaders
- the request's headerscontent
- the content of the requestcookies
- the cookies- Returns:
- the
OperationResponse
- Since:
- 3.0.0
-
createFrom
Creates a newOperationResponse
based on the givenoriginal
but with the givennewContent
. If the original response had aContent-Length
header it will be modified to match the length of the new content.- Parameters:
original
- the original responsenewContent
- the new content- Returns:
- the new response with the new content
-
createFrom
public OperationResponse createFrom(OperationResponse original, org.springframework.http.HttpHeaders newHeaders) Creates a newOperationResponse
based on the givenoriginal
but with the givennewHeaders
.- Parameters:
original
- the original responsenewHeaders
- the new headers- Returns:
- the new response with the new headers
-