|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2019 the original author or authors. |
| 2 | + * Copyright 2014-2022 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
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;
|
@@ -61,6 +63,38 @@ public void requestPartWithNoBody() throws IOException {
|
61 | 63 | .is(codeBlock(null, "nowrap").withContent(""));
|
62 | 64 | }
|
63 | 65 |
|
| 66 | + @Test |
| 67 | + public void requestPartWithJsonMediaType() throws IOException { |
| 68 | + requestPartBody("one").document(this.operationBuilder.request("http://localhost").part("one", "".getBytes()) |
| 69 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build()); |
| 70 | + assertThat(this.generatedSnippets.snippet("request-part-one-body")) |
| 71 | + .is(codeBlock("json", "nowrap").withContent("")); |
| 72 | + } |
| 73 | + |
| 74 | + @Test |
| 75 | + public void requestPartWithJsonSubtypeMediaType() throws IOException { |
| 76 | + requestPartBody("one").document(this.operationBuilder.request("http://localhost").part("one", "".getBytes()) |
| 77 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_PROBLEM_JSON_VALUE).build()); |
| 78 | + assertThat(this.generatedSnippets.snippet("request-part-one-body")) |
| 79 | + .is(codeBlock("json", "nowrap").withContent("")); |
| 80 | + } |
| 81 | + |
| 82 | + @Test |
| 83 | + public void requestPartWithXmlMediaType() throws IOException { |
| 84 | + requestPartBody("one").document(this.operationBuilder.request("http://localhost").part("one", "".getBytes()) |
| 85 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML_VALUE).build()); |
| 86 | + assertThat(this.generatedSnippets.snippet("request-part-one-body")) |
| 87 | + .is(codeBlock("xml", "nowrap").withContent("")); |
| 88 | + } |
| 89 | + |
| 90 | + @Test |
| 91 | + public void requestPartWithXmlSubtypeMediaType() throws IOException { |
| 92 | + requestPartBody("one").document(this.operationBuilder.request("http://localhost").part("one", "".getBytes()) |
| 93 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_ATOM_XML_VALUE).build()); |
| 94 | + assertThat(this.generatedSnippets.snippet("request-part-one-body")) |
| 95 | + .is(codeBlock("xml", "nowrap").withContent("")); |
| 96 | + } |
| 97 | + |
64 | 98 | @Test
|
65 | 99 | public void subsectionOfRequestPartBody() throws IOException {
|
66 | 100 | requestPartBody("one", beneathPath("a.b")).document(this.operationBuilder.request("http://localhost")
|
|
0 commit comments