|
20 | 20 |
|
21 | 21 | import org.junit.Test;
|
22 | 22 |
|
| 23 | +import org.springframework.http.HttpHeaders; |
| 24 | +import org.springframework.http.MediaType; |
23 | 25 | import org.springframework.restdocs.AbstractSnippetTests;
|
24 | 26 | import org.springframework.restdocs.templates.TemplateEngine;
|
25 | 27 | import org.springframework.restdocs.templates.TemplateFormat;
|
|
29 | 31 | import static org.assertj.core.api.Assertions.assertThat;
|
30 | 32 | import static org.mockito.BDDMockito.given;
|
31 | 33 | import static org.mockito.Mockito.mock;
|
32 |
| -import static org.springframework.restdocs.payload.PayloadDocumentation.beneathPath; |
33 |
| -import static org.springframework.restdocs.payload.PayloadDocumentation.responseBody; |
| 34 | +import static org.springframework.restdocs.payload.PayloadDocumentation.*; |
| 35 | +import static org.springframework.restdocs.payload.PayloadDocumentation.requestBody; |
34 | 36 | import static org.springframework.restdocs.snippet.Attributes.attributes;
|
35 | 37 | import static org.springframework.restdocs.snippet.Attributes.key;
|
36 | 38 |
|
@@ -58,6 +60,22 @@ public void responseWithNoBody() throws IOException {
|
58 | 60 | assertThat(this.generatedSnippets.snippet("response-body")).is(codeBlock(null, "nowrap").withContent(""));
|
59 | 61 | }
|
60 | 62 |
|
| 63 | + @Test |
| 64 | + public void responseWithMediaTypeJson() throws IOException { |
| 65 | + new ResponseBodySnippet().document(this.operationBuilder.response() |
| 66 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) |
| 67 | + .build()); |
| 68 | + assertThat(this.generatedSnippets.snippet("response-body")).is(codeBlock("json", "nowrap").withContent("")); |
| 69 | + } |
| 70 | + |
| 71 | + @Test |
| 72 | + public void responseWithMediaTypeXml() throws IOException { |
| 73 | + new ResponseBodySnippet().document(this.operationBuilder.response() |
| 74 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_ATOM_XML_VALUE) |
| 75 | + .build()); |
| 76 | + assertThat(this.generatedSnippets.snippet("response-body")).is(codeBlock("xml", "nowrap").withContent("")); |
| 77 | + } |
| 78 | + |
61 | 79 | @Test
|
62 | 80 | public void subsectionOfResponseBody() throws IOException {
|
63 | 81 | responseBody(beneathPath("a.b"))
|
|
0 commit comments