Skip to content

Commit d2ca690

Browse files
committed
test compatibility fixing
1 parent 5c6b141 commit d2ca690

File tree

5 files changed

+429
-424
lines changed

5 files changed

+429
-424
lines changed

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

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
import mockit.*;
99
import org.testng.annotations.Test;
1010

11-
import java.util.Map;
1211

13-
import static org.testng.Assert.assertEquals;
1412

1513
public class ComponentsProcessorTest {
1614

@@ -42,82 +40,73 @@ public class ComponentsProcessorTest {
4240
@Mocked
4341
SecuritySchemeProcessor securitySchemeProcessor;
4442

43+
@Injectable
44+
Schema model1;
45+
46+
@Injectable
47+
Schema model2;
48+
49+
@Injectable
50+
ResolverCache cache;
51+
4552
@Injectable
4653
boolean openapi31;
4754

48-
@Test
49-
public void testComponentsSchemasProcessor(@Injectable final Schema model1,
50-
@Injectable final Schema model2,
51-
@Injectable final ResolverCache cache) throws Exception {
55+
@Injectable OpenAPI openAPI;
56+
57+
5258

59+
@Test
60+
public void testComponentsSchemasProcessor() throws Exception {
5361
final OpenAPI openAPI = new OpenAPI();
5462
openAPI.components(new Components().addSchemas("foo", model1));
5563
openAPI.getComponents().addSchemas("bar", model2);
5664

5765

58-
5966
new Expectations() {{
6067

61-
new SchemaProcessor(cache, openAPI, openapi31);
62-
times = 1;
63-
result = schemaProcessor;
64-
65-
6668
schemaProcessor.processSchema((Schema) any);
6769
times = 2;
6870
}};
6971

7072
new ComponentsProcessor(openAPI,cache, openapi31).processComponents();
7173

72-
73-
7474
new Verifications() {{
7575
schemaProcessor.processSchema(model1);
7676
schemaProcessor.processSchema(model2);
7777
}};
7878
}
7979

8080
@Test
81-
public void testNoComponentsDefined(@Injectable final OpenAPI openAPI,
82-
@Injectable final ResolverCache cache) throws Exception {
83-
81+
public void testNoComponentsDefined() throws Exception {
8482

8583
new Expectations() {{
8684
new SchemaProcessor(cache, openAPI, openapi31);
8785
times = 1;
88-
result = schemaProcessor;
8986

9087
new ResponseProcessor(cache, openAPI, openapi31);
9188
times = 1;
92-
result = responseProcessor;
9389

9490
new RequestBodyProcessor(cache, openAPI, openapi31);
9591
times = 1;
96-
result = requestBodyProcessor;
9792

9893
new ParameterProcessor( cache, openAPI, openapi31);
9994
times = 1;
100-
result = parameterProcessor;
10195

10296
new HeaderProcessor(cache, openAPI, openapi31);
10397
times = 1;
104-
result = headerProcessor;
10598

10699
new ExampleProcessor(cache, openAPI);
107100
times = 1;
108-
result = exampleProcessor;
109101

110102
new LinkProcessor(cache, openAPI, openapi31);
111103
times = 1;
112-
result = linkProcessor;
113104

114105
new CallbackProcessor(cache, openAPI, openapi31);
115106
times = 1;
116-
result = callbackProcessor;
117107

118108
new SecuritySchemeProcessor(cache, openAPI);
119109
times = 1;
120-
result = securitySchemeProcessor;
121110

122111
openAPI.getComponents();
123112
times = 1;

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ public class ExternalRefProcessorTest {
3434
@Injectable
3535
OpenAPI openAPI;
3636

37+
@Injectable Schema mockedModel;
38+
3739
@Test
38-
public void testProcessRefToExternalDefinition_NoNameConflict(
39-
@Injectable final Schema mockedModel) throws Exception {
40+
public void testProcessRefToExternalDefinition_NoNameConflict() throws Exception {
4041

4142
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
4243
final RefFormat refFormat = RefFormat.URL;
@@ -73,7 +74,7 @@ public void testProcessRefToExternalDefinition_NoNameConflict(
7374

7475

7576
@Test
76-
public void testNestedExternalRefs(@Injectable final Schema mockedModel){
77+
public void testNestedExternalRefs(){
7778
final RefFormat refFormat = RefFormat.URL;
7879

7980
//Swagger test instance
@@ -150,7 +151,7 @@ public void testNestedExternalRefs(@Injectable final Schema mockedModel){
150151

151152

152153
@Test
153-
public void testRelativeRefIncludingUrlRef(@Injectable final Schema mockedModel)
154+
public void testRelativeRefIncludingUrlRef()
154155
throws Exception {
155156
final RefFormat refFormat = RefFormat.RELATIVE;
156157

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

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,26 @@ public class ParameterProcessorTest {
3838
@Injectable
3939
boolean openapi31;
4040

41+
@Injectable
42+
HeaderParameter headerParameter;
43+
44+
@Injectable
45+
QueryParameter queryParameter;
46+
47+
@Injectable
48+
CookieParameter cookieParameter;
49+
50+
@Injectable
51+
PathParameter pathParameter;
52+
53+
@Injectable
54+
HeaderParameter resolvedHeaderParam;
55+
56+
@Injectable
57+
Schema bodyParamSchema;
58+
4159
@Test
42-
public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final HeaderParameter headerParameter,
43-
@Injectable final QueryParameter queryParameter,
44-
@Injectable final CookieParameter cookieParameter,
45-
@Injectable final PathParameter pathParameter) throws Exception {
60+
public void testProcessParameters_TypesThatAreNotRefOrBody() throws Exception {
4661
expectedModelProcessorCreation();
4762
new Expectations() {
4863
{
@@ -89,7 +104,7 @@ public void testProcessParameters_TypesThatAreNotRefOrBody(@Injectable final Hea
89104
}
90105

91106
@Test
92-
public void testProcessParameters_RefToHeader(@Injectable final HeaderParameter resolvedHeaderParam) throws Exception {
107+
public void testProcessParameters_RefToHeader() throws Exception {
93108
expectedModelProcessorCreation();
94109

95110
final String ref = "#/components/parameters/foo";
@@ -122,30 +137,21 @@ private void expectLoadingRefFromCache(final String ref, final RefFormat refForm
122137
}};
123138
}
124139

125-
private void expectLoadingRefFromCache(final String ref, final RefFormat refFormat,
126-
final RequestBody resolvedParam) {
127-
new Expectations() {{
128-
/*cache.loadRef(ref, refFormat, RequestBody.class);
129-
times = 1;
130-
result = resolvedParam;*/
131-
}};
132-
}
133-
134140
@Test
135-
public void testProcessParameters_BodyParameter(@Injectable final Schema bodyParamSchema) throws Exception {
141+
public void testProcessParameters_BodyParameter() throws Exception {
136142

137143
expectedModelProcessorCreation();
138144

139145
RequestBody bodyParameter = new RequestBody().content(new Content().addMediaType("*/*",new MediaType().schema(bodyParamSchema)));
140146

141-
expectModelProcessorInvoked(bodyParamSchema);
147+
expectModelProcessorInvoked(bodyParamSchema);
142148

143149
new RequestBodyProcessor(cache, openAPI, openapi31).processRequestBody(bodyParameter);
144150

145151
new FullVerifications(){{}};
146152
}
147153

148-
private void expectModelProcessorInvoked(@Injectable final Schema bodyParamSchema) {
154+
private void expectModelProcessorInvoked(Schema bodyParamSchema) {
149155
new Expectations(){{
150156
modelProcessor.processSchema(bodyParamSchema); times=1;
151157
}};
@@ -156,7 +162,6 @@ private void expectedModelProcessorCreation() {
156162
new Expectations() {{
157163
new SchemaProcessor(cache, openAPI, openapi31);
158164
times = 1;
159-
result = modelProcessor;
160165
}};
161166
}
162167
}

0 commit comments

Comments
 (0)