Class ResponseCookiesSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.cookies.AbstractCookiesSnippet
org.springframework.restdocs.cookies.ResponseCookiesSnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the cookies in a response.- Since:
- 3.0
- Author:
- Clyde Stubbs, Andy Wilkinson
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
ResponseCookiesSnippet
(List<CookieDescriptor> descriptors) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
.protected
ResponseCookiesSnippet
(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
.protected
ResponseCookiesSnippet
(List<CookieDescriptor> descriptors, Map<String, Object> attributes) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
.protected
ResponseCookiesSnippet
(List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
. -
Method Summary
Modifier and TypeMethodDescriptionfinal ResponseCookiesSnippet
and
(List<CookieDescriptor> additionalDescriptors) Returns a newResponseCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final ResponseCookiesSnippet
and
(CookieDescriptor... additionalDescriptors) Returns a newResponseCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.extractActualCookies
(Operation operation) Extracts the names of the cookies from the request or response of the givenoperation
.protected void
verificationFailed
(Set<String> undocumentedCookies, Set<String> missingCookies) Called when the documented cookies do not match the actual cookies.Methods inherited from class org.springframework.restdocs.cookies.AbstractCookiesSnippet
createModel, createModelForDescriptor, getCookieDescriptors, isIgnoreUndocumentedCookies
Methods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
ResponseCookiesSnippet
Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
.- Parameters:
descriptors
- the descriptors
-
ResponseCookiesSnippet
protected ResponseCookiesSnippet(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
. IfignoreUndocumentedCookies
istrue
, undocumented cookies will be ignored and will not trigger a failure.- Parameters:
descriptors
- the descriptorsignoreUndocumentedCookies
- whether undocumented cookies should be ignored
-
ResponseCookiesSnippet
Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
. The givenattributes
will be included in the model during template rendering. Undocumented cookies will not be ignored.- Parameters:
descriptors
- the descriptorsattributes
- the additional attributes
-
ResponseCookiesSnippet
protected ResponseCookiesSnippet(List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newResponseCookiesSnippet
that will document the cookies in the response using the givendescriptors
. The givenattributes
will be included in the model during template rendering.- Parameters:
descriptors
- the descriptorsattributes
- the additional attributesignoreUndocumentedCookies
- whether undocumented cookies should be ignored
-
-
Method Details
-
extractActualCookies
Description copied from class:AbstractCookiesSnippet
Extracts the names of the cookies from the request or response of the givenoperation
.- Specified by:
extractActualCookies
in classAbstractCookiesSnippet
- Parameters:
operation
- the operation- Returns:
- the cookie names
-
verificationFailed
Description copied from class:AbstractCookiesSnippet
Called when the documented cookies do not match the actual cookies.- Specified by:
verificationFailed
in classAbstractCookiesSnippet
- Parameters:
undocumentedCookies
- the cookies that were found in the operation but were not documentedmissingCookies
- the cookies that were documented but were not found in the operation
-
and
Returns a newResponseCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newResponseCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-