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
ConstructorsModifierConstructorDescriptionprotectedRequestCookiesSnippet(List<CookieDescriptor> descriptors) Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors.protectedRequestCookiesSnippet(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors.protectedRequestCookiesSnippet(List<CookieDescriptor> descriptors, Map<String, Object> attributes) Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors.protectedRequestCookiesSnippet(List<CookieDescriptor> descriptors, Map<String, Object> attributes, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors. -
Method Summary
Modifier and TypeMethodDescriptionfinal RequestCookiesSnippetand(List<CookieDescriptor> additionalDescriptors) Returns a newRequestCookiesSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.final RequestCookiesSnippetand(CookieDescriptor... additionalDescriptors) Returns a newRequestCookiesSnippetconfigured 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 voidverificationFailed(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, isIgnoreUndocumentedCookiesMethods inherited from class org.springframework.restdocs.snippet.TemplatedSnippet
document, getAttributes, getSnippetName
-
Constructor Details
-
RequestCookiesSnippet
Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors.- Parameters:
descriptors- the descriptors
-
RequestCookiesSnippet
protected RequestCookiesSnippet(List<CookieDescriptor> descriptors, boolean ignoreUndocumentedCookies) Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors. IfignoreUndocumentedCookiesistrue, undocumented cookies will be ignored and will not trigger a failure.- Parameters:
descriptors- the descriptorsignoreUndocumentedCookies- whether undocumented cookies should be ignored
-
RequestCookiesSnippet
Creates a newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors. The givenattributeswill 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 newRequestCookiesSnippetthat will document the cookies in the request using the givendescriptors. The givenattributeswill 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:AbstractCookiesSnippetExtracts the names of the cookies from the request or response of the givenoperation.- Specified by:
extractActualCookiesin classAbstractCookiesSnippet- Parameters:
operation- the operation- Returns:
- the cookie names
-
verificationFailed
Description copied from class:AbstractCookiesSnippetCalled when the documented cookies do not match the actual cookies.- Specified by:
verificationFailedin 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 newRequestCookiesSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-
and
Returns a newRequestCookiesSnippetconfigured with this snippet's attributes and its descriptors combined with the givenadditionalDescriptors.- Parameters:
additionalDescriptors- the additional descriptors- Returns:
- the new snippet
-