Skip to content

Commit 67b89fe

Browse files
committed
simpler test setup
1 parent 6a584ee commit 67b89fe

6 files changed

Lines changed: 120 additions & 131 deletions

File tree

src/testInt/kotlin/io/openapiprocessor/spring/CompileExpectedSpec.kt

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ package io.openapiprocessor.spring
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.*
13-
import kotlin.collections.filter
14-
import kotlin.collections.map
15-
import kotlin.collections.plus
11+
import io.openapiprocessor.test.ResourceReader
12+
import io.openapiprocessor.test.TestFilesNative
13+
import io.openapiprocessor.test.TestSet
14+
import io.openapiprocessor.test.TestSetCompiler
1615

1716

1817
class CompileExpectedSpec: StringSpec({
@@ -34,21 +33,5 @@ class CompileExpectedSpec: StringSpec({
3433
})
3534

3635
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
36+
return buildTestSets()
5437
}

src/testInt/kotlin/io/openapiprocessor/spring/ProcessorEndToEndJimfsSpec.kt

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ 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.*
14-
import io.openapiprocessor.test.TestSet
1513

1614
/**
1715
* runs integration tests with Jimfs.
@@ -37,25 +35,29 @@ class ProcessorEndToEndJimfsSpec: StringSpec({
3735
private fun sources(): Collection<TestSet> {
3836
// the swagger parser does not work with a custom FileSystem
3937

40-
val openapi4j = ALL_30.map {
41-
testSet(it.name, ParserType.OPENAPI4J, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
42-
}
43-
44-
val openapi30 = ALL_30.map {
45-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
46-
}
47-
48-
val openapi31 = ALL_31.map {
49-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
50-
}
51-
52-
val openapi30r = ALL_30.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
53-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
54-
}
55-
56-
val openapi31r = ALL_31.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
57-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
58-
}
59-
60-
return openapi4j + openapi30 + openapi31 + openapi30r + openapi31r
38+
return buildTestSets()
39+
.filter { it.parser != "SWAGGER" }
40+
41+
42+
// val openapi4j = ALL_30.map {
43+
// testSet(it.name, ParserType.OPENAPI4J, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
44+
// }
45+
//
46+
// val openapi30 = ALL_30.map {
47+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
48+
// }
49+
//
50+
// val openapi31 = ALL_31.map {
51+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
52+
// }
53+
//
54+
// val openapi30r = ALL_30.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
55+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
56+
// }
57+
//
58+
// val openapi31r = ALL_31.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
59+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
60+
// }
61+
//
62+
// return openapi4j + openapi30 + openapi31 + openapi30r + openapi31r
6163
}

src/testInt/kotlin/io/openapiprocessor/spring/ProcessorEndToEndSpec.kt

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,30 @@ class ProcessorEndToEndSpec: StringSpec({
3333
})
3434

3535
private fun sources(): Collection<TestSet> {
36-
val swagger = ALL_30.map {
37-
testSet(it.name, ParserType.SWAGGER, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
38-
}
39-
40-
val openapi4j = ALL_30.map {
41-
testSet(it.name, ParserType.OPENAPI4J, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
42-
}
43-
44-
val openapi30 = ALL_30.map {
45-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
46-
}
47-
48-
val openapi31 = ALL_31.map {
49-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
50-
}
51-
52-
val openapi30r = ALL_30.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
53-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
54-
}
55-
56-
val openapi31r = ALL_31.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
57-
testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
58-
}
59-
60-
return swagger + openapi4j + openapi30 + openapi31 + openapi30r + openapi31r
36+
return buildTestSets()
37+
// val swagger = ALL_30.map {
38+
// testSet(it.name, ParserType.SWAGGER, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
39+
// }
40+
//
41+
// val openapi4j = ALL_30.map {
42+
// testSet(it.name, ParserType.OPENAPI4J, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
43+
// }
44+
//
45+
// val openapi30 = ALL_30.map {
46+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
47+
// }
48+
//
49+
// val openapi31 = ALL_31.map {
50+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "default", outputs = it.outputs, expected = it.expected)
51+
// }
52+
//
53+
// val openapi30r = ALL_30.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
54+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
55+
// }
56+
//
57+
// val openapi31r = ALL_31.filter { it.modelTypes.contains(ModelTypes.RECORD) }.map {
58+
// testSet(it.name, ParserType.INTERNAL, it.openapi, model = "record", outputs = it.outputs, expected = it.expected)
59+
// }
60+
//
61+
// return swagger + openapi4j + openapi30 + openapi31 + openapi30r + openapi31r
6162
}

src/testInt/kotlin/io/openapiprocessor/spring/ProcessorPendingSpec.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ package io.openapiprocessor.spring
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.INTERNAL
1211
import io.openapiprocessor.test.*
13-
import io.openapiprocessor.test.API_30
14-
import io.openapiprocessor.test.TestSet
1512

1613
/**
1714
* helper to run selected integration tests.
@@ -35,8 +32,6 @@ class ProcessorPendingSpec: StringSpec({
3532

3633
private fun sources(): Collection<TestSet> {
3734
return listOf(
38-
testSet("params-enum", INTERNAL, API_30, model = "default", outputs = "outputs.yaml", expected = "outputs"),
39-
// testSet("params-request-body-multipart-mapping", INTERNAL, API_30, model = "default", outputs = "outputs.yaml", expected = "outputs"),
40-
// testSet("params-request-body-multipart-mapping", INTERNAL, API_31, model = "default", outputs = "outputs.yaml", expected = "outputs")
35+
testSet("params-enum", "INTERNAL", API_30),
4136
)
4237
}

src/testInt/kotlin/io/openapiprocessor/spring/ProcessorTestSets.kt

Lines changed: 63 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,70 @@
55

66
package io.openapiprocessor.spring
77

8+
import io.openapiprocessor.spring.processor.SpringServiceV2
89
import io.openapiprocessor.test.*
910

10-
val ALL_30: List<TestParams> = listOf(
11-
test30_D_("endpoint-http-mapping"),
12-
test30_DR("params-complex-data-types"),
13-
test30_D_("params-enum"),
14-
test30_D_("params-pageable-mapping"),
15-
test30_D_("params-path-simple-data-types"),
16-
test30_D_("params-query-annotate-simple-mapping"),
17-
test30_DR("params-request-body"),
18-
test30_D_("params-request-body-multipart-mapping"),
19-
test30_D_("params-simple-data-types"),
20-
test30_D_("response-status")
11+
val ALL_3x: List<TestParams2> = join(
12+
emptyList(),
13+
testX("endpoint-http-mapping"),
14+
tests("params-complex-data-types"),
15+
testX("params-enum"),
16+
testX("params-pageable-mapping"),
17+
testX("params-path-simple-data-types"),
18+
testX("params-query-annotate-simple-mapping"),
19+
tests("params-request-body"),
20+
testX("params-request-body-multipart-mapping"),
21+
testX("params-simple-data-types"),
22+
testX("response-status")
2123
)
2224

23-
val ALL_31: List<TestParams> = listOf(
24-
test31_D_("endpoint-http-mapping"),
25-
test31_DR("params-complex-data-types"),
26-
test31_D_("params-enum"),
27-
test31_D_("params-pageable-mapping"),
28-
test31_D_("params-path-simple-data-types"),
29-
test31_D_("params-query-annotate-simple-mapping"),
30-
test31_DR("params-request-body"),
31-
test31_DR("params-request-body-multipart-mapping"),
32-
test31_D_("params-simple-data-types"),
33-
test31_D_("response-status")
34-
)
25+
fun testSet(
26+
name: String,
27+
parser: String = "INTERNAL",
28+
openapi: String = "openapi.yaml",
29+
model: String = "default",
30+
inputs: String = "inputs.yaml",
31+
outputs: String = "outputs.yaml",
32+
expected: String = "outputs"
33+
): TestSet {
34+
val testSet = TestSet()
35+
testSet.name = name
36+
testSet.processor = SpringServiceV2(testMode = true)
37+
testSet.parser = parser
38+
testSet.modelType = model
39+
testSet.openapi = openapi
40+
testSet.inputs = inputs
41+
testSet.outputs = outputs
42+
testSet.expected = expected
43+
return testSet
44+
}
45+
46+
fun buildTestSets(): List<TestSet> {
47+
return ALL_3x
48+
.filter {
49+
when (it.parser) {
50+
"INTERNAL" -> {
51+
true
52+
}
53+
"SWAGGER" if it.openapi == "openapi30.yaml" -> {
54+
true
55+
}
56+
"OPENAPI4J" if it.openapi == "openapi30.yaml" -> {
57+
true
58+
}
59+
else -> {
60+
false
61+
}
62+
}
63+
}
64+
.map {
65+
testSet(
66+
it.name,
67+
it.parser,
68+
it.openapi,
69+
model = it.modelType,
70+
outputs = it.outputs,
71+
expected = it.expected
72+
)
73+
}
74+
}

src/testInt/kotlin/io/openapiprocessor/spring/ProcessorTestSetsSupport.kt

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)