Skip to content

Commit 17e7b2a

Browse files
committed
simpler integration test setup
1 parent 2e67981 commit 17e7b2a

File tree

6 files changed

+34
-261
lines changed

6 files changed

+34
-261
lines changed

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/CompileExpectedSpec.kt

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ package io.openapiprocessor.core
88
import io.kotest.core.spec.style.StringSpec
99
import io.kotest.engine.spec.tempdir
1010
import io.kotest.matchers.booleans.shouldBeTrue
11-
import io.openapiprocessor.core.parser.ParserType
12-
import io.openapiprocessor.test.*
11+
import io.openapiprocessor.test.ResourceReader
12+
import io.openapiprocessor.test.TestFilesNative
13+
import io.openapiprocessor.test.TestSet
14+
import io.openapiprocessor.test.TestSetCompiler
1315

1416

1517
class CompileExpectedSpec: StringSpec({
@@ -34,21 +36,5 @@ class CompileExpectedSpec: StringSpec({
3436
})
3537

3638
private fun sources(): Collection<TestSet> {
37-
val compile30 = ALL_30.map {
38-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
39-
}
40-
41-
val compile31 = ALL_31.map {
42-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
43-
}
44-
45-
val compile30r = ALL_30.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
46-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
47-
}
48-
49-
val compile31r = ALL_31.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
50-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
51-
}
52-
53-
return compile30 + compile31 + compile30r + compile31r
39+
return buildTestSets()
5440
}

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/ProcessorEndToEndJimfsSpec.kt

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import com.google.common.jimfs.Configuration
99
import com.google.common.jimfs.Jimfs
1010
import io.kotest.core.spec.style.StringSpec
1111
import io.kotest.matchers.booleans.shouldBeTrue
12-
import io.openapiprocessor.core.parser.ParserType
1312
import io.openapiprocessor.test.*
1413

1514
/**
@@ -34,22 +33,7 @@ class ProcessorEndToEndJimfsSpec: StringSpec({
3433
})
3534

3635
private fun sources(): Collection<TestSet> {
37-
38-
// the swagger parser does not work with a custom FileSystem
39-
40-
val openapi4j = ALL_30
41-
.filter { !EXCLUDE_OPENAPI4J.contains(it.name) }
42-
.map {
43-
testSet(it.name, ParserType.OPENAPI4J, it.openapi, outputs = it.outputs, expected = it.expected)
44-
}
45-
46-
val openapi30 = ALL_30.map {
47-
testSet(it.name, ParserType.INTERNAL, it.openapi, outputs = it.outputs, expected = it.expected)
48-
}
49-
50-
val openapi31 = ALL_31.map {
51-
testSet(it.name, ParserType.INTERNAL, it.openapi, outputs = it.outputs, expected = it.expected)
52-
}
53-
54-
return openapi4j + openapi30 + openapi31
36+
return buildTestSets()
37+
// swagger does not work with a custom FileSystem
38+
.filter { it.parser != "SWAGGER" }
5539
}

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/ProcessorEndToEndSpec.kt

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,24 +31,5 @@ class ProcessorEndToEndSpec: StringSpec({
3131
})
3232

3333
private fun sources(): Collection<TestSet> {
34-
return ALL_3x
35-
.filter {
36-
when (it.parser) {
37-
"INTERNAL" -> {
38-
true
39-
}
40-
"SWAGGER" if it.openapi == "openapi30.yaml" -> {
41-
!EXCLUDE_SWAGGER.contains(it.name)
42-
}
43-
"OPENAPI4J" if it.openapi == "openapi30.yaml" -> {
44-
!EXCLUDE_OPENAPI4J.contains(it.name)
45-
}
46-
else -> {
47-
false
48-
}
49-
}
50-
}
51-
.map {
52-
testSet(it.name, it.parser, it.openapi, model = it.modelType, outputs = it.outputs, expected = it.expected)
53-
}
34+
return buildTestSets()
5435
}

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/ProcessorPendingSpec.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class ProcessorPendingSpec: StringSpec({
4848

4949
private fun sources(): Collection<TestSet> {
5050
return listOf(
51-
testSet("packages", INTERNAL, "api/$API_30", model = "model", outputs = "outputs.yaml", expected = "outputs"),
52-
testSet("packages", INTERNAL, "api/$API_30", model = "record", outputs = "outputs.yaml", expected = "outputs"),
51+
testSet("packages", "INTERNAL", "api/$API_30", model = "model"),
52+
testSet("packages", "INTERNAL", "api/$API_30", model = "record"),
5353
)
5454
}

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/ProcessorTestSets.kt

Lines changed: 0 additions & 176 deletions
Original file line numberDiff line numberDiff line change
@@ -119,182 +119,6 @@ val ALL_3x: List<TestParams2> = join(
119119
tests("swagger-parsing-error")
120120
).sortedWith(testParamComparator)
121121

122-
@Deprecated(message = "merged into ALL_3x")
123-
val ALL_30: List<TestParams> = listOf(
124-
test30_DR("annotation-mapping-class"),
125-
test30_DR("bean-validation"),
126-
test30_DR("bean-validation-allof-required"),
127-
test30_DR("bean-validation-iterable"),
128-
test30_DR("bean-validation-jakarta"),
129-
test30_D_("bean-validation-list-item-import"),
130-
test30_D_("bean-validation-mapping-supported"),
131-
test30_D_("bean-validation-requestbody"),
132-
test30_D_("bean-validation-requestbody-mapping"),
133-
test30_DR("components-requestbodies"),
134-
test30_DR("deprecated"),
135-
test30_D_("endpoint-exclude"),
136-
test30_D_("endpoint-http-mapping"), // framework specific
137-
test30_DR("extension-mapping"),
138-
test30_DR("format-eclipse"),
139-
test30_DR("generated"),
140-
test30_DR("javadoc"),
141-
test30_DR("javadoc-with-mapping"),
142-
test30_DR("json-input", "openapi30.json"),
143-
test30_DR("keyword-identifier"),
144-
test30_D_("map-from-additional-properties"),
145-
test30_DR("map-from-additional-properties-with-package-name"),
146-
test30_DR("map-many"),
147-
test30_DR("map-to-primitive-data-types"),
148-
test30_D_("method-operation-id"),
149-
test30_DR("model-name-suffix"),
150-
test30_DR("model-name-suffix-with-package-name"),
151-
test30_D_("object-empty"),
152-
test30_DR("object-nullable-properties"),
153-
test30_DR("object-read-write-properties"),
154-
test30_DR("object-without-properties"),
155-
test30_DR(name = "packages", openapi = "api/$API_30"),
156-
test30_D_("params-additional"),
157-
test30_D_("params-additional-global"),
158-
test30_DR("params-complex-data-types"), // framework specific
159-
test30_D_("params-endpoint"),
160-
test30_D_("params-enum"),
161-
test30_D_("params-enum-string"),
162-
test30_D_("params-path-simple-data-types"), // framework specific
163-
test30_DR("params-request-body"), // framework specific
164-
test30_D_("params-request-body-multipart-form-data"), // framework specific
165-
test30_D_("params-simple-data-types"), // framework specific
166-
test30_D_("params-unnecessary"),
167-
test30_DR("ref-array-items-nested"),
168-
test30_DR("ref-chain-spring-124.1"),
169-
test30_DR("ref-chain-spring-124.2"),
170-
test30_DR("ref-into-another-file"),
171-
test30_DR("ref-into-another-file-path"),
172-
test30_DR("ref-is-relative-to-current-file"),
173-
test30_DR("ref-loop"),
174-
test30_DR("ref-loop-array"),
175-
test30_D_("ref-parameter"),
176-
test30_D_("ref-parameter-with-primitive-mapping"),
177-
test30_DR("ref-response"),
178-
test30_DR("ref-to-escaped-path-name"),
179-
test30_D_("response-array-data-type-mapping"),
180-
test30_DR("response-complex-data-types"),
181-
test30_DR("response-content-multiple-no-content"),
182-
test30_DR("response-content-multiple-style-all"),
183-
test30_DR("response-content-multiple-style-success"),
184-
test30_D_("response-content-single"),
185-
test30_DR("response-multi-mapping-with-array-type-mapping"),
186-
test30_D_("response-reactive-mapping"),
187-
test30_D_("response-reactive-result-mapping"),
188-
test30_DR("response-ref-class-name"),
189-
test30_D_("response-result-mapping"),
190-
test30_DR("response-result-multiple"),
191-
test30_DR("response-result-multiple-object"),
192-
test30_D_("response-result-reactive-mapping"),
193-
test30_D_("response-simple-data-types"),
194-
test30_DR("response-single-multi-mapping"),
195-
test30_D_("response-status"),
196-
test30_DR("schema-composed"),
197-
test30_DR("schema-composed-allof"),
198-
test30_DR("schema-composed-allof-notype"),
199-
test30_DR("schema-composed-allof-properties"),
200-
test30_DR("schema-composed-allof-ref-sibling"),
201-
test30_DR("schema-composed-nested"),
202-
test30_DR("schema-composed-oneof-interface"),
203-
//test30_DR("schema-duplicate-by-refs"), // not supported
204-
test30_DR("schema-mapping"),
205-
test30_DR("schema-unreferenced"),
206-
test30_DR("server-url"),
207-
test30_DR("swagger-parsing-error")
208-
)
209-
210-
@Deprecated(message = "merged into ALL_3x")
211-
val ALL_31: List<TestParams> = listOf(
212-
test31_DR("annotation-mapping-class"),
213-
test31_DR("bean-validation"),
214-
test31_DR("bean-validation-allof-required"),
215-
test31_DR("bean-validation-iterable"),
216-
test31_DR("bean-validation-jakarta"),
217-
test31_D_("bean-validation-list-item-import"),
218-
test31_D_("bean-validation-mapping-supported"),
219-
test31_D_("bean-validation-requestbody"),
220-
test31_D_("bean-validation-requestbody-mapping"),
221-
test31_DR("components-requestbodies"),
222-
test31_DR("extension-mapping"),
223-
test31_DR("format-eclipse"),
224-
test31_DR("deprecated"),
225-
test31_D_("endpoint-exclude"),
226-
test31_D_("endpoint-http-mapping"), // framework specific
227-
test31_DR("generated"),
228-
test31_DR("javadoc"),
229-
test31_DR("javadoc-with-mapping"),
230-
test31_DR("json-input", "openapi31.json"),
231-
test31_DR("keyword-identifier"),
232-
test31_D_("map-from-additional-properties"),
233-
test31_DR("map-from-additional-properties-with-package-name"),
234-
test31_DR("map-many"),
235-
test31_DR("map-to-primitive-data-types"),
236-
test31_D_("method-operation-id"),
237-
test31_DR("model-name-suffix"),
238-
test31_DR("model-name-suffix-with-package-name"),
239-
test31_D_("object-empty"),
240-
test31_DR("object-nullable-properties"),
241-
test31_DR("object-read-write-properties"),
242-
test31_DR("object-without-properties"),
243-
test31_DR(name = "packages", openapi = "api/$API_31"),
244-
test31_D_("params-additional"),
245-
test31_D_("params-additional-global"),
246-
test31_DR("params-complex-data-types"), // framework specific
247-
test31_D_("params-endpoint"),
248-
test31_D_("params-enum"),
249-
test31_D_("params-enum-string"),
250-
test31_D_("params-path-simple-data-types"), // framework specific
251-
test31_DR("params-request-body"), // framework specific
252-
test31_D_("params-request-body-multipart-form-data"), // framework specific
253-
test31_D_("params-simple-data-types"), // framework specific
254-
test31_D_("params-unnecessary"),
255-
test31_DR("ref-array-items-nested"),
256-
test31_DR("ref-chain-spring-124.1"),
257-
test31_DR("ref-chain-spring-124.2"),
258-
test31_DR("ref-into-another-file"),
259-
test31_DR("ref-into-another-file-path"),
260-
test31_DR("ref-is-relative-to-current-file"),
261-
test31_DR("ref-loop"),
262-
test31_DR("ref-loop-array"),
263-
test31_D_("ref-parameter"),
264-
test31_D_("ref-parameter-with-primitive-mapping"),
265-
test31_DR("ref-response"),
266-
test31_DR("ref-to-escaped-path-name"),
267-
test31_D_("response-array-data-type-mapping"),
268-
test31_DR("response-complex-data-types"),
269-
test31_DR("response-content-multiple-no-content"),
270-
test31_DR("response-content-multiple-style-all"),
271-
test31_DR("response-content-multiple-style-success"),
272-
test31_D_("response-content-single"),
273-
test31_DR("response-multi-mapping-with-array-type-mapping"),
274-
test31_D_("response-reactive-mapping"),
275-
test31_D_("response-reactive-result-mapping"),
276-
test31_DR("response-ref-class-name"),
277-
test31_D_("response-result-mapping"),
278-
test31_DR("response-result-multiple"),
279-
test31_DR("response-result-multiple-object"),
280-
test31_D_("response-result-reactive-mapping"),
281-
test31_D_("response-simple-data-types"),
282-
test31_DR("response-single-multi-mapping"),
283-
test31_D_("response-status"),
284-
test31_DR("schema-composed"),
285-
test31_DR("schema-composed-allof"),
286-
test31_DR("schema-composed-allof-notype"),
287-
test31_DR("schema-composed-allof-properties"),
288-
test31_DR("schema-composed-allof-ref-sibling"),
289-
test31_DR("schema-composed-nested"),
290-
test31_DR("schema-composed-oneof-interface"),
291-
//test31_DR("schema-duplicate-by-refs"), // not supported
292-
test31_DR("schema-mapping"),
293-
test31_DR("schema-unreferenced"),
294-
test31_DR("server-url"),
295-
test31_DR("swagger-parsing-error")
296-
)
297-
298122
val EXCLUDE_OPENAPI4J = setOf(
299123
// the parser assumes that "type" must be string if a non-standard format is used
300124
"schema-mapping",

openapi-processor-core/src/testInt/kotlin/io/openapiprocessor/core/ProcessorTestSetsSupport.kt

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,8 @@
55

66
package io.openapiprocessor.core
77

8-
import io.openapiprocessor.core.parser.ParserType
98
import io.openapiprocessor.test.TestSet
109

11-
@Deprecated(message = "use other overload")
12-
//@Suppress("SameParameterValue")
13-
fun testSet(
14-
name: String,
15-
parser: ParserType,
16-
openapi: String = "openapi.yaml",
17-
model: String = "default",
18-
inputs: String = "inputs.yaml",
19-
outputs: String = "generated.yaml",
20-
expected: String = "generated"
21-
): TestSet {
22-
val testSet = TestSet()
23-
testSet.name = name
24-
testSet.processor = TestProcessor()
25-
testSet.parser = parser.name
26-
testSet.modelType = model
27-
testSet.openapi = openapi
28-
testSet.inputs = inputs
29-
testSet.outputs = outputs
30-
testSet.expected = expected
31-
return testSet
32-
}
33-
34-
//@Suppress("SameParameterValue")
3510
fun testSet(
3611
name: String,
3712
parser: String = "INTERNAL",
@@ -52,3 +27,26 @@ fun testSet(
5227
testSet.expected = expected
5328
return testSet
5429
}
30+
31+
fun buildTestSets(): List<TestSet> {
32+
return ALL_3x
33+
.filter {
34+
when (it.parser) {
35+
"INTERNAL" -> {
36+
true
37+
}
38+
"SWAGGER" if it.openapi == "openapi30.yaml" -> {
39+
!EXCLUDE_SWAGGER.contains(it.name)
40+
}
41+
"OPENAPI4J" if it.openapi == "openapi30.yaml" -> {
42+
!EXCLUDE_OPENAPI4J.contains(it.name)
43+
}
44+
else -> {
45+
false
46+
}
47+
}
48+
}
49+
.map {
50+
testSet(it.name, it.parser, it.openapi, model = it.modelType, outputs = it.outputs, expected = it.expected)
51+
}
52+
}

0 commit comments

Comments
 (0)