diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java index 706078d0..8a2f9314 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/snippet/RestDocumentationContextPlaceholderResolver.java @@ -66,22 +66,26 @@ public class RestDocumentationContextPlaceholderResolver implements PlaceholderR return this.context.getTestMethodName(); } if ("method-name".equals(placeholderName)) { - return camelCaseToDash(this.context.getTestMethodName()); + return camelCaseToKebabCase(this.context.getTestMethodName()); } if ("method_name".equals(placeholderName)) { - return camelCaseToUnderscore(this.context.getTestMethodName()); + return camelCaseToSnakeCase(this.context.getTestMethodName()); } return null; } - private String camelCaseToDash(String string) { + protected final String camelCaseToKebabCase(String string) { return camelCaseToSeparator(string, "-"); } - private String camelCaseToUnderscore(String string) { + protected final String camelCaseToSnakeCase(String string) { return camelCaseToSeparator(string, "_"); } + protected final RestDocumentationContext getContext() { + return this.context; + } + private String camelCaseToSeparator(String string, String separator) { Matcher matcher = CAMEL_CASE_PATTERN.matcher(string); StringBuffer result = new StringBuffer();