From 2730a7ceef8e2a34f754cae4fea2e957cb69484a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 30 Sep 2015 19:28:43 +0100 Subject: [PATCH] Polishing --- .../headers/AbstractHeadersSnippet.java | 15 ++++-------- ...kMvcRestDocumentationIntegrationTests.java | 24 ------------------- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java index 5c3099b9..f5e2c126 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/headers/AbstractHeadersSnippet.java @@ -75,18 +75,13 @@ public abstract class AbstractHeadersSnippet extends TemplatedSnippet { private void validateHeaderDocumentation(Operation operation) { List missingHeaders = findMissingHeaders(operation); - if (!missingHeaders.isEmpty()) { - String message = ""; - if (!missingHeaders.isEmpty()) { - List names = new ArrayList(); - for (HeaderDescriptor headerDescriptor : missingHeaders) { - names.add(headerDescriptor.getName()); - } - message += "Headers with the following names were not found in the " - + this.type + ": " + names; + List names = new ArrayList(); + for (HeaderDescriptor headerDescriptor : missingHeaders) { + names.add(headerDescriptor.getName()); } - throw new SnippetException(message); + throw new SnippetException("Headers with the following names were not found" + + " in the " + this.type + ": " + names); } } diff --git a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java index 8c5be89e..546a17e7 100644 --- a/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java +++ b/spring-restdocs-mockmvc/src/test/java/org/springframework/restdocs/mockmvc/MockMvcRestDocumentationIntegrationTests.java @@ -400,30 +400,6 @@ public class MockMvcRestDocumentationIntegrationTests { "$ curl 'http://localhost:8080/custom/' -i -H 'Accept: application/json'")))); } - @Test - public void stackOverflowQuestion() throws Exception { - MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context) - .apply(documentationConfiguration(this.restDocumentation)).build(); - - mockMvc.perform(get("/company/5").accept(MediaType.APPLICATION_JSON)) - .andExpect(status().isOk()) - .andDo(document( - "company", - responseFields( - fieldWithPath("companyName").description( - "The name of the company"), - fieldWithPath("employee").description( - "An array of the company's employees")))) - .andDo(document( - "employee", - responseFields( - fieldWithPath("companyName").ignored(), - fieldWithPath("employee[].name").description( - "The name of the employee"), - fieldWithPath("employee[].age").description( - "The age of the employee")))); - } - private void assertExpectedSnippetFilesExist(File directory, String... snippets) { for (String snippet : snippets) { assertTrue(new File(directory, snippet).isFile());