7
7
* Licensed under the Apache License, Version 2.0 (the "License");
8
8
* you may not use this file except in compliance with the License.
9
9
* You may obtain a copy of the License at
10
- *
10
+ *
11
11
* http://www.apache.org/licenses/LICENSE-2.0
12
- *
12
+ *
13
13
* Unless required by applicable law or agreed to in writing, software
14
14
* distributed under the License is distributed on an "AS IS" BASIS,
15
15
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
37
37
38
38
import java .util .ArrayList ;
39
39
import java .util .Arrays ;
40
+ import java .util .Collections ;
41
+ import java .util .List ;
40
42
41
43
import capital .scalable .restdocs .i18n .TranslationRule ;
42
44
import capital .scalable .restdocs .javadoc .JavadocReader ;
43
45
import org .junit .Before ;
44
46
import org .junit .Rule ;
45
47
import org .junit .Test ;
48
+ import org .junit .runners .Parameterized ;
46
49
import org .springframework .restdocs .AbstractSnippetTests ;
47
50
import org .springframework .restdocs .http .HttpDocumentation ;
48
51
import org .springframework .restdocs .templates .TemplateFormat ;
52
+ import org .springframework .restdocs .templates .TemplateFormats ;
53
+ import org .springframework .restdocs .test .ExpectedSnippets ;
54
+ import org .springframework .restdocs .test .OperationBuilder ;
49
55
import org .springframework .web .method .HandlerMethod ;
50
56
51
- public class SectionSnippetTest extends AbstractSnippetTests {
57
+ public class SectionSnippetTest {
52
58
53
59
private JavadocReader javadocReader ;
54
60
55
61
@ Rule
56
62
public TranslationRule translationRule = new TranslationRule ();
57
63
58
- public SectionSnippetTest (String name , TemplateFormat templateFormat ) {
59
- super (name , templateFormat );
64
+ @ Rule
65
+ public ExpectedSnippets snippets ;
66
+
67
+ @ Rule
68
+ public OperationBuilder operationBuilder ;
69
+
70
+ public SectionSnippetTest () {
71
+ // Only runs for AsciiDoctor, because Markdown is not supported.
72
+ TemplateFormat templateFormat = TemplateFormats .asciidoctor ();
73
+ this .snippets = new ExpectedSnippets (templateFormat );
74
+ this .operationBuilder = new OperationBuilder (templateFormat );
60
75
}
61
76
62
77
@ Before
@@ -72,8 +87,8 @@ public void noSnippets() throws Exception {
72
87
this .snippets .expect (SECTION )
73
88
.withContents (equalTo ("[[resources-noSnippets]]\n " +
74
89
"=== Get Item By Id\n \n " +
75
- "include::{snippets}/noSnippets/ auto-method-path.adoc[]\n \n " +
76
- "include::{snippets}/noSnippets/ auto-description.adoc[]\n " ));
90
+ "include::auto-method-path.adoc[]\n \n " +
91
+ "include::auto-description.adoc[]\n " ));
77
92
78
93
new SectionBuilder ()
79
94
.snippetNames ()
@@ -91,8 +106,8 @@ public void noHandlerMethod() throws Exception {
91
106
this .snippets .expect (SECTION )
92
107
.withContents (equalTo ("[[resources-noHandlerMethod]]\n " +
93
108
"=== No Handler Method\n \n " +
94
- "include::{snippets}/noHandlerMethod/ auto-method-path.adoc[]\n \n " +
95
- "include::{snippets}/noHandlerMethod/ auto-description.adoc[]\n " ));
109
+ "include::auto-method-path.adoc[]\n \n " +
110
+ "include::auto-description.adoc[]\n " ));
96
111
97
112
new SectionBuilder ()
98
113
.snippetNames ()
@@ -112,22 +127,22 @@ public void defaultSnippets() throws Exception {
112
127
this .snippets .expect (SECTION )
113
128
.withContents (equalTo ("[[resources-defaultSnippets]]\n " +
114
129
"=== Get Item By Id\n \n " +
115
- "include::{snippets}/defaultSnippets/ auto-method-path.adoc[]\n \n " +
116
- "include::{snippets}/defaultSnippets/ auto-description.adoc[]\n \n " +
130
+ "include::auto-method-path.adoc[]\n \n " +
131
+ "include::auto-description.adoc[]\n \n " +
117
132
"==== Authorization\n \n " +
118
- "include::{snippets}/defaultSnippets/ auto-authorization.adoc[]\n \n " +
133
+ "include::auto-authorization.adoc[]\n \n " +
119
134
"==== Path parameters\n \n " +
120
- "include::{snippets}/defaultSnippets/ auto-path-parameters.adoc[]\n \n " +
135
+ "include::auto-path-parameters.adoc[]\n \n " +
121
136
"==== Query parameters\n \n " +
122
- "include::{snippets}/defaultSnippets/ auto-request-parameters.adoc[]\n \n " +
137
+ "include::auto-request-parameters.adoc[]\n \n " +
123
138
"==== Request fields\n \n " +
124
- "include::{snippets}/defaultSnippets/ auto-request-fields.adoc[]\n \n " +
139
+ "include::auto-request-fields.adoc[]\n \n " +
125
140
"==== Response fields\n \n " +
126
- "include::{snippets}/defaultSnippets/ auto-response-fields.adoc[]\n \n " +
141
+ "include::auto-response-fields.adoc[]\n \n " +
127
142
"==== Example request\n \n " +
128
- "include::{snippets}/defaultSnippets/ curl-request.adoc[]\n \n " +
143
+ "include::curl-request.adoc[]\n \n " +
129
144
"==== Example response\n \n " +
130
- "include::{snippets}/defaultSnippets/ http-response.adoc[]\n " ));
145
+ "include::http-response.adoc[]\n " ));
131
146
132
147
new SectionBuilder ().build ()
133
148
.document (operationBuilder
@@ -149,14 +164,14 @@ public void customSnippets() throws Exception {
149
164
this .snippets .expect (SECTION )
150
165
.withContents (equalTo ("[[resources-customSnippets]]\n " +
151
166
"=== Get Item By Id\n \n " +
152
- "include::{snippets}/customSnippets/ auto-method-path.adoc[]\n \n " +
153
- "include::{snippets}/customSnippets/ auto-description.adoc[]\n \n " +
167
+ "include::auto-method-path.adoc[]\n \n " +
168
+ "include::auto-description.adoc[]\n \n " +
154
169
"==== Example response\n \n " +
155
- "include::{snippets}/customSnippets/ http-response.adoc[]\n \n " +
170
+ "include::http-response.adoc[]\n \n " +
156
171
"==== Response fields\n \n " +
157
- "include::{snippets}/customSnippets/ auto-response-fields.adoc[]\n \n " +
172
+ "include::auto-response-fields.adoc[]\n \n " +
158
173
"==== Example request\n \n " +
159
- "include::{snippets}/customSnippets/ http-request.adoc[]\n " ));
174
+ "include::http-request.adoc[]\n " ));
160
175
161
176
new SectionBuilder ()
162
177
.snippetNames (HTTP_RESPONSE , RESPONSE_FIELDS , HTTP_REQUEST )
@@ -180,14 +195,14 @@ public void skipEmpty() throws Exception {
180
195
this .snippets .expect (SECTION )
181
196
.withContents (equalTo ("[[resources-skipEmpty]]\n " +
182
197
"=== Get Item By Id\n \n " +
183
- "include::{snippets}/skipEmpty/ auto-method-path.adoc[]\n \n " +
184
- "include::{snippets}/skipEmpty/ auto-description.adoc[]\n \n " +
198
+ "include::auto-method-path.adoc[]\n \n " +
199
+ "include::auto-description.adoc[]\n \n " +
185
200
"==== Authorization\n \n " +
186
- "include::{snippets}/skipEmpty/ auto-authorization.adoc[]\n \n " +
201
+ "include::auto-authorization.adoc[]\n \n " +
187
202
"==== Example request\n \n " +
188
- "include::{snippets}/skipEmpty/ curl-request.adoc[]\n \n " +
203
+ "include::curl-request.adoc[]\n \n " +
189
204
"==== Example response\n \n " +
190
- "include::{snippets}/skipEmpty/ http-response.adoc[]\n " ));
205
+ "include::http-response.adoc[]\n " ));
191
206
192
207
new SectionBuilder ()
193
208
.skipEmpty (true )
@@ -211,8 +226,8 @@ public void customTitle() throws Exception {
211
226
this .snippets .expect (SECTION )
212
227
.withContents (equalTo ("[[resources-customTitle]]\n " +
213
228
"=== Custom title\n \n " +
214
- "include::{snippets}/customTitle/ auto-method-path.adoc[]\n \n " +
215
- "include::{snippets}/customTitle/ auto-description.adoc[]\n " ));
229
+ "include::auto-method-path.adoc[]\n \n " +
230
+ "include::auto-description.adoc[]\n " ));
216
231
217
232
new SectionBuilder ()
218
233
.snippetNames ()
@@ -236,8 +251,8 @@ public void deprecated() throws Exception {
236
251
this .snippets .expect (SECTION )
237
252
.withContents (equalTo ("[[resources-deprecated]]\n " +
238
253
"=== Get Item By Id (deprecated)\n \n " +
239
- "include::{snippets}/deprecated/ auto-method-path.adoc[]\n \n " +
240
- "include::{snippets}/deprecated/ auto-description.adoc[]\n " ));
254
+ "include::auto-method-path.adoc[]\n \n " +
255
+ "include::auto-description.adoc[]\n " ));
241
256
242
257
new SectionBuilder ()
243
258
.snippetNames ()
@@ -260,22 +275,22 @@ public void translation() throws Exception {
260
275
this .snippets .expect (SECTION )
261
276
.withContents (equalTo ("[[resources-translation]]\n " +
262
277
"=== Get Item By Id\n \n " +
263
- "include::{snippets}/translation/ auto-method-path.adoc[]\n \n " +
264
- "include::{snippets}/translation/ auto-description.adoc[]\n \n " +
278
+ "include::auto-method-path.adoc[]\n \n " +
279
+ "include::auto-description.adoc[]\n \n " +
265
280
"==== XAuthorization\n \n " +
266
- "include::{snippets}/translation/ auto-authorization.adoc[]\n \n " +
281
+ "include::auto-authorization.adoc[]\n \n " +
267
282
"==== XPath parameters\n \n " +
268
- "include::{snippets}/translation/ auto-path-parameters.adoc[]\n \n " +
283
+ "include::auto-path-parameters.adoc[]\n \n " +
269
284
"==== XQuery parameters\n \n " +
270
- "include::{snippets}/translation/ auto-request-parameters.adoc[]\n \n " +
285
+ "include::auto-request-parameters.adoc[]\n \n " +
271
286
"==== XRequest fields\n \n " +
272
- "include::{snippets}/translation/ auto-request-fields.adoc[]\n \n " +
287
+ "include::auto-request-fields.adoc[]\n \n " +
273
288
"==== XResponse fields\n \n " +
274
- "include::{snippets}/translation/ auto-response-fields.adoc[]\n \n " +
289
+ "include::auto-response-fields.adoc[]\n \n " +
275
290
"==== XExample request\n \n " +
276
- "include::{snippets}/translation/ curl-request.adoc[]\n \n " +
291
+ "include::curl-request.adoc[]\n \n " +
277
292
"==== XExample response\n \n " +
278
- "include::{snippets}/translation/ http-response.adoc[]\n " ));
293
+ "include::http-response.adoc[]\n " ));
279
294
280
295
new SectionBuilder ().build ()
281
296
.document (operationBuilder
0 commit comments