Consistently use ID-based equality check for TemplateFormat
Closes gh-530
This commit is contained in:
committed by
Andy Wilkinson
parent
93cb08a4cc
commit
d05f6cdb6a
@@ -17,7 +17,7 @@
|
||||
package org.springframework.restdocs.templates;
|
||||
|
||||
/**
|
||||
* An enumeration of the built-in formats for which templates are provuded.
|
||||
* An enumeration of the built-in formats for which templates are provided.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.1.0
|
||||
|
||||
@@ -86,8 +86,8 @@ public class RestDocumentationConfigurerTests {
|
||||
SnippetConfiguration snippetConfiguration = (SnippetConfiguration) configuration
|
||||
.get(SnippetConfiguration.class.getName());
|
||||
assertThat(snippetConfiguration.getEncoding(), is(equalTo("UTF-8")));
|
||||
assertThat(snippetConfiguration.getTemplateFormat(),
|
||||
is(equalTo(TemplateFormats.asciidoctor())));
|
||||
assertThat(snippetConfiguration.getTemplateFormat().getId(),
|
||||
is(equalTo(TemplateFormats.asciidoctor().getId())));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,8 +168,8 @@ public class RestDocumentationConfigurerTests {
|
||||
instanceOf(SnippetConfiguration.class)));
|
||||
SnippetConfiguration snippetConfiguration = (SnippetConfiguration) configuration
|
||||
.get(SnippetConfiguration.class.getName());
|
||||
assertThat(snippetConfiguration.getTemplateFormat(),
|
||||
is(equalTo(TemplateFormats.markdown())));
|
||||
assertThat(snippetConfiguration.getTemplateFormat().getId(),
|
||||
is(equalTo(TemplateFormats.markdown().getId())));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
@@ -173,7 +173,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -164,7 +164,7 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -178,7 +178,7 @@ public class LinksSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -461,7 +461,7 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -472,7 +472,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -87,8 +87,7 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
public void missingOptionalPathParameter() throws IOException {
|
||||
this.snippets.expectPathParameters()
|
||||
.withContents(tableWithTitleAndHeader(
|
||||
this.templateFormat == TemplateFormats.asciidoctor() ? "+/{a}+"
|
||||
: "`/{a}`",
|
||||
getTitle("/{a}"),
|
||||
"Parameter", "Description").row("`a`", "one").row("`b`", "two"));
|
||||
new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"),
|
||||
parameterWithName("b").description("two").optional()))
|
||||
@@ -101,8 +100,7 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
public void presentOptionalPathParameter() throws IOException {
|
||||
this.snippets.expectPathParameters()
|
||||
.withContents(tableWithTitleAndHeader(
|
||||
this.templateFormat == TemplateFormats.asciidoctor() ? "+/{a}+"
|
||||
: "`/{a}`",
|
||||
getTitle("/{a}"),
|
||||
"Parameter", "Description").row("`a`", "one"));
|
||||
new PathParametersSnippet(
|
||||
Arrays.asList(parameterWithName("a").description("one").optional()))
|
||||
@@ -208,7 +206,7 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
@@ -219,7 +217,7 @@ public class PathParametersSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String getTitle(String title) {
|
||||
if (this.templateFormat.equals(TemplateFormats.asciidoctor())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.asciidoctor().getId())) {
|
||||
return "+" + title + "+";
|
||||
}
|
||||
return "`" + title + "`";
|
||||
|
||||
@@ -200,7 +200,7 @@ public class RequestParametersSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
@@ -191,7 +191,7 @@ public class RequestPartsSnippetTests extends AbstractSnippetTests {
|
||||
}
|
||||
|
||||
private String escapeIfNecessary(String input) {
|
||||
if (this.templateFormat.equals(TemplateFormats.markdown())) {
|
||||
if (this.templateFormat.getId().equals(TemplateFormats.markdown().getId())) {
|
||||
return input;
|
||||
}
|
||||
return input.replace("|", "\\|");
|
||||
|
||||
Reference in New Issue
Block a user