@@ -36,8 +36,6 @@ public class ResolverCacheTest {
36
36
@ Mocked
37
37
RefUtils refUtils ;
38
38
39
- @ Mocked
40
- DeserializationUtils deserializationUtils ;
41
39
42
40
@ Injectable
43
41
OpenAPI openAPI ;
@@ -50,7 +48,7 @@ public void testMock(@Injectable final Schema expectedResult) throws Exception {
50
48
final String ref = "http://my.company.com/path/to/file.json" ;
51
49
final String contentsOfExternalFile = "really good json" ;
52
50
53
- new Expectations () {{
51
+ new Expectations (DeserializationUtils . class ) {{
54
52
RefUtils .readExternalUrlRef (ref , format , auths , "http://my.company.com/path/parent.json" );
55
53
times = 1 ;
56
54
result = contentsOfExternalFile ;
@@ -75,7 +73,7 @@ public void testLoadExternalRef_NoDefinitionPath(@Injectable final Schema expect
75
73
final String ref = "http://my.company.com/path/to/file.json" ;
76
74
final String contentsOfExternalFile = "really good json" ;
77
75
78
- new Expectations () {{
76
+ new Expectations (DeserializationUtils . class ) {{
79
77
RefUtils .readExternalUrlRef (ref , format , auths , "http://my.company.com/path/parent.json" );
80
78
times = 1 ;
81
79
result = contentsOfExternalFile ;
@@ -128,6 +126,35 @@ public void testLoadExternalRefWithEscapedCharacters() throws Exception {
128
126
assertNotNull (path );
129
127
}
130
128
129
+ @ Test
130
+ public void testLoadExternalRefResponseWithNoContent () throws Exception {
131
+ final RefFormat format = RefFormat .URL ;
132
+ final String ref = "http://my.company.com/path/to/main.yaml" ;
133
+ final String contentsOfExternalFile = "openapi: 3.0.0\n " +
134
+ "\n " +
135
+ "info:\n " +
136
+ " version: 1.0.0\n " +
137
+ " title: Response include test case child\n " +
138
+ "\n " +
139
+ "components:\n " +
140
+ " responses:\n " +
141
+ " 200:\n " +
142
+ " description: Success\n " ;
143
+
144
+ new Expectations () {{
145
+ RefUtils .readExternalUrlRef (ref , format , auths , "http://my.company.com/path/parent.json" );
146
+ times = 1 ;
147
+ result = contentsOfExternalFile ;
148
+ }};
149
+
150
+ ResolverCache cache = new ResolverCache (openAPI , auths , "http://my.company.com/path/parent.json" );
151
+
152
+ ApiResponse response = cache .loadRef (ref +"#/components/responses/200" , RefFormat .URL , ApiResponse .class );
153
+ assertNotNull (response );
154
+ assertEquals (response .getDescription (), "Success" );
155
+ assertNull (response .getContent ());
156
+ }
157
+
131
158
@ Test
132
159
public void testLoadInternalParameterRef (@ Injectable Parameter mockedParameter ) throws Exception {
133
160
OpenAPI openAPI = new OpenAPI ();
0 commit comments