Class RestDocumentationContextPlaceholderResolver
java.lang.Object
org.springframework.restdocs.snippet.RestDocumentationContextPlaceholderResolver
- All Implemented Interfaces:
org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver
public class RestDocumentationContextPlaceholderResolver
extends Object
implements org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver
A
PropertyPlaceholderHelper.PlaceholderResolver that resolves placeholders using a
RestDocumentationContext. The following placeholders are supported:
step- thestep current count.methodName- the unmodified name of thecurrent test methodwithout applying any formattingmethod-name- the name of thecurrent test methodformatted using kebab-casemethod_name- the name of thecurrent test methodformatted using snake_caseClassName- the unmodifiedsimple nameof thecurrent test classclass-name- thesimple nameof thecurrent test classformatted using kebab-caseclass_name- thesimple nameof thecurrent test classformatted using snake case
- Author:
- Andy Wilkinson
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new placeholder resolver that will resolve placeholders using the givencontext. -
Method Summary
Modifier and TypeMethodDescriptionprotected final StringcamelCaseToKebabCase(String string) Converts the givenstringfrom camelCase to kebab-case.protected final StringcamelCaseToSnakeCase(String string) Converts the givenstringfrom camelCase to snake_case.protected final RestDocumentationContextReturns theRestDocumentationContextthat should be used during placeholder resolution.resolvePlaceholder(String placeholderName)
-
Constructor Details
-
RestDocumentationContextPlaceholderResolver
Creates a new placeholder resolver that will resolve placeholders using the givencontext.- Parameters:
context- the context to use
-
-
Method Details
-
resolvePlaceholder
- Specified by:
resolvePlaceholderin interfaceorg.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver
-
camelCaseToKebabCase
Converts the givenstringfrom camelCase to kebab-case.- Parameters:
string- the string- Returns:
- the converted string
-
camelCaseToSnakeCase
Converts the givenstringfrom camelCase to snake_case.- Parameters:
string- the string- Returns:
- the converted string
-
getContext
Returns theRestDocumentationContextthat should be used during placeholder resolution.- Returns:
- the context
-