diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java index bb7cff80..86f5a04f 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/CurlRequestSnippetTests.java @@ -278,8 +278,8 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests { .request("http://localhost/upload").method("POST") .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) - .part("image", new byte[0]) - .submittedFileName("documents/images/example.png").build()); + .part("image", new byte[0]) + .submittedFileName("documents/images/example.png").build()); } @Test @@ -309,7 +309,7 @@ public class CurlRequestSnippetTests extends AbstractSnippetTests { .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils .encodeToString("user:secret".getBytes())) - .build()); + .build()); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java index 3fd92c38..8f9f48db 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/cli/HttpieRequestSnippetTests.java @@ -280,8 +280,8 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests { .request("http://localhost/upload").method("POST") .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) - .part("image", new byte[0]) - .submittedFileName("documents/images/example.png").build()); + .part("image", new byte[0]) + .submittedFileName("documents/images/example.png").build()); } @Test @@ -311,7 +311,7 @@ public class HttpieRequestSnippetTests extends AbstractSnippetTests { .header(HttpHeaders.AUTHORIZATION, "Basic " + Base64Utils .encodeToString("user:secret".getBytes())) - .build()); + .build()); } @Test 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 59441562..2f97aee8 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 @@ -61,16 +61,13 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests { headerWithName("Accept-Language").description("four"), headerWithName("Cache-Control").description("five"), headerWithName("Connection").description("six"))) - .document( - operationBuilder("request-with-headers") - .request("http://localhost") - .header("X-Test", "test") - .header("Accept", "*/*") - .header("Accept-Encoding", - "gzip, deflate") - .header("Accept-Language", "en-US,en;q=0.5") - .header("Cache-Control", "max-age=0") - .header("Connection", "keep-alive").build()); + .document(operationBuilder("request-with-headers") + .request("http://localhost") + .header("X-Test", "test").header("Accept", "*/*") + .header("Accept-Encoding", "gzip, deflate") + .header("Accept-Language", "en-US,en;q=0.5") + .header("Cache-Control", "max-age=0") + .header("Connection", "keep-alive").build()); } @Test @@ -140,7 +137,7 @@ public class RequestHeadersSnippetTests extends AbstractSnippetTests { .header("X-Test", "test") .header("Accept-Encoding", "gzip, deflate") - .header("Accept", "*/*").build()); + .header("Accept", "*/*").build()); } @Test 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 d3f2ffbd..463f631c 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 @@ -64,9 +64,9 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests { .header("X-Test", "test") .header("Content-Type", "application/json") - .header("Etag", "lskjadldj3ii32l2ij23") - .header("Cache-Control", "max-age=0") - .header("Vary", "User-Agent").build()); + .header("Etag", "lskjadldj3ii32l2ij23") + .header("Cache-Control", "max-age=0") + .header("Vary", "User-Agent").build()); } @Test @@ -130,7 +130,8 @@ public class ResponseHeadersSnippetTests extends AbstractSnippetTests { .response().header("X-Test", "test") .header("Content-Type", "application/json") - .header("Etag", "lskjadldj3ii32l2ij23").build()); + .header("Etag", "lskjadldj3ii32l2ij23") + .build()); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java index 0660eac8..32e1e680 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/http/HttpRequestSnippetTests.java @@ -86,8 +86,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests { String content = "Hello, world"; this.snippet.expectHttpRequest("post-request-with-content") .withContents(httpRequest(RequestMethod.POST, "/foo") - .header(HttpHeaders.HOST, "localhost").content(content) - .header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length)); + .header(HttpHeaders.HOST, "localhost").content(content).header( + HttpHeaders.CONTENT_LENGTH, content.getBytes().length)); new HttpRequestSnippet().document(operationBuilder("post-request-with-content") .request("http://localhost/foo").method("POST").content(content).build()); @@ -140,8 +140,8 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests { String content = "Hello, world"; this.snippet.expectHttpRequest("put-request-with-content") .withContents(httpRequest(RequestMethod.PUT, "/foo") - .header(HttpHeaders.HOST, "localhost").content(content) - .header(HttpHeaders.CONTENT_LENGTH, content.getBytes().length)); + .header(HttpHeaders.HOST, "localhost").content(content).header( + HttpHeaders.CONTENT_LENGTH, content.getBytes().length)); new HttpRequestSnippet().document(operationBuilder("put-request-with-content") .request("http://localhost/foo").method("PUT").content(content).build()); @@ -176,7 +176,7 @@ public class HttpRequestSnippetTests extends AbstractSnippetTests { .request("http://localhost/upload").method("POST") .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) - .part("image", "<< data >>".getBytes()).build()); + .part("image", "<< data >>".getBytes()).build()); } @Test 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 e94abfc3..81ee8b4e 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 @@ -149,12 +149,14 @@ public class LinksSnippetTests extends AbstractSnippetTests { new LinkDescriptor("a").description("one") .attributes(key("foo").value("alpha")), new LinkDescriptor("b").description("two").attributes( - key("foo").value("bravo")))).document(operationBuilder( - "links-with-custom-descriptor-attributes") - .attribute(TemplateEngine.class.getName(), - new MustacheTemplateEngine( - resolver)) - .build()); + key("foo").value("bravo")))) + .document(operationBuilder( + "links-with-custom-descriptor-attributes") + .attribute(TemplateEngine.class + .getName(), + new MustacheTemplateEngine( + resolver)) + .build()); } @Test @@ -165,7 +167,7 @@ public class LinksSnippetTests extends AbstractSnippetTests { HypermediaDocumentation .links(new StubLinkExtractor().withLinks(new Link("a", "alpha"), new Link("b", "bravo")), - new LinkDescriptor("a").description("one")) + new LinkDescriptor("a").description("one")) .and(new LinkDescriptor("b").description("two")) .document(operationBuilder("additional-descriptors").build()); } diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java index 84accb52..319c37fb 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/operation/preprocess/PrettyPrintingContentModifierTests.java @@ -56,7 +56,7 @@ public class PrettyPrintingContentModifierTests { equalTo(String .format("%n" + "%n %n%n") - .getBytes())); + .getBytes())); } @Test diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java index 6cadefeb..8b2760a9 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/RequestFieldsSnippetFailureTests.java @@ -75,11 +75,13 @@ public class RequestFieldsSnippetFailureTests { @Test public void missingOptionalRequestFieldWithNoTypeProvided() throws IOException { this.thrown.expect(FieldTypeRequiredException.class); - new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one") - .optional())).document(new OperationBuilder( - "missing-optional-request-field-with-no-type", - this.snippet.getOutputDirectory()).request("http://localhost") - .content("{ }").build()); + new RequestFieldsSnippet( + Arrays.asList(fieldWithPath("a.b").description("one").optional())) + .document(new OperationBuilder( + "missing-optional-request-field-with-no-type", + this.snippet.getOutputDirectory()) + .request("http://localhost").content("{ }") + .build()); } @Test @@ -136,7 +138,7 @@ public class RequestFieldsSnippetFailureTests { .content("") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test 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 d94a9071..9245d915 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 @@ -51,8 +51,8 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests { public void mapRequestWithFields() throws IOException { this.snippet.expectRequestFields("map-request-with-fields") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a.b", "Number", "one").row("a.c", "String", "two") - .row("a", "Object", "three")); + .row("a.b", "Number", "one").row("a.c", "String", "two").row("a", + "Object", "three")); new RequestFieldsSnippet(Arrays.asList(fieldWithPath("a.b").description("one"), fieldWithPath("a.c").description("two"), @@ -150,15 +150,15 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests { .request("http://localhost") .content( "{\"a\": {\"b\": 5, \"c\": \"charlie\"}}") - .build()); + .build()); } @Test public void xmlRequestFields() throws IOException { this.snippet.expectRequestFields("xml-request") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a/b", "b", "one").row("a/c", "c", "two") - .row("a", "a", "three")); + .row("a/b", "b", "one").row("a/c", "c", "two").row("a", "a", + "three")); new RequestFieldsSnippet( Arrays.asList(fieldWithPath("a/b").description("one").type("b"), @@ -170,15 +170,15 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests { .content("5charlie") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test public void additionalDescriptors() throws IOException { this.snippet.expectRequestFields("additional-descriptors") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a.b", "Number", "one").row("a.c", "String", "two") - .row("a", "Object", "three")); + .row("a.b", "Number", "one").row("a.c", "String", "two").row("a", + "Object", "three")); PayloadDocumentation .requestFields(fieldWithPath("a.b").description("one"), @@ -193,8 +193,8 @@ public class RequestFieldsSnippetTests extends AbstractSnippetTests { public void prefixedAdditionalDescriptors() throws IOException { this.snippet.expectRequestFields("prefixed-additional-descriptors") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a", "Object", "one").row("a.b", "Number", "two") - .row("a.c", "String", "three")); + .row("a", "Object", "one").row("a.b", "Number", "two").row("a.c", + "String", "three")); PayloadDocumentation.requestFields(fieldWithPath("a").description("one")) .andWithPrefix("a.", fieldWithPath("b").description("two"), diff --git a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java index b8b25684..34770b61 100644 --- a/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java +++ b/spring-restdocs-core/src/test/java/org/springframework/restdocs/payload/ResponseFieldsSnippetFailureTests.java @@ -63,7 +63,7 @@ public class ResponseFieldsSnippetFailureTests { .content("5") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -79,7 +79,7 @@ public class ResponseFieldsSnippetFailureTests { .content("foo") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -89,15 +89,14 @@ public class ResponseFieldsSnippetFailureTests { String.format("The following parts of the payload were not documented:" + "%nbar%n"))); new ResponseFieldsSnippet( - Arrays.asList( - fieldWithPath("a/@id").description("one") - .type("a"))).document(new OperationBuilder( - "documented-attribute-is-removed", + Arrays.asList(fieldWithPath("a/@id").description("one").type("a"))) + .document( + new OperationBuilder("documented-attribute-is-removed", this.snippet.getOutputDirectory()).response() .content("bar") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -124,7 +123,7 @@ public class ResponseFieldsSnippetFailureTests { .content("") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -145,7 +144,7 @@ public class ResponseFieldsSnippetFailureTests { .content("5") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } } 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 215eb4c8..8e777d3f 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 @@ -80,7 +80,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { operationBuilder("array-response-with-fields").response() .content( "[{\"a\": {\"b\": 5}},{\"a\": {\"c\": \"charlie\"}}]") - .build()); + .build()); } @Test @@ -145,8 +145,8 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { .row("a", "Object", "three", "charlie")); new ResponseFieldsSnippet(Arrays.asList( - fieldWithPath("a.b").description("one") - .attributes(key("foo").value("alpha")), + fieldWithPath("a.b").description("one").attributes(key("foo") + .value("alpha")), fieldWithPath("a.c").description("two") .attributes(key("foo").value("bravo")), fieldWithPath("a").description("three") @@ -164,8 +164,8 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { public void xmlResponseFields() throws IOException { this.snippet.expectResponseFields("xml-response") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a/b", "b", "one").row("a/c", "c", "two") - .row("a", "a", "three")); + .row("a/b", "b", "one").row("a/c", "c", "two").row("a", "a", + "three")); new ResponseFieldsSnippet( Arrays.asList(fieldWithPath("a/b").description("one").type("b"), fieldWithPath("a/c").description("two").type("c"), @@ -175,7 +175,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { .content("5charlie") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -191,7 +191,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { .content("foo") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -207,7 +207,7 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { .response().content("foo") .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE) - .build()); + .build()); } @Test @@ -248,8 +248,8 @@ public class ResponseFieldsSnippetTests extends AbstractSnippetTests { public void prefixedAdditionalDescriptors() throws IOException { this.snippet.expectResponseFields("prefixed-additional-descriptors") .withContents(tableWithHeader("Path", "Type", "Description") - .row("a", "Object", "one").row("a.b", "Number", "two") - .row("a.c", "String", "three")); + .row("a", "Object", "one").row("a.b", "Number", "two").row("a.c", + "String", "three")); PayloadDocumentation.responseFields(fieldWithPath("a").description("one")) .andWithPrefix("a.", fieldWithPath("b").description("two"), 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 c3443048..eac8c9d1 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 @@ -77,11 +77,10 @@ public class PathParametersSnippetTests extends AbstractSnippetTests { tableWithTitleAndHeader(getTitle(), "Parameter", "Description").row("b", "two")); new PathParametersSnippet( - Arrays.asList(parameterWithName("b").description("two")), - true).document(operationBuilder("ignore-all-undocumented") - .attribute(RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, - "/{a}/{b}") - .build()); + Arrays.asList(parameterWithName("b").description("two")), true) + .document(operationBuilder("ignore-all-undocumented").attribute( + RestDocumentationGenerator.ATTRIBUTE_NAME_URL_TEMPLATE, + "/{a}/{b}").build()); } @Test @@ -125,8 +124,8 @@ public class PathParametersSnippetTests extends AbstractSnippetTests { Arrays.asList( parameterWithName("a").description("one") .attributes(key("foo").value("alpha")), - parameterWithName("b").description("two") - .attributes(key("foo").value("bravo"))), + parameterWithName("b").description("two") + .attributes(key("foo").value("bravo"))), attributes(key("title").value("The title"))).document( operationBuilder("path-parameters-with-custom-attributes") .attribute( 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 a62c5de2..380f1cc3 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 @@ -116,8 +116,8 @@ public class RequestParametersSnippetTests extends AbstractSnippetTests { Arrays.asList( parameterWithName("a").description("one") .attributes(key("foo").value("alpha")), - parameterWithName("b").description("two") - .attributes(key("foo").value("bravo"))), + parameterWithName("b").description("two") + .attributes(key("foo").value("bravo"))), attributes(key("title").value("The title"))).document( operationBuilder("request-parameters-with-custom-attributes") .attribute(TemplateEngine.class.getName(), 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 54bce09f..28b76962 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 @@ -266,9 +266,8 @@ public class MockMvcRestDocumentationIntegrationTests { mockMvc.perform(get("/").param("foo", "bar").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) - .andDo(document("links", - responseFields(fieldWithPath("a") - .description("The description"), + .andDo(document("links", responseFields( + fieldWithPath("a").description("The description"), fieldWithPath("links").description("Links to other resources")))); assertExpectedSnippetFilesExist(new File("build/generated-snippets/links"),