Skip to content

Commit c1dc157

Browse files
committed
more passing tests
1 parent d2ca690 commit c1dc157

File tree

4 files changed

+60
-52
lines changed

4 files changed

+60
-52
lines changed

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/processors/ResponseProcessorTest.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ public class ResponseProcessorTest {
3838
@Injectable
3939
boolean openapi31;
4040

41+
@Injectable
42+
Schema responseSchema;
43+
@Injectable
44+
Header responseHeader;
45+
4146
@Test
42-
public void testProcessResponse(@Injectable final Schema responseSchema,
43-
@Injectable final Header responseHeader) throws Exception {
47+
public void testProcessResponse() throws Exception {
4448

4549
new Expectations(){{
4650
new SchemaProcessor(cache, swagger, openapi31);
4751
times=1;
48-
result = propertyProcessor;
4952

5053
new HeaderProcessor(cache,swagger, openapi31);
5154
times = 1;
52-
result = headerProcessor;
5355

5456
new LinkProcessor(cache,swagger, openapi31);
5557
times = 1;
56-
result = linkProcessor;
57-
5858

5959
propertyProcessor.processSchema(responseSchema);
6060
times=1;
@@ -72,6 +72,7 @@ public void testProcessResponse(@Injectable final Schema responseSchema,
7272
new ResponseProcessor(cache, swagger, openapi31).processResponse(response);
7373

7474

75-
new FullVerifications(){{}};
75+
new FullVerifications(){{
76+
}};
7677
}
7778
}

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/OpenAPIResolverTest.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979

8080
public class OpenAPIResolverTest {
8181

82+
@Injectable OpenAPI swagger;
83+
List<AuthorizationValue> auths = new ArrayList<>();
84+
@Mocked ResolverCache cache;
85+
@Injectable ParseOptions parseOptions;
86+
@Mocked ComponentsProcessor componentsProcessor;
87+
@Mocked PathsProcessor pathsProcessor;
88+
8289
protected int serverPort = getDynamicPort();
8390
protected WireMockServer wireMockServer;
8491
private static final String REMOTE_REF_JSON = "http://localhost:${dynamicPort}/remote_ref_json#/components/schemas/Tag";
@@ -571,7 +578,7 @@ public void pathsResolver() throws Exception {
571578
}
572579

573580
@Test
574-
public void testSelfReferenceResolution(@Injectable final List<AuthorizationValue> auths)throws Exception {
581+
public void testSelfReferenceResolution()throws Exception {
575582

576583
String yaml = "" +
577584
"openapi: 3.0.1\n" +
@@ -613,7 +620,7 @@ public void testSelfReferenceResolution(@Injectable final List<AuthorizationValu
613620
}
614621

615622
@Test
616-
public void testIssue85(@Injectable final List<AuthorizationValue> auths) {
623+
public void testIssue85() {
617624
String yaml =
618625
"openapi: '3.0.1'\n" +
619626
"paths: \n" +
@@ -662,7 +669,7 @@ public void testIssue85(@Injectable final List<AuthorizationValue> auths) {
662669
}
663670

664671
@Test
665-
public void testIssue1352(@Injectable final List<AuthorizationValue> auths) {
672+
public void testIssue1352() {
666673
ParseOptions options = new ParseOptions();
667674
options.setResolve(true);
668675
options.setResolveFully(true);
@@ -673,7 +680,7 @@ public void testIssue1352(@Injectable final List<AuthorizationValue> auths) {
673680
}
674681

675682
@Test
676-
public void testIssue1157(@Injectable final List<AuthorizationValue> auths) {
683+
public void testIssue1157() {
677684
ParseOptions options = new ParseOptions();
678685
options.setResolve(true);
679686
options.setResolveFully(true);
@@ -696,7 +703,7 @@ public void testIssue1157(@Injectable final List<AuthorizationValue> auths) {
696703
}
697704

698705
@Test
699-
public void testIssue1161(@Injectable final List<AuthorizationValue> auths) {
706+
public void testIssue1161() {
700707
String path = "/issue-1161/swagger.yaml";
701708

702709
ParseOptions options = new ParseOptions();
@@ -721,7 +728,7 @@ public void testIssue1161(@Injectable final List<AuthorizationValue> auths) {
721728
}
722729

723730
@Test
724-
public void testIssue1170(@Injectable final List<AuthorizationValue> auths) {
731+
public void testIssue1170() {
725732
String path = "/issue-1170/swagger.yaml";
726733

727734
ParseOptions options = new ParseOptions();
@@ -790,7 +797,7 @@ public void testIssue1706() {
790797

791798

792799
@Test
793-
public void selfReferenceTest(@Injectable final List<AuthorizationValue> auths) {
800+
public void selfReferenceTest() {
794801
String yaml = "" +
795802
"openapi: 3.0.1\n" +
796803
"paths:\n" +
@@ -881,7 +888,7 @@ public void selfReferenceTest(@Injectable final List<AuthorizationValue> auths)
881888
}
882889

883890
@Test
884-
public void resolveAllOfWithoutAggregatingParameters(@Injectable final List<AuthorizationValue> auths) {
891+
public void resolveAllOfWithoutAggregatingParameters() {
885892
ParseOptions options = new ParseOptions();
886893
options.setResolveFully(true);
887894
options.setResolveCombinators(false);
@@ -910,7 +917,7 @@ public void resolveAllOfWithoutAggregatingParameters(@Injectable final List<Auth
910917
}
911918

912919
@Test
913-
public void resolveComposedReferenceAllOfSchema(@Injectable final List<AuthorizationValue> auths){
920+
public void resolveComposedReferenceAllOfSchema(){
914921

915922

916923

@@ -929,7 +936,7 @@ public void resolveComposedReferenceAllOfSchema(@Injectable final List<Authoriza
929936
}
930937

931938
@Test
932-
public void resolveComposedSchema(@Injectable final List<AuthorizationValue> auths){
939+
public void resolveComposedSchema(){
933940

934941
ParseOptions options = new ParseOptions();
935942
options.setResolveCombinators(false);
@@ -1004,7 +1011,7 @@ public void testParameterOnPathLevel() throws Exception {
10041011
}
10051012

10061013
@Test
1007-
public void testComposedSchemaAdjacent(@Injectable final List<AuthorizationValue> auths) throws Exception {
1014+
public void testComposedSchemaAdjacent() throws Exception {
10081015
ParseOptions options = new ParseOptions();
10091016
options.setResolve(true);
10101017
options.setResolveFully(true);
@@ -1025,7 +1032,7 @@ public void testComposedSchemaAdjacent(@Injectable final List<AuthorizationValue
10251032
}
10261033

10271034
@Test
1028-
public void testComposedSchemaAdjacentWithExamples(@Injectable final List<AuthorizationValue> auths) throws Exception {
1035+
public void testComposedSchemaAdjacentWithExamples() throws Exception {
10291036
ParseOptions options = new ParseOptions();
10301037
options.setResolve(true);
10311038
options.setResolveFully(true);
@@ -1044,7 +1051,7 @@ public void testComposedSchemaAdjacentWithExamples(@Injectable final List<Author
10441051
}
10451052

10461053
@Test
1047-
public void allOfExampleGeneration(@Injectable final List<AuthorizationValue> auths) throws JsonProcessingException {
1054+
public void allOfExampleGeneration() throws JsonProcessingException {
10481055
ParseOptions options = new ParseOptions();
10491056
options.setResolve(true);
10501057
options.setResolveFully(true);
@@ -1059,12 +1066,7 @@ public void allOfExampleGeneration(@Injectable final List<AuthorizationValue> au
10591066
}
10601067

10611068
@Test
1062-
public void testSwaggerResolver(@Injectable final OpenAPI swagger,
1063-
@Injectable final List<AuthorizationValue> auths,
1064-
@Mocked final ResolverCache cache,
1065-
@Injectable final ParseOptions parseOptions,
1066-
@Mocked final ComponentsProcessor componentsProcessor,
1067-
@Mocked final PathsProcessor pathsProcessor) throws Exception {
1069+
public void testSwaggerResolver() throws Exception {
10681070

10691071
new Expectations() {{
10701072
new ResolverCache(swagger, auths, null, new HashSet<>(), parseOptions);

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/test/ResolverCacheTest.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.testng.Assert.assertNotNull;
55
import static org.testng.Assert.assertNull;
66

7+
import java.util.ArrayList;
78
import java.util.HashSet;
89
import java.util.List;
910

@@ -39,11 +40,19 @@ public class ResolverCacheTest {
3940
@Mocked
4041
RefUtils refUtils;
4142

42-
4343
@Injectable
4444
OpenAPI openAPI;
45+
46+
List<AuthorizationValue> auths = new ArrayList<>();
47+
48+
@Injectable
49+
Parameter mockedParameter;
50+
51+
@Injectable
52+
Schema mockedModel;
53+
4554
@Injectable
46-
List<AuthorizationValue> auths;
55+
ApiResponse mockedResponse;
4756

4857
@Test
4958
public void testMock() throws Exception {
@@ -168,7 +177,7 @@ public void testLoadExternalRefResponseWithNoContent() throws Exception {
168177
}
169178

170179
@Test
171-
public void testLoadInternalParameterRef(@Injectable Parameter mockedParameter) throws Exception {
180+
public void testLoadInternalParameterRef() throws Exception {
172181
OpenAPI openAPI = new OpenAPI();
173182
openAPI.components(new Components().addParameters("foo", mockedParameter));
174183

@@ -181,7 +190,7 @@ public void testLoadInternalParameterRef(@Injectable Parameter mockedParameter)
181190
}
182191

183192
@Test
184-
public void testLoadInternalParameterRefWithSpaces(@Injectable Parameter mockedParameter) throws Exception {
193+
public void testLoadInternalParameterRefWithSpaces() throws Exception {
185194
OpenAPI openAPI = new OpenAPI();
186195
openAPI.components(new Components().addParameters("foo bar", mockedParameter));
187196

@@ -191,7 +200,7 @@ public void testLoadInternalParameterRefWithSpaces(@Injectable Parameter mockedP
191200
}
192201

193202
@Test
194-
public void testLoadInternalDefinitionRef(@Injectable Schema mockedModel) throws Exception {
203+
public void testLoadInternalDefinitionRef() throws Exception {
195204
OpenAPI openAPI = new OpenAPI();
196205
openAPI.components(new Components().addSchemas("foo", mockedModel));
197206

@@ -204,7 +213,7 @@ public void testLoadInternalDefinitionRef(@Injectable Schema mockedModel) throws
204213
}
205214

206215
@Test
207-
public void testLoadInternalDefinitionRefWithSpaces(@Injectable Schema mockedModel) throws Exception {
216+
public void testLoadInternalDefinitionRefWithSpaces() throws Exception {
208217
OpenAPI openAPI = new OpenAPI();
209218
openAPI.components(new Components().addSchemas("foo bar", mockedModel));
210219

@@ -214,7 +223,7 @@ public void testLoadInternalDefinitionRefWithSpaces(@Injectable Schema mockedMod
214223
}
215224

216225
@Test
217-
public void testLoadInternalDefinitionRefWithEscapedCharacters(@Injectable Schema mockedModel) throws Exception {
226+
public void testLoadInternalDefinitionRefWithEscapedCharacters() throws Exception {
218227
OpenAPI openAPI = new OpenAPI();
219228
openAPI.components(new Components().addSchemas("foo~bar/baz~1", mockedModel));
220229

@@ -224,7 +233,7 @@ public void testLoadInternalDefinitionRefWithEscapedCharacters(@Injectable Schem
224233
}
225234

226235
@Test
227-
public void testLoadInternalResponseRef(@Injectable ApiResponse mockedResponse) throws Exception {
236+
public void testLoadInternalResponseRef() throws Exception {
228237
OpenAPI openAPI = new OpenAPI();
229238
openAPI.components(new Components().addResponses("foo", mockedResponse));
230239

@@ -236,7 +245,7 @@ public void testLoadInternalResponseRef(@Injectable ApiResponse mockedResponse)
236245
}
237246

238247
@Test
239-
public void testLoadInternalResponseRefWithSpaces(@Injectable ApiResponse mockedResponse) throws Exception {
248+
public void testLoadInternalResponseRefWithSpaces() throws Exception {
240249
OpenAPI openAPI = new OpenAPI();
241250
openAPI.components(new Components().addResponses("foo bar", mockedResponse));
242251

modules/swagger-parser-v3/src/test/java/io/swagger/v3/parser/util/OpenAPIDeserializerTest.java

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,7 @@
5353
import java.nio.file.Files;
5454
import java.time.OffsetDateTime;
5555
import java.time.ZoneOffset;
56-
import java.util.Arrays;
57-
import java.util.Calendar;
58-
import java.util.Date;
59-
import java.util.HashSet;
60-
import java.util.List;
61-
import java.util.Map;
62-
import java.util.Set;
56+
import java.util.*;
6357

6458
import static java.util.Collections.emptyList;
6559
import static org.testng.Assert.assertEquals;
@@ -71,6 +65,8 @@
7165

7266
public class OpenAPIDeserializerTest {
7367

68+
List<AuthorizationValue> auths = new ArrayList<>();
69+
7470
@Test
7571
public void testIssue1072() throws Exception {
7672
String yaml = "openapi: 3.0.0\n" +
@@ -2307,7 +2303,7 @@ public void testIssue360() {
23072303
}
23082304

23092305
@Test
2310-
public void testAllOfSchema(@Injectable List<AuthorizationValue> auths){
2306+
public void testAllOfSchema(){
23112307
String yaml = "openapi: '3.0'\n" +
23122308
"components:\n" +
23132309
" schemas:\n" +
@@ -2359,7 +2355,7 @@ public void testAllOfSchema(@Injectable List<AuthorizationValue> auths){
23592355
}
23602356

23612357
@Test
2362-
public void testOneOfSchema(@Injectable List<AuthorizationValue> auths){
2358+
public void testOneOfSchema(){
23632359
String yaml = "openapi: '3.0'\n" +
23642360
"components:\n" +
23652361
" schemas:\n" +
@@ -2420,7 +2416,7 @@ public void testOneOfSchema(@Injectable List<AuthorizationValue> auths){
24202416
}
24212417

24222418
@Test
2423-
public void testAnyOfSchema(@Injectable List<AuthorizationValue> auths){
2419+
public void testAnyOfSchema(){
24242420
String yaml = "openapi: '3.0'\n" +
24252421
"components:\n" +
24262422
" schemas:\n" +
@@ -2458,7 +2454,7 @@ public void testAnyOfSchema(@Injectable List<AuthorizationValue> auths){
24582454
}
24592455

24602456
@Test
2461-
public void propertyTest(@Injectable List<AuthorizationValue> auths){
2457+
public void propertyTest(){
24622458
String yaml = "openapi: 3.0.1\n"+
24632459
"paths:\n"+
24642460
" /primitiveBody/inline:\n" +
@@ -2497,7 +2493,7 @@ public void propertyTest(@Injectable List<AuthorizationValue> auths){
24972493
}
24982494

24992495
@Test
2500-
public void testExamples(@Injectable List<AuthorizationValue> auths){
2496+
public void testExamples(){
25012497
String yaml = "openapi: 3.0.1\n"+
25022498
"info:\n"+
25032499
" title: httpbin\n"+
@@ -2639,7 +2635,7 @@ public void testExamples(@Injectable List<AuthorizationValue> auths){
26392635

26402636

26412637
@Test
2642-
public void testSchemaExample(@Injectable List<AuthorizationValue> auths){
2638+
public void testSchemaExample(){
26432639
String yaml = "openapi: '3.0.1'\n" +
26442640
"components:\n" +
26452641
" schemas:\n"+
@@ -3073,7 +3069,7 @@ public void testIssue1454WithDefaultAllOfEnumWithDefaultValue(){
30733069
}
30743070

30753071
@Test
3076-
public void testOptionalParameter(@Injectable List<AuthorizationValue> auths) {
3072+
public void testOptionalParameter() {
30773073
String yaml = "openapi: 3.0.1\n" +
30783074
"paths:\n" +
30793075
" \"/pet\":\n" +
@@ -3108,7 +3104,7 @@ public void testOptionalParameter(@Injectable List<AuthorizationValue> auths) {
31083104
Assert.assertFalse(parameter.getRequired());
31093105
}
31103106

3111-
@Test void testDiscriminatorObject(@Injectable List<AuthorizationValue> auths){
3107+
@Test void testDiscriminatorObject(){
31123108
String yaml = "openapi: '3.0.1'\n" +
31133109
"components:\n" +
31143110
" schemas:\n" +
@@ -3165,7 +3161,7 @@ public void testOptionalParameter(@Injectable List<AuthorizationValue> auths) {
31653161
}
31663162

31673163
@Test
3168-
public void testEmpty(@Injectable List<AuthorizationValue> auths) {
3164+
public void testShouldReturnEmpty() {
31693165
String json = "{}";
31703166

31713167
OpenAPIV3Parser parser = new OpenAPIV3Parser();
@@ -3181,7 +3177,7 @@ public void testEmpty(@Injectable List<AuthorizationValue> auths) {
31813177
}
31823178

31833179
@Test
3184-
public void testAlmostEmpty(@Injectable List<AuthorizationValue> auths) {
3180+
public void testAlmostEmpty() {
31853181
String yaml = "openapi: '3.0.1'\n" +
31863182
"new: extra";
31873183

0 commit comments

Comments
 (0)