Skip to content

Commit b592db0

Browse files
committed
fix tests
1 parent ac59fb8 commit b592db0

File tree

5 files changed

+33
-32
lines changed

5 files changed

+33
-32
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/mapping/Mappings.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class Mappings(
121121
}
122122

123123
fun findAddParameterTypeMappings(filter: MappingMatcher, step: MappingStep): List<AddParameterTypeMapping> {
124-
val mappings = parameterTypeMappings.filter(filter, step.add(ParametersStep("type")))
124+
val mappings = parameterTypeMappings.filter(filter, step.add(ParametersStep("add")))
125125
if (mappings.isEmpty()) {
126126
return emptyList()
127127
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/mapping/steps/ParametersStep.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
package io.openapiprocessor.core.converter.mapping.steps
77

8-
class ParametersStep(val kind: String): ItemsStep() {
8+
class ParametersStep(private val kind: String): ItemsStep() {
99

1010
override fun isEqual(step: MappingStep): Boolean {
1111
return step is ParametersStep && step.kind == kind

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/processor/mapping/v2/MappingConverterGenericsSpec.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class MappingConverterGenericsSpec: StringSpec({
163163

164164
val mappingData = converter.convert(reader.read(yaml))
165165
val type = mappingData.globalMappings.findParameterNameTypeMapping(
166-
ParameterNameTypeMatcher(query(name = "foo")), ParametersStep())!!
166+
ParameterNameTypeMatcher(query(name = "foo")), ParametersStep("name"))!!
167167

168168
type.parameterName shouldBe "foo"
169169
val tm = type.mapping
@@ -190,7 +190,7 @@ class MappingConverterGenericsSpec: StringSpec({
190190

191191
val mappingData = converter.convert(reader.read(yaml))
192192
val type = mappingData.globalMappings.findParameterNameTypeMapping(
193-
ParameterNameTypeMatcher(query(name = "foo")), ParametersStep())!!
193+
ParameterNameTypeMatcher(query(name = "foo")), ParametersStep("name"))!!
194194

195195
type.parameterName shouldBe "foo"
196196
val tm = type.mapping
@@ -219,7 +219,7 @@ class MappingConverterGenericsSpec: StringSpec({
219219
""".trimMargin()
220220

221221
val mappingData = converter.convert(reader.read(yaml))
222-
val adds = mappingData.globalMappings.findAddParameterTypeMappings(AddParameterTypeMatcher(), ParametersStep())
222+
val adds = mappingData.globalMappings.findAddParameterTypeMappings(AddParameterTypeMatcher(), ParametersStep("type"))
223223

224224
adds shouldHaveSize 1
225225
val type = adds.first()
@@ -281,7 +281,7 @@ class MappingConverterGenericsSpec: StringSpec({
281281

282282
// when:
283283
val mappingData = converter.convert(reader.read(yaml))
284-
val types = mappingData.globalMappings.findAddParameterTypeMappings(AddParameterTypeMatcher(), ParametersStep())
284+
val types = mappingData.globalMappings.findAddParameterTypeMappings(AddParameterTypeMatcher(), ParametersStep("type"))
285285

286286
types shouldHaveSize 1
287287
val type = types.first()

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/processor/mapping/v2/MappingConverterParameterSpec.kt

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import io.kotest.matchers.shouldBe
1515
import io.mockk.mockk
1616
import io.openapiprocessor.core.converter.MappingFinderQuery
1717
import io.openapiprocessor.core.converter.mapping.AmbiguousTypeMappingException
18-
import io.openapiprocessor.core.converter.mapping.steps.EndpointsStep
1918
import io.openapiprocessor.core.converter.mapping.steps.GlobalsStep
2019
import io.openapiprocessor.core.converter.mapping.steps.ParametersStep
2120
import io.openapiprocessor.core.parser.HttpMethod
@@ -102,7 +101,8 @@ class MappingConverterParameterSpec: StringSpec({
102101
val mappings = MappingConverter(mapping).convert().globalMappings
103102

104103
// then:
105-
val nameTypeMapping = mappings.findParameterNameTypeMapping(parameterNameMatcher(name = "foo"), ParametersStep())!!
104+
val nameTypeMapping = mappings.findParameterNameTypeMapping(
105+
parameterNameMatcher(name = "foo"), ParametersStep("type"))!!
106106

107107
nameTypeMapping.parameterName shouldBe "foo"
108108
nameTypeMapping.mapping.sourceTypeName.shouldBeNull()
@@ -125,7 +125,8 @@ class MappingConverterParameterSpec: StringSpec({
125125
val mappings = MappingConverter(mapping).convert().globalMappings
126126

127127
// then:
128-
val nameTypeMapping = mappings.findParameterNameTypeMapping(parameterNameMatcher(name = "foo"), ParametersStep())
128+
val nameTypeMapping = mappings.findParameterNameTypeMapping(
129+
parameterNameMatcher(name = "foo"), ParametersStep("type"))
129130

130131
nameTypeMapping.shouldBeNull()
131132
}
@@ -147,7 +148,7 @@ class MappingConverterParameterSpec: StringSpec({
147148
val mappings = MappingConverter(mapping).convert().globalMappings
148149

149150
shouldThrow<AmbiguousTypeMappingException> {
150-
mappings.findParameterNameTypeMapping(parameterNameMatcher(name = "foo"), ParametersStep())
151+
mappings.findParameterNameTypeMapping(parameterNameMatcher(name = "foo"), ParametersStep("type"))
151152
}
152153
}
153154

@@ -165,7 +166,7 @@ class MappingConverterParameterSpec: StringSpec({
165166
val mappings = MappingConverter(mapping).convert().globalMappings
166167

167168
// then:
168-
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep())
169+
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep("type"))
169170

170171
addMappings.shouldBeEmpty()
171172
}
@@ -183,7 +184,7 @@ class MappingConverterParameterSpec: StringSpec({
183184
val mappings = MappingConverter(mapping).convert().globalMappings
184185

185186
// then:
186-
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep())
187+
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep("type"))
187188

188189
addMappings.size.shouldBe(1)
189190
val add = addMappings.first()
@@ -209,7 +210,7 @@ class MappingConverterParameterSpec: StringSpec({
209210
val mappings = MappingConverter(mapping).convert().globalMappings
210211

211212
// then:
212-
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep())
213+
val addMappings = mappings.findAddParameterTypeMappings(addParameterTypeMatcher(), ParametersStep("type"))
213214

214215
addMappings.size.shouldBe(2)
215216
addMappings[0].parameterName shouldBe "foo"
@@ -232,7 +233,7 @@ class MappingConverterParameterSpec: StringSpec({
232233
val mappings = MappingConverter(mapping).convert().globalMappings
233234

234235
val annotationMappings = mappings.findAnnotationParameterTypeMapping(
235-
annotationTypeMatcher(type = "Foo"), ParametersStep())
236+
annotationTypeMatcher(type = "Foo"), ParametersStep("type"))
236237

237238
annotationMappings shouldHaveSize 1
238239
val annotationMapping = annotationMappings.first()
@@ -259,7 +260,7 @@ class MappingConverterParameterSpec: StringSpec({
259260
val mappings = MappingConverter(mapping).convert().globalMappings
260261

261262
val annotationMappings = mappings.findAnnotationParameterTypeMapping(
262-
annotationTypeMatcher(type = "Foo"), ParametersStep())
263+
annotationTypeMatcher(type = "Foo"), ParametersStep("type"))
263264

264265
annotationMappings shouldHaveSize 2
265266
}
@@ -279,7 +280,7 @@ class MappingConverterParameterSpec: StringSpec({
279280

280281
// then:
281282
val annotationMappings = mappings.findAnnotationParameterTypeMapping(
282-
annotationTypeMatcher(name = "Foo"), ParametersStep())
283+
annotationTypeMatcher(name = "Foo"), ParametersStep("type"))
283284

284285
annotationMappings.shouldBeEmpty()
285286
}
@@ -300,7 +301,7 @@ class MappingConverterParameterSpec: StringSpec({
300301
val mappings = MappingConverter(mapping).convert().globalMappings
301302

302303
val annotationMappings = mappings.findAnnotationParameterNameTypeMapping(
303-
annotationParameterNameTypeMatcher(name = "foo"), ParametersStep())
304+
annotationParameterNameTypeMatcher(name = "foo"), ParametersStep("name"))
304305

305306
annotationMappings shouldHaveSize 1
306307
val annotationMapping = annotationMappings.first()
@@ -326,7 +327,7 @@ class MappingConverterParameterSpec: StringSpec({
326327
val mappings = MappingConverter(mapping).convert().globalMappings
327328

328329
val annotationMappings = mappings.findAnnotationParameterNameTypeMapping(
329-
annotationParameterNameTypeMatcher(name = "foo"), ParametersStep())
330+
annotationParameterNameTypeMatcher(name = "foo"), ParametersStep("name"))
330331

331332
annotationMappings shouldHaveSize 2
332333
}
@@ -346,7 +347,7 @@ class MappingConverterParameterSpec: StringSpec({
346347

347348
// then:
348349
val annotationMappings = mappings.findAnnotationParameterNameTypeMapping(
349-
annotationTypeMatcher(name = "foo"), ParametersStep())
350+
annotationTypeMatcher(name = "foo"), ParametersStep("name"))
350351

351352
annotationMappings.shouldBeEmpty()
352353
}
@@ -376,14 +377,14 @@ class MappingConverterParameterSpec: StringSpec({
376377

377378
// then:
378379
val postQuery = MappingFinderQuery(path = "/foo", method = HttpMethod.POST, name = "Foo")
379-
val typeMapping = mappings["/foo"]!!.findParameterTypeMapping(postQuery, ParametersStep())!!
380+
val typeMapping = mappings["/foo"]!!.findParameterTypeMapping(postQuery, ParametersStep("type"))!!
380381

381382
typeMapping.sourceTypeName shouldBe "Foo"
382383
typeMapping.sourceTypeFormat.shouldBeNull()
383384
typeMapping.targetTypeName shouldBe "io.openapiprocessor.Foo"
384385

385386
val getQuery = MappingFinderQuery(path = "/foo", method = HttpMethod.GET, name= "Foo")
386-
val typeMappingGet = mappings["/foo"]!!.findParameterTypeMapping(getQuery, ParametersStep())!!
387+
val typeMappingGet = mappings["/foo"]!!.findParameterTypeMapping(getQuery, ParametersStep("type"))!!
387388

388389
typeMappingGet.sourceTypeName shouldBe "Foo"
389390
typeMappingGet.sourceTypeFormat.shouldBeNull()
@@ -415,7 +416,7 @@ class MappingConverterParameterSpec: StringSpec({
415416
val mappings = MappingConverter(mapping).convert().endpointMappings
416417

417418
val annotationMappings = mappings["/foo"]!!.findAnnotationParameterTypeMapping(
418-
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, type = "Foo"), ParametersStep())
419+
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, type = "Foo"), ParametersStep("type"))
419420

420421
annotationMappings shouldHaveSize 2
421422
annotationMappings[0].sourceTypeName shouldBe "Foo"
@@ -428,7 +429,7 @@ class MappingConverterParameterSpec: StringSpec({
428429
annotationMappings[1].annotation.parameters.shouldBeEmpty()
429430

430431
val annotationMappingsGet = mappings["/foo"]!!.findAnnotationParameterTypeMapping(
431-
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, type = "Foo"), ParametersStep())
432+
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, type = "Foo"), ParametersStep("type"))
432433

433434
annotationMappingsGet shouldHaveSize 2
434435
annotationMappingsGet[0].sourceTypeName shouldBe "Foo"
@@ -466,14 +467,14 @@ class MappingConverterParameterSpec: StringSpec({
466467

467468
// then:
468469
val typeMapping = mappings["/foo"]!!.findParameterNameTypeMapping(
469-
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, name = "foo"), ParametersStep())!!
470+
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, name = "foo"), ParametersStep("name"))!!
470471

471472
typeMapping.parameterName shouldBe "foo"
472473
typeMapping.mapping.sourceTypeName.shouldBeNull()
473474
typeMapping.mapping.targetTypeName shouldBe "io.openapiprocessor.Foo"
474475

475476
val typeMappingGet = mappings["/foo"]!!.findParameterNameTypeMapping(
476-
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, name= "foo"), ParametersStep())!!
477+
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, name= "foo"), ParametersStep("name"))!!
477478

478479
typeMappingGet.parameterName shouldBe "foo"
479480
typeMappingGet.mapping.sourceTypeName.shouldBeNull()
@@ -505,7 +506,7 @@ class MappingConverterParameterSpec: StringSpec({
505506
val mappings = MappingConverter(mapping).convert().endpointMappings
506507

507508
val annotationMappings = mappings["/foo"]!!.findAnnotationParameterNameTypeMapping(
508-
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, name = "foo"), ParametersStep())
509+
MappingFinderQuery(path = "/foo", method = HttpMethod.POST, name = "foo"), ParametersStep("name"))
509510

510511
annotationMappings shouldHaveSize 2
511512
annotationMappings[0].name shouldBe "foo"
@@ -514,7 +515,7 @@ class MappingConverterParameterSpec: StringSpec({
514515
annotationMappings[1].annotation.type shouldBe "io.openapiprocessor.Bar"
515516

516517
val annotationMappingsGet = mappings["/foo"]!!.findAnnotationParameterNameTypeMapping(
517-
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, name = "foo"), ParametersStep())
518+
MappingFinderQuery(path = "/foo", method = HttpMethod.GET, name = "foo"), ParametersStep("name"))
518519

519520
annotationMappingsGet shouldHaveSize 2
520521
annotationMappingsGet[0].name shouldBe "foo"
@@ -550,7 +551,7 @@ class MappingConverterParameterSpec: StringSpec({
550551

551552
// then:
552553
val addMappings = mappings["/foo"]!!.findAddParameterTypeMappings(
553-
MappingFinderQuery(path = "/foo", method = HttpMethod.POST), ParametersStep())
554+
MappingFinderQuery(path = "/foo", method = HttpMethod.POST), ParametersStep("add"))
554555

555556
addMappings shouldHaveSize 2
556557
addMappings[0].parameterName shouldBe "foo"
@@ -559,7 +560,7 @@ class MappingConverterParameterSpec: StringSpec({
559560
addMappings[1].mapping.targetTypeName shouldBe "io.openapiprocessor.Bar"
560561

561562
val addMappingsGet = mappings["/foo"]!!.findAddParameterTypeMappings(
562-
MappingFinderQuery(path = "/foo", method = HttpMethod.GET), ParametersStep())
563+
MappingFinderQuery(path = "/foo", method = HttpMethod.GET), ParametersStep("add"))
563564

564565
addMappingsGet shouldHaveSize 2
565566
addMappingsGet[0].parameterName shouldBe "foo2"

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/processor/mapping/v2/MappingConverterSpec.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class MappingConverterSpec: StringSpec({
131131
val mappings = MappingConverter(reader.read(yaml) as Mapping).convert().globalMappings
132132

133133
val annotations = mappings.findAnnotationParameterTypeMapping(
134-
annotationTypeMatcher(name = "Foo"), ParametersStep())
134+
annotationTypeMatcher(name = "Foo"), ParametersStep("add"))
135135

136136
annotations shouldHaveSize 1
137137
val annotation = annotations.first()
@@ -156,7 +156,7 @@ class MappingConverterSpec: StringSpec({
156156

157157
val mappings = MappingConverter(reader.read(yaml) as Mapping).convert().endpointMappings
158158
val annotations = mappings["/foo"]!!.findAnnotationParameterTypeMapping(
159-
MappingFinderQuery(name = "Foo"), ParametersStep())
159+
MappingFinderQuery(name = "Foo"), ParametersStep("add"))
160160

161161
annotations shouldHaveSize 1
162162

@@ -183,7 +183,7 @@ class MappingConverterSpec: StringSpec({
183183

184184
val mappings = MappingConverter(reader.read(yaml) as Mapping).convert().endpointMappings
185185
val annotations = mappings["/foo"]!!.findAnnotationParameterTypeMapping(
186-
MappingFinderQuery(name = "Foo", method = HttpMethod.GET), ParametersStep())
186+
MappingFinderQuery(name = "Foo", method = HttpMethod.GET), ParametersStep("add"))
187187

188188
annotations shouldHaveSize 1
189189

0 commit comments

Comments
 (0)