diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java index 1b76d0c0..32f5b4aa 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/templates/TemplateFormats.java @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 the original author or authors. + * Copyright 2014-2018 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. @@ -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 diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java index 67ea00f0..c4d16936 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/config/RestDocumentationConfigurerTests.java @@ -100,9 +100,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()))); OperationRequestPreprocessor defaultOperationRequestPreprocessor = (OperationRequestPreprocessor) configuration .get(RestDocumentationGenerator.ATTRIBUTE_NAME_DEFAULT_OPERATION_REQUEST_PREPROCESSOR); assertThat(defaultOperationRequestPreprocessor, is(nullValue())); @@ -190,8 +189,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") diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetTests.java index 8b9007bd..81318305 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/RequestHeadersSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetTests.java index fbf5887b..0156812f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/headers/ResponseHeadersSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java index 5797dda4..71bf83c0 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/hypermedia/LinksSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java index 43eece49..7ceb2ab6 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java index 020131df..9388dd1e 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java index e053430d..47060e89 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/PathParametersSnippetTests.java @@ -85,11 +85,9 @@ public class PathParametersSnippetTests extends AbstractSnippetTests { @Test public void missingOptionalPathParameter() throws IOException { - this.snippets.expectPathParameters() - .withContents(tableWithTitleAndHeader( - this.templateFormat == TemplateFormats.asciidoctor() ? "+/{a}+" - : "`/{a}`", - "Parameter", "Description").row("`a`", "one").row("`b`", "two")); + this.snippets.expectPathParameters().withContents( + tableWithTitleAndHeader(getTitle("/{a}"), "Parameter", "Description") + .row("`a`", "one").row("`b`", "two")); new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"), parameterWithName("b").description("two").optional())) .document(this.operationBuilder.attribute( @@ -99,11 +97,9 @@ public class PathParametersSnippetTests extends AbstractSnippetTests { @Test public void presentOptionalPathParameter() throws IOException { - this.snippets.expectPathParameters() - .withContents(tableWithTitleAndHeader( - this.templateFormat == TemplateFormats.asciidoctor() ? "+/{a}+" - : "`/{a}`", - "Parameter", "Description").row("`a`", "one")); + this.snippets.expectPathParameters().withContents( + tableWithTitleAndHeader(getTitle("/{a}"), "Parameter", "Description") + .row("`a`", "one")); new PathParametersSnippet( Arrays.asList(parameterWithName("a").description("one").optional())) .document(this.operationBuilder.attribute( @@ -208,7 +204,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 +215,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 + "`"; diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java index 3aa98e02..da1fecbe 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestParametersSnippetTests.java @@ -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("|", "\\|"); diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetTests.java index 2c495400..9abbd4ac 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/request/RequestPartsSnippetTests.java @@ -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("|", "\\|");