Apply Eclipse Mars (4.5.2) code formatting

This commit is contained in:
Andy Wilkinson
2016-05-05 09:50:01 +01:00
parent 032b7b59dc
commit a3e6883524
10 changed files with 145 additions and 122 deletions

View File

@@ -262,8 +262,8 @@ public class CurlRequestSnippetTests {
.request("http://localhost/upload").method("POST")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA_VALUE)
.part("metadata", "{\"description\": \"foo\"}".getBytes())
.build());
.part("metadata", "{\"description\": \"foo\"}".getBytes())
.build());
}
@Test
@@ -279,9 +279,11 @@ public class CurlRequestSnippetTests {
.request("http://localhost/upload").method("POST")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA_VALUE)
.part("image", new byte[0])
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
.submittedFileName("documents/images/example.png").build());
.part("image", new byte[0])
.header(HttpHeaders.CONTENT_TYPE,
MediaType.IMAGE_PNG_VALUE)
.submittedFileName("documents/images/example.png")
.build());
}
@Test
@@ -314,9 +316,10 @@ public class CurlRequestSnippetTests {
.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").and()
.param("a", "apple", "avocado").param("b", "banana").build());
.part("image", new byte[0])
.submittedFileName("documents/images/example.png").and()
.param("a", "apple", "avocado").param("b", "banana")
.build());
}
@Test

View File

@@ -62,20 +62,18 @@ public class RequestHeadersSnippetTests {
.row("Accept", "two").row("Accept-Encoding", "three")
.row("Accept-Language", "four").row("Cache-Control", "five")
.row("Connection", "six"));
new RequestHeadersSnippet(
Arrays.asList(headerWithName("X-Test").description("one"),
headerWithName("Accept").description("two"),
headerWithName("Accept-Encoding").description("three"),
headerWithName("Accept-Language").description("four"),
headerWithName("Cache-Control").description("five"),
headerWithName("Connection").description("six")))
.document(new OperationBuilder("request-with-headers",
this.snippet.getOutputDirectory())
.request("http://localhost")
.header("X-Test", "test")
.header("Accept", "*/*")
.header("Accept-Encoding",
"gzip, deflate")
new RequestHeadersSnippet(Arrays.asList(
headerWithName("X-Test").description("one"),
headerWithName("Accept").description("two"),
headerWithName("Accept-Encoding").description("three"),
headerWithName("Accept-Language").description("four"),
headerWithName("Cache-Control").description("five"),
headerWithName("Connection").description("six")))
.document(new OperationBuilder("request-with-headers",
this.snippet.getOutputDirectory())
.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());
@@ -143,14 +141,15 @@ public class RequestHeadersSnippetTests {
TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
given(resolver.resolveTemplateResource("request-headers"))
.willReturn(snippetResource("request-headers-with-extra-column"));
new RequestHeadersSnippet(Arrays.asList(
headerWithName("X-Test").description("one")
.attributes(key("foo").value("alpha")),
headerWithName("Accept-Encoding").description("two")
.attributes(key("foo").value("bravo")),
headerWithName("Accept").description("three")
.attributes(key("foo").value("charlie"))))
.document(new OperationBuilder(
new RequestHeadersSnippet(
Arrays.asList(
headerWithName("X-Test").description("one")
.attributes(key("foo").value(
"alpha")),
headerWithName("Accept-Encoding").description("two")
.attributes(key("foo").value("bravo")),
headerWithName("Accept").description("three").attributes(key(
"foo").value("charlie")))).document(new OperationBuilder(
"request-headers-with-custom-attributes",
this.snippet.getOutputDirectory())
.attribute(TemplateEngine.class.getName(),

View File

@@ -72,9 +72,9 @@ public class ResponseHeadersSnippetTests {
.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
@@ -107,15 +107,20 @@ public class ResponseHeadersSnippetTests {
.attributes(key("foo").value("charlie"))))
.document(new OperationBuilder(
"response-headers-with-custom-attributes",
this.snippet.getOutputDirectory())
.attribute(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
resolver))
.response().header("X-Test", "test")
.header("Content-Type",
"application/json")
.header("Etag", "lskjadldj3ii32l2ij23")
.build());
this.snippet
.getOutputDirectory())
.attribute(
TemplateEngine.class
.getName(),
new MustacheTemplateEngine(
resolver))
.response()
.header("X-Test", "test")
.header("Content-Type",
"application/json")
.header("Etag",
"lskjadldj3ii32l2ij23")
.build());
}
@Test

View File

@@ -92,8 +92,8 @@ public class HttpRequestSnippetTests {
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(new OperationBuilder("post-request-with-content",
@@ -154,8 +154,8 @@ public class HttpRequestSnippetTests {
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(new OperationBuilder("put-request-with-content",
this.snippet.getOutputDirectory()).request("http://localhost/foo")
@@ -223,8 +223,8 @@ public class HttpRequestSnippetTests {
.request("http://localhost/upload").method("POST")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA_VALUE)
.param("a", "apple", "avocado").param("b", "banana")
.part("image", "<< data >>".getBytes()).build());
.param("a", "apple", "avocado").param("b", "banana")
.part("image", "<< data >>".getBytes()).build());
}
@Test
@@ -269,9 +269,10 @@ public class HttpRequestSnippetTests {
.request("http://localhost/upload").method("POST")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.MULTIPART_FORM_DATA_VALUE)
.part("image", "<< data >>".getBytes())
.header(HttpHeaders.CONTENT_TYPE, MediaType.IMAGE_PNG_VALUE)
.build());
.part("image", "<< data >>".getBytes())
.header(HttpHeaders.CONTENT_TYPE,
MediaType.IMAGE_PNG_VALUE)
.build());
}
@Test

View File

@@ -56,7 +56,7 @@ public class PrettyPrintingContentModifierTests {
equalTo(String
.format("<?xml version=\"1.0\" encoding=\"UTF-8\"?>%n"
+ "<one a=\"alpha\">%n <two b=\"bravo\"/>%n</one>%n")
.getBytes()));
.getBytes()));
}
@Test

View File

@@ -61,8 +61,8 @@ public class RequestFieldsSnippetTests {
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"),
@@ -132,11 +132,13 @@ public class RequestFieldsSnippetTests {
@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
@@ -175,14 +177,17 @@ public class RequestFieldsSnippetTests {
.attributes(key("foo").value("charlie"))))
.document(new OperationBuilder(
"request-fields-with-custom-descriptor-attributes",
this.snippet.getOutputDirectory())
.attribute(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
resolver))
.request("http://localhost")
.content(
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
.build());
this.snippet
.getOutputDirectory())
.attribute(
TemplateEngine.class
.getName(),
new MustacheTemplateEngine(
resolver))
.request("http://localhost")
.content(
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
.build());
}
@Test
@@ -228,8 +233,8 @@ public class RequestFieldsSnippetTests {
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"),
@@ -241,7 +246,7 @@ public class RequestFieldsSnippetTests {
.content("<a><b>5</b><c>charlie</c></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -283,7 +288,7 @@ public class RequestFieldsSnippetTests {
.content("<a></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test

View File

@@ -94,7 +94,7 @@ public class ResponseFieldsSnippetTests {
.response()
.content(
"[{\"a\": {\"b\": 5}},{\"a\": {\"c\": \"charlie\"}}]")
.build());
.build());
}
@Test
@@ -141,14 +141,17 @@ public class ResponseFieldsSnippetTests {
.attributes(key("foo").value("charlie"))))
.document(new OperationBuilder(
"response-fields-with-custom-attributes",
this.snippet.getOutputDirectory())
.attribute(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
resolver))
.response()
.content(
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
.build());
this.snippet
.getOutputDirectory())
.attribute(
TemplateEngine.class
.getName(),
new MustacheTemplateEngine(
resolver))
.response()
.content(
"{\"a\": {\"b\": 5, \"c\": \"charlie\"}}")
.build());
}
@Test
@@ -172,8 +175,8 @@ public class ResponseFieldsSnippetTests {
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"),
@@ -183,7 +186,7 @@ public class ResponseFieldsSnippetTests {
.content("<a><b>5</b><c>charlie</c></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -199,7 +202,7 @@ public class ResponseFieldsSnippetTests {
.content("<a><b>5</b></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -215,7 +218,7 @@ public class ResponseFieldsSnippetTests {
.content("<a id=\"1\">foo</a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -231,7 +234,7 @@ public class ResponseFieldsSnippetTests {
.content("<a>foo</a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -263,7 +266,7 @@ public class ResponseFieldsSnippetTests {
.content("<a id=\"foo\">bar</a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -273,15 +276,14 @@ public class ResponseFieldsSnippetTests {
String.format("The following parts of the payload were not documented:"
+ "%n<a>bar</a>%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("<a id=\"foo\">bar</a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -308,7 +310,7 @@ public class ResponseFieldsSnippetTests {
.content("<a></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
@Test
@@ -329,7 +331,7 @@ public class ResponseFieldsSnippetTests {
.content("<a><c>5</c></a>")
.header(HttpHeaders.CONTENT_TYPE,
MediaType.APPLICATION_XML_VALUE)
.build());
.build());
}
private FileSystemResource snippetResource(String name) {

View File

@@ -79,7 +79,7 @@ public class PathParametersSnippetTests {
.document(new OperationBuilder("missing-path-parameter",
this.snippet.getOutputDirectory()).attribute(
"org.springframework.restdocs.urlTemplate", "/")
.build());
.build());
}
@Test
@@ -104,11 +104,13 @@ public class PathParametersSnippetTests {
tableWithTitleAndHeader("/{a}/{b}", "Parameter", "Description")
.row("a", "one").row("b", "two"));
new PathParametersSnippet(Arrays.asList(parameterWithName("a").description("one"),
parameterWithName("b").description("two"))).document(new OperationBuilder(
"path-parameters", this.snippet.getOutputDirectory())
.attribute("org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
.build());
parameterWithName("b").description("two")))
.document(new OperationBuilder(
"path-parameters", this.snippet.getOutputDirectory())
.attribute(
"org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
.build());
}
@Test
@@ -117,11 +119,14 @@ public class PathParametersSnippetTests {
tableWithTitleAndHeader("/{a}/{b}", "Parameter", "Description").row("b",
"two"));
new PathParametersSnippet(Arrays.asList(parameterWithName("a").ignored(),
parameterWithName("b").description("two"))).document(new OperationBuilder(
"ignored-path-parameter", this.snippet.getOutputDirectory())
.attribute("org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
.build());
parameterWithName("b").description("two")))
.document(new OperationBuilder(
"ignored-path-parameter",
this.snippet.getOutputDirectory())
.attribute(
"org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
.build());
}
@Test
@@ -156,9 +161,10 @@ public class PathParametersSnippetTests {
parameterWithName("b").description("two").attributes(
key("foo").value("bravo")))).document(new OperationBuilder(
"path-parameters-with-custom-descriptor-attributes",
this.snippet.getOutputDirectory()).attribute(
"org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
this.snippet.getOutputDirectory())
.attribute(
"org.springframework.restdocs.urlTemplate",
"/{a}/{b}")
.attribute(TemplateEngine.class.getName(),
new MustacheTemplateEngine(resolver))
.build());
@@ -176,8 +182,8 @@ public class PathParametersSnippetTests {
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(
new OperationBuilder("path-parameters-with-custom-attributes",
this.snippet.getOutputDirectory())

View File

@@ -151,13 +151,16 @@ public class RequestParametersSnippetTests {
.attributes(key("foo").value("bravo"))))
.document(new OperationBuilder(
"request-parameters-with-custom-descriptor-attributes",
this.snippet.getOutputDirectory())
.attribute(TemplateEngine.class.getName(),
new MustacheTemplateEngine(
resolver))
.request("http://localhost")
.param("a", "alpha").param("b", "bravo")
.build());
this.snippet
.getOutputDirectory())
.attribute(
TemplateEngine.class
.getName(),
new MustacheTemplateEngine(
resolver))
.request("http://localhost")
.param("a", "alpha")
.param("b", "bravo").build());
}
@Test
@@ -172,8 +175,8 @@ public class RequestParametersSnippetTests {
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(
new OperationBuilder("request-parameters-with-custom-attributes",
this.snippet.getOutputDirectory())

View File

@@ -217,9 +217,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"),