Skip to content

Commit 430eb1b

Browse files
committed
reduce failing test to 2
1 parent 65efdc7 commit 430eb1b

File tree

1 file changed

+40
-30
lines changed

1 file changed

+40
-30
lines changed

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

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@ public class SchemaProcessorTest {
2626
@Mocked
2727
ExternalRefProcessor externalRefProcessor;
2828

29-
3029
@Test
3130
public void testProcessRefSchema_ExternalRef() throws Exception {
3231

3332
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
3433
final String newRef = "bar";
3534

36-
expectCreationOfExternalRefProcessor();
37-
3835
new Expectations() {{
3936

4037
externalRefProcessor.processRefToExternalSchema(ref, RefFormat.URL);
@@ -54,8 +51,6 @@ public void testProcessRefSchema_ExternalRef() throws Exception {
5451
public void testProcessRefSchema_InternalRef() throws Exception {
5552
final String ref = "#/components/schemas/bar";
5653

57-
expectCreationOfExternalRefProcessor();
58-
5954
Schema refModel = new Schema().$ref(ref);
6055

6156
new SchemaProcessor(cache, openAPI).processSchema(refModel);
@@ -85,7 +80,6 @@ public void testProcessArraySchema() throws Exception {
8580

8681
@Test
8782
public void testProcessComposedSchema() throws Exception {
88-
expectCreationOfExternalRefProcessor();
8983

9084
final String ref1 = "http://my.company.com/path/to/file.json#/foo/bar";
9185
final String ref2 = "http://my.company.com/path/to/file.json#/this/that";
@@ -152,32 +146,38 @@ public void testProcessSchema() throws Exception {
152146

153147
@Test
154148
public void testProcessRefProperty_ExternalRef() throws Exception {
155-
expectCreationOfExternalRefProcessor();
149+
150+
final ExternalRefProcessor[] erp = {new ExternalRefProcessor(cache, openAPI)};
151+
new Expectations() {{
152+
erp[0] = new ExternalRefProcessor(cache, openAPI);
153+
times = 1;
154+
}};
156155

157156
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
158157
final Schema refProperty = new Schema().$ref(ref);
159158

160-
expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
159+
new Expectations() {{
160+
erp[0].processRefToExternalSchema(ref, RefFormat.URL );
161+
times = 1;
162+
result = "bar";
163+
}};
161164

162165
new SchemaProcessor(cache, openAPI).processSchema(refProperty);
163166

164167
new FullVerifications() {{
168+
erp[0].processRefToExternalSchema(ref, RefFormat.URL);
169+
times = 1;
165170
}};
166171

167172
assertEquals(refProperty.get$ref(), "#/components/schemas/bar");
168173
}
169174

170-
private void expectCallToExternalRefProcessor(final String ref, final RefFormat refFormat, final String newRef) {
175+
@Test
176+
public void testProcessRefProperty_InternalRef() throws Exception {
171177
new Expectations() {{
172-
externalRefProcessor.processRefToExternalSchema(ref, refFormat);
178+
new ExternalRefProcessor(cache, openAPI);
173179
times = 1;
174-
result = newRef;
175180
}};
176-
}
177-
178-
@Test
179-
public void testProcessRefProperty_InternalRef() throws Exception {
180-
expectCreationOfExternalRefProcessor();
181181

182182
final String expectedRef = "#/components/schemas/foo";
183183
final Schema property = new Schema().$ref(expectedRef);
@@ -191,18 +191,27 @@ public void testProcessRefProperty_InternalRef() throws Exception {
191191

192192
@Test
193193
public void testProcessArrayProperty_ItemsIsRefProperty() throws Exception {
194-
expectCreationOfExternalRefProcessor();
194+
final ExternalRefProcessor[] erp = {new ExternalRefProcessor(cache, openAPI)};
195+
new Expectations() {{
196+
erp[0] = new ExternalRefProcessor(cache, openAPI);
197+
times = 1;
198+
}};
195199
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
196200
final Schema refProperty = new Schema().$ref(ref);
197201

198202
ArraySchema arrayProperty = new ArraySchema();
199203
arrayProperty.setItems(refProperty);
200-
201-
expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
204+
new Expectations() {{
205+
erp[0].processRefToExternalSchema(ref, RefFormat.URL );
206+
times = 1;
207+
result = "bar";
208+
}};
202209

203210
new SchemaProcessor(cache, openAPI).processSchema(arrayProperty);
204211

205212
new FullVerifications() {{
213+
erp[0].processRefToExternalSchema(ref, RefFormat.URL);
214+
times = 1;
206215
}};
207216

208217
assertEquals((arrayProperty.getItems()).get$ref(), "#/components/schemas/bar");
@@ -211,28 +220,29 @@ public void testProcessArrayProperty_ItemsIsRefProperty() throws Exception {
211220

212221
@Test
213222
public void testProcessMapProperty_AdditionalPropertiesIsRefProperty() throws Exception {
214-
expectCreationOfExternalRefProcessor();
223+
final ExternalRefProcessor[] erp = {new ExternalRefProcessor(cache, openAPI)};
224+
new Expectations() {{
225+
erp[0] = new ExternalRefProcessor(cache, openAPI);
226+
times = 1;
227+
}};
215228
final String ref = "http://my.company.com/path/to/file.json#/foo/bar";
216229
final Schema refProperty = new Schema().$ref(ref);
217230

218-
219231
refProperty.setAdditionalProperties(refProperty);
220232

221-
expectCallToExternalRefProcessor(ref, RefFormat.URL, "bar");
233+
new Expectations() {{
234+
erp[0].processRefToExternalSchema(ref, RefFormat.URL );
235+
times = 1;
236+
result = "bar";
237+
}};
222238

223239
new SchemaProcessor(cache, openAPI).processSchema(refProperty);
224240

225241
new FullVerifications() {{
242+
erp[0].processRefToExternalSchema(ref, RefFormat.URL);
243+
times = 1;
226244
}};
227245

228246
assertEquals((((Schema)refProperty.getAdditionalProperties()).get$ref()), "#/components/schemas/bar");
229247
}
230-
231-
private void expectCreationOfExternalRefProcessor() {
232-
new Expectations() {{
233-
new ExternalRefProcessor(cache, openAPI);
234-
times = 1;
235-
result = externalRefProcessor;
236-
}};
237-
}
238248
}

0 commit comments

Comments
 (0)