Fix kebab and snake case formatting of all upper case words

Closes gh-658
This commit is contained in:
Andy Wilkinson
2020-09-01 16:28:03 +01:00
parent baaf4f2e05
commit 536e87acc9
2 changed files with 48 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2019 the original author or authors.
* Copyright 2014-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,12 +38,48 @@ public class RestDocumentationContextPlaceholderResolverTests {
.isEqualTo("dash-separated-method-name");
}
@Test
public void kebabCaseMethodNameWithUpperCaseOpeningSection() throws Exception {
assertThat(createResolver("URIDashSeparatedMethodName").resolvePlaceholder("method-name"))
.isEqualTo("uri-dash-separated-method-name");
}
@Test
public void kebabCaseMethodNameWithUpperCaseMidSection() throws Exception {
assertThat(createResolver("dashSeparatedMethodNameWithURIInIt").resolvePlaceholder("method-name"))
.isEqualTo("dash-separated-method-name-with-uri-in-it");
}
@Test
public void kebabCaseMethodNameWithUpperCaseEndSection() throws Exception {
assertThat(createResolver("dashSeparatedMethodNameWithURI").resolvePlaceholder("method-name"))
.isEqualTo("dash-separated-method-name-with-uri");
}
@Test
public void snakeCaseMethodName() throws Exception {
assertThat(createResolver("underscoreSeparatedMethodName").resolvePlaceholder("method_name"))
.isEqualTo("underscore_separated_method_name");
}
@Test
public void snakeCaseMethodNameWithUpperCaseOpeningSection() throws Exception {
assertThat(createResolver("URIUnderscoreSeparatedMethodName").resolvePlaceholder("method_name"))
.isEqualTo("uri_underscore_separated_method_name");
}
@Test
public void snakeCaseMethodNameWithUpperCaseMidSection() throws Exception {
assertThat(createResolver("underscoreSeparatedMethodNameWithURIInIt").resolvePlaceholder("method_name"))
.isEqualTo("underscore_separated_method_name_with_uri_in_it");
}
@Test
public void snakeCaseMethodNameWithUpperCaseEndSection() throws Exception {
assertThat(createResolver("underscoreSeparatedMethodNameWithURI").resolvePlaceholder("method_name"))
.isEqualTo("underscore_separated_method_name_with_uri");
}
@Test
public void camelCaseMethodName() throws Exception {
assertThat(createResolver("camelCaseMethodName").resolvePlaceholder("methodName"))