Merge branch '1.2.x'

This commit is contained in:
Andy Wilkinson
2018-08-01 12:00:03 +01:00
10 changed files with 21 additions and 26 deletions

View File

@@ -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

View File

@@ -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")

View File

@@ -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("|", "\\|");

View File

@@ -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("|", "\\|");

View File

@@ -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("|", "\\|");

View File

@@ -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("|", "\\|");

View File

@@ -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("|", "\\|");

View File

@@ -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 + "`";

View File

@@ -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("|", "\\|");

View File

@@ -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("|", "\\|");