Skip to content

Commit 5f87969

Browse files
committed
improve homes
1 parent 17e7b2a commit 5f87969

File tree

3 files changed

+72
-77
lines changed

3 files changed

+72
-77
lines changed

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

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,6 @@ package io.openapiprocessor.core
88
import io.openapiprocessor.test.*
99

1010

11-
private fun join(vararg collections: Collection<TestParams2>): List<TestParams2> {
12-
return collections.flatMap { it }
13-
}
14-
15-
private val testParamComparator = Comparator<TestParams2> { l, r ->
16-
val parser = l.parser.compareTo(r.parser)
17-
if (parser != 0) {
18-
return@Comparator parser
19-
}
20-
21-
val name = l.name.compareTo(r.name)
22-
if (name != 0) {
23-
return@Comparator name
24-
}
25-
26-
val openapi = l.openapi.compareTo(r.openapi)
27-
if (openapi != 0) {
28-
return@Comparator openapi
29-
}
30-
31-
return@Comparator 0
32-
}
33-
3411
val ALL_3x: List<TestParams2> = join(
3512
emptyList(),
3613
tests("annotation-mapping-class"),
@@ -117,7 +94,7 @@ val ALL_3x: List<TestParams2> = join(
11794
tests("schema-unreferenced"),
11895
tests("server-url"),
11996
tests("swagger-parsing-error")
120-
).sortedWith(testParamComparator)
97+
).sortedWith(TestParamComparator)
12198

12299
val EXCLUDE_OPENAPI4J = setOf(
123100
// the parser assumes that "type" must be string if a non-standard format is used
@@ -135,3 +112,47 @@ val EXCLUDE_SWAGGER = setOf(
135112
// can't get uri of a document
136113
"packages"
137114
)
115+
116+
fun testSet(
117+
name: String,
118+
parser: String = "INTERNAL",
119+
openapi: String = "openapi.yaml",
120+
model: String = "default",
121+
inputs: String = "inputs.yaml",
122+
outputs: String = "outputs.yaml",
123+
expected: String = "outputs"
124+
): TestSet {
125+
val testSet = TestSet()
126+
testSet.name = name
127+
testSet.processor = TestProcessor()
128+
testSet.parser = parser
129+
testSet.modelType = model
130+
testSet.openapi = openapi
131+
testSet.inputs = inputs
132+
testSet.outputs = outputs
133+
testSet.expected = expected
134+
return testSet
135+
}
136+
137+
fun buildTestSets(): List<TestSet> {
138+
return ALL_3x
139+
.filter {
140+
when (it.parser) {
141+
"INTERNAL" -> {
142+
true
143+
}
144+
"SWAGGER" if it.openapi == "openapi30.yaml" -> {
145+
!EXCLUDE_SWAGGER.contains(it.name)
146+
}
147+
"OPENAPI4J" if it.openapi == "openapi30.yaml" -> {
148+
!EXCLUDE_OPENAPI4J.contains(it.name)
149+
}
150+
else -> {
151+
false
152+
}
153+
}
154+
}
155+
.map {
156+
testSet(it.name, it.parser, it.openapi, model = it.modelType, outputs = it.outputs, expected = it.expected)
157+
}
158+
}

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

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

openapi-processor-test/src/main/kotlin/io/openapiprocessor/test/ProcessorTestSetsSupport.kt

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ data class TestParams(
3939
val modelTypes: List<ModelTypes> = listOf(ModelTypes.DEFAULT)
4040
)
4141

42+
// todo rename to TestParams
4243
data class TestParams2(
4344
val name: String,
4445
val openapi: String,
@@ -48,6 +49,28 @@ data class TestParams2(
4849
val parser: String = I
4950
)
5051

52+
fun join(vararg collections: Collection<TestParams2>): List<TestParams2> {
53+
return collections.flatMap { it }
54+
}
55+
56+
val TestParamComparator = Comparator<TestParams2> { l, r ->
57+
val parser = l.parser.compareTo(r.parser)
58+
if (parser != 0) {
59+
return@Comparator parser
60+
}
61+
62+
val name = l.name.compareTo(r.name)
63+
if (name != 0) {
64+
return@Comparator name
65+
}
66+
67+
val openapi = l.openapi.compareTo(r.openapi)
68+
if (openapi != 0) {
69+
return@Comparator openapi
70+
}
71+
72+
return@Comparator 0
73+
}
5174

5275
fun tests(
5376
name: String,
@@ -77,7 +100,7 @@ fun testX(name: String): Collection<TestParams2> {
77100

78101

79102

80-
103+
@Deprecated(message = "replace with test(sX)")
81104
fun test30_D_(
82105
name: String,
83106
openapi: String = API_30,
@@ -88,6 +111,7 @@ fun test30_D_(
88111
return TestParams(name, openapi, outputs, expected, modelTypes)
89112
}
90113

114+
@Deprecated(message = "replace with test(sX)")
91115
fun test30_DR(
92116
name: String,
93117
openapi: String = API_30,
@@ -98,6 +122,7 @@ fun test30_DR(
98122
return TestParams(name, openapi, outputs, expected, modelTypes)
99123
}
100124

125+
@Deprecated(message = "replace with test(sX)")
101126
fun test31_D_(
102127
name: String,
103128
openapi: String = API_31,
@@ -108,6 +133,7 @@ fun test31_D_(
108133
return TestParams(name, openapi, outputs, expected, modelTypes)
109134
}
110135

136+
@Deprecated(message = "replace with test(sX)")
111137
fun test31_DR(
112138
name: String,
113139
openapi: String = API_31,

0 commit comments

Comments
 (0)