Class RequestCookiesSnippet
java.lang.Object
org.springframework.restdocs.snippet.TemplatedSnippet
org.springframework.restdocs.cookies.AbstractCookiesSnippet
org.springframework.restdocs.cookies.RequestCookiesSnippet
- All Implemented Interfaces:
Snippet
A
Snippet
that documents the cookies in a request.- Since:
- 3.0
- Author:
- Clyde Stubbs, Andy Wilkinson
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
RequestCookiesSnippet
(List<CookieDescriptor> descriptors) Creates a newRequestCookiesSnippet
that will document the cookies in the request using the givendescriptors
.protected
RequestCookiesSnippet
(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippet
that will document the cookies in the request using the givendescriptors
.protected
RequestCookiesSnippet
(List<CookieDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestCookiesSnippet
that will document the cookies in the request using the givendescriptors
.protected
RequestCookiesSnippet
(List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippet
that will document the cookies in the request using the givendescriptors
. -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestCookiesSnippet
and
(List<CookieDescriptor> additionalDescriptors) Returns a newRequestCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.final RequestCookiesSnippet
and
(CookieDescriptor... additionalDescriptors) Returns a newRequestCookiesSnippet
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
-
RequestCookiesSnippet
Creates a newRequestCookiesSnippet
that will document the cookies in the request using the givendescriptors
.- Parameters:
descriptors
- the descriptors
-
RequestCookiesSnippet
protected RequestCookiesSnippet(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippet
that will document the cookies in the request 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
-
RequestCookiesSnippet
Creates a newRequestCookiesSnippet
that will document the cookies in the request 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
-
RequestCookiesSnippet
protected RequestCookiesSnippet(List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippet
that will document the cookies in the request 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 newRequestCookiesSnippet
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 newRequestCookiesSnippet
configured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors
.- Parameters:
additionalDescriptors
- the additional descriptors- Returns:
- the new snippet
-