Skip to content

Commit 2ef3200

Browse files
committed
simpler test setup
1 parent 621c37e commit 2ef3200

15 files changed

Lines changed: 81 additions & 123 deletions

File tree

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

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,5 @@ class CompileExpectedSpec: StringSpec({
3737
})
3838

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

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

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,6 @@ class ProcessorEndToEndJimfsSpec: StringSpec({
3636
private fun sources(): Collection<TestSet> {
3737
// the swagger parser does not work with a custom FileSystem
3838

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

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

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,5 @@ 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()
6137
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ package io.openapiprocessor.micronaut
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
12-
import io.openapiprocessor.core.parser.ParserType.SWAGGER
1311
import io.openapiprocessor.test.*
1412

1513
/**
@@ -34,8 +32,6 @@ class ProcessorPendingSpec: StringSpec({
3432

3533
private fun sources(): Collection<TestSet> {
3634
return listOf(
37-
testSet("params-path-simple-data-types", SWAGGER, API_30, model = "default", outputs = "outputs.yaml", expected = "outputs"),
38-
// testSet("bean-validation-introspected", INTERNAL, API_30, model = "default", outputs = "outputs.yaml", expected = "outputs"),
39-
// testSet("bean-validation-introspected", INTERNAL, API_31, model = "default", outputs = "outputs.yaml", expected = "outputs")
35+
testSet("params-path-simple-data-types", "SWAGGER", API_30),
4036
)
4137
}

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

Lines changed: 67 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,73 @@
55

66
package io.openapiprocessor.micronaut
77

8-
import io.openapiprocessor.test.*
9-
import io.openapiprocessor.test.test30_D_
8+
import io.openapiprocessor.micronaut.processor.MicronautServiceV2
9+
import io.openapiprocessor.test.TestParams2
10+
import io.openapiprocessor.test.TestSet
11+
import io.openapiprocessor.test.join
12+
import io.openapiprocessor.test.testX
13+
import io.openapiprocessor.test.tests
1014

11-
val ALL_30: List<TestParams> = listOf(
12-
test30_DR("bean-validation-introspected"),
13-
test30_D_("endpoint-http-mapping"),
14-
test30_DR("params-complex-data-types"),
15-
test30_D_("params-pageable-mapping"),
16-
test30_D_("params-path-simple-data-types"),
17-
test30_DR("params-request-body"),
18-
test30_DR("params-request-body-multipart-mapping"),
19-
test30_D_("params-simple-data-types"),
20-
test30_D_("response-status")
15+
val ALL_3x: List<TestParams2> = join(
16+
emptyList(),
17+
tests("bean-validation-introspected"),
18+
testX("endpoint-http-mapping"),
19+
tests("params-complex-data-types"),
20+
testX("params-pageable-mapping"),
21+
testX("params-path-simple-data-types"),
22+
tests("params-request-body"),
23+
tests("params-request-body-multipart-mapping"),
24+
testX("params-simple-data-types"),
25+
testX("response-status")
2126
)
2227

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

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

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
items:
22
- inputs/openapi30.yaml
33
- inputs/openapi31.yaml
4+
- inputs/openapi32.yaml
45
- inputs/mapping.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
items:
22
- inputs/openapi30.yaml
33
- inputs/openapi31.yaml
4+
- inputs/openapi32.yaml
45
- inputs/mapping.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
items:
22
- inputs/openapi30.yaml
33
- inputs/openapi31.yaml
4+
- inputs/openapi32.yaml
45
- inputs/mapping.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
items:
22
- inputs/openapi30.yaml
33
- inputs/openapi31.yaml
4+
- inputs/openapi32.yaml
45
- inputs/mapping.yaml

0 commit comments

Comments
 (0)