Class AbstractCookiesSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.cookies.AbstractCookiesSnippet
- All Implemented Interfaces:
Snippet
- Direct Known Subclasses:
RequestCookiesSnippet
,ResponseCookiesSnippet
Abstract
TemplatedSnippet
subclass that provides a base for snippets that
document a RESTful resource's request or response cookies.- Since:
- 3.0
- Author:
- Clyde Stubbs, Andy Wilkinson
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractCookiesSnippet
(String type, List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newAbstractCookiesSnippet
that will produce a snippet named<type>-cookies
. -
Method Summary
Modifier and TypeMethodDescriptioncreateModel
(Operation operation) Create the model that should be used during template rendering to document the givenoperation
.createModelForDescriptor
(CookieDescriptor descriptor) Returns a model for the givendescriptor
.extractActualCookies
(Operation operation) Extracts the names of the cookies from the request or response of the givenoperation
.protected final Map<String,
CookieDescriptor> Returns the list ofCookieDescriptors
that will be used to generate the documentation.protected final boolean
Returns whether or not this snippet ignores undocumented cookies.protected abstract 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.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
AbstractCookiesSnippet
protected AbstractCookiesSnippet(String type, List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newAbstractCookiesSnippet
that will produce a snippet named<type>-cookies
. The cookies will be documented using the givendescriptors
and the givenattributes
will be included in the model during template rendering.- Parameters:
type
- the type of the cookiesdescriptors
- the cookie descriptorsattributes
- the additional attributesignoreUndocumentedCookies
- whether undocumented cookies should be ignored
-
-
Method Details
-
createModel
Description copied from class:TemplatedSnippet
Create the model that should be used during template rendering to document the givenoperation
. Any additional attributes that were supplied when thisTemplatedSnippet
were created will be automatically added to the model prior to rendering.- Specified by:
createModel
in classTemplatedSnippet
- Parameters:
operation
- the operation- Returns:
- the model
-
extractActualCookies
Extracts the names of the cookies from the request or response of the givenoperation
.- Parameters:
operation
- the operation- Returns:
- the cookie names
-
verificationFailed
protected abstract void verificationFailed(Set<String> undocumentedCookies, Set<String> missingCookies) Called when the documented cookies do not match the actual cookies.- 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
-
getCookieDescriptors
Returns the list ofCookieDescriptors
that will be used to generate the documentation.- Returns:
- the cookie descriptors
-
isIgnoreUndocumentedCookies
protected final boolean isIgnoreUndocumentedCookies()Returns whether or not this snippet ignores undocumented cookies.- Returns:
true
if undocumented cookies are ignored, otherwisefalse
-
createModelForDescriptor
Returns a model for the givendescriptor
.- Parameters:
descriptor
- the descriptor- Returns:
- the model
-