66import io .swagger .v3 .oas .models .Operation ;
77import io .swagger .v3 .oas .models .media .Schema ;
88import org .testng .annotations .BeforeMethod ;
9+ import org .testng .annotations .DataProvider ;
910import org .testng .annotations .Test ;
1011
1112import static org .testng .AssertJUnit .assertEquals ;
1213
1314public class APIResponsesResourceTest {
1415 private OpenAPI openAPI ;
1516
17+ // Prepare list of resource schema URLs
18+ @ DataProvider (name = "schemas" )
19+ public String [] getSchemas () {
20+ return new String [] {
21+ "/postStringOrEmailSchemaContent" ,
22+ "/postBooleanSchemaContent" ,
23+ "/postByteOrBinarySchemaContent" ,
24+ "/postURISchemaContent" ,
25+ "/postURLSchemaContent" ,
26+ "/postUUIDSchemaContent" ,
27+ "/postIntegerSchemaContent" ,
28+ "/postLongSchemaContent" ,
29+ "/postFloatSchemaContent" ,
30+ "/postDoubleSchemaContent" ,
31+ "/postBigIntegerSchemaContent" ,
32+ "/postBigDecimalSchemaContent" ,
33+ "/postNumberSchemaContent" ,
34+ "/postDateStubSchemaContent" ,
35+ "/postDateSchemaContent" ,
36+ "/postLocalTimeSchemaContent" ,
37+ "/postFileSchemaContent" ,
38+ "/postObjectSchemaContent"
39+ };
40+ }
41+
1642 @ BeforeMethod
1743 public void setUp () {
1844 SwaggerConfiguration config = new SwaggerConfiguration ().openAPI31 (true );
@@ -25,145 +51,9 @@ private Schema getResponseSchema(String path) {
2551 return postOperation .getResponses ().get ("200" ).getContent ().get ("*/*" ).getSchema ();
2652 }
2753
28- @ Test
29- public void testStringOrEmailSchemaAPIResource31 () {
30- Schema responseSchema = getResponseSchema ("/postStringOrEmailSchemaContent" );
31-
32- // Value of field "type" must equal value of field "types"
33- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
34- }
35-
36- @ Test
37- public void testBooleanSchemaAPIResource31 () {
38- Schema responseSchema = getResponseSchema ("/postBooleanSchemaContent" );
39-
40- // Value of field "type" must equal value of field "types"
41- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
42- }
43-
44- @ Test
45- public void testByteOrBinarySchemaAPIResource31 () {
46- Schema responseSchema = getResponseSchema ("/postByteOrBinarySchemaContent" );
47-
48- // Value of field "type" must equal value of field "types"
49- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
50- }
51-
52- @ Test
53- public void testURISchemaAPIResource31 () {
54- Schema responseSchema = getResponseSchema ("/postURISchemaContent" );
55-
56- // Value of field "type" must equal value of field "types"
57- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
58- }
59-
60- @ Test
61- public void testURLSchemaAPIResource31 () {
62- Schema responseSchema = getResponseSchema ("/postURLSchemaContent" );
63-
64- // Value of field "type" must equal value of field "types"
65- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
66- }
67-
68- @ Test
69- public void testUUIDSchemaAPIResource31 () {
70- Schema responseSchema = getResponseSchema ("/postUUIDSchemaContent" );
71-
72- // Value of field "type" must equal value of field "types"
73- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
74- }
75-
76- @ Test
77- public void testIntegerSchemaAPIResource31 () {
78- Schema responseSchema = getResponseSchema ("/postIntegerSchemaContent" );
79-
80- // Value of field "type" must equal value of field "types"
81- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
82- }
83-
84- @ Test
85- public void testLongSchemaAPIResource31 () {
86- Schema responseSchema = getResponseSchema ("/postLongSchemaContent" );
87-
88- // Value of field "type" must equal value of field "types"
89- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
90- }
91-
92- @ Test
93- public void testFloatSchemaAPIResource31 () {
94- Schema responseSchema = getResponseSchema ("/postFloatSchemaContent" );
95-
96- // Value of field "type" must equal value of field "types"
97- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
98- }
99-
100- @ Test
101- public void testDoubleSchemaAPIResource31 () {
102- Schema responseSchema = getResponseSchema ("/postDoubleSchemaContent" );
103-
104- // Value of field "type" must equal value of field "types"
105- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
106- }
107-
108- @ Test
109- public void testBigIntegerSchemaAPIResource31 () {
110- Schema responseSchema = getResponseSchema ("/postBigIntegerSchemaContent" );
111-
112- // Value of field "type" must equal value of field "types"
113- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
114- }
115-
116- @ Test
117- public void testBigDecimalSchemaAPIResource31 () {
118- Schema responseSchema = getResponseSchema ("/postBigDecimalSchemaContent" );
119-
120- // Value of field "type" must equal value of field "types"
121- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
122- }
123-
124- @ Test
125- public void testNumberSchemaAPIResource31 () {
126- Schema responseSchema = getResponseSchema ("/postNumberSchemaContent" );
127-
128- // Value of field "type" must equal value of field "types"
129- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
130- }
131-
132- @ Test
133- public void testDateStubSchemaAPIResource31 () {
134- Schema responseSchema = getResponseSchema ("/postDateStubSchemaContent" );
135-
136- // Value of field "type" must equal value of field "types"
137- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
138- }
139-
140- @ Test
141- public void testDateSchemaAPIResource31 () {
142- Schema responseSchema = getResponseSchema ("/postDateSchemaContent" );
143-
144- // Value of field "type" must equal value of field "types"
145- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
146- }
147-
148- @ Test
149- public void testLocalTimeSchemaAPIResource31 () {
150- Schema responseSchema = getResponseSchema ("/postLocalTimeSchemaContent" );
151-
152- // Value of field "type" must equal value of field "types"
153- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
154- }
155-
156- @ Test
157- public void testFileSchemaAPIResource31 () {
158- Schema responseSchema = getResponseSchema ("/postFileSchemaContent" );
159-
160- // Value of field "type" must equal value of field "types"
161- assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
162- }
163-
164- @ Test
165- public void testObjectSchemaAPIResource31 () {
166- Schema responseSchema = getResponseSchema ("/postObjectSchemaContent" );
54+ @ Test (dataProvider = "schemas" )
55+ public void testSchemaAPIResource31 (String schema ) {
56+ Schema responseSchema = getResponseSchema (schema );
16757
16858 // Value of field "type" must equal value of field "types"
16959 assertEquals (responseSchema .getType (), responseSchema .getTypes ().iterator ().next ());
0 commit comments