|
| 1 | +/* |
| 2 | + * Copyright 2025 https://github.com/openapi-processor/openapi-processor-spring |
| 3 | + * PDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +package io.openapiprocessor.spring |
| 7 | + |
| 8 | +import io.kotest.core.spec.style.StringSpec |
| 9 | +import io.kotest.engine.spec.tempdir |
| 10 | +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 |
| 16 | + |
| 17 | + |
| 18 | +class CompileExpectedSpec: StringSpec({ |
| 19 | + |
| 20 | + for (testSet in sources()) { |
| 21 | + "compile - $testSet".config(enabled = true) { |
| 22 | + val folder = tempdir() |
| 23 | + val reader = ResourceReader(CompileExpectedSpec::class.java) |
| 24 | + |
| 25 | + val testFiles = TestFilesNative(folder, reader) |
| 26 | + |
| 27 | + TestSetCompiler(testSet, testFiles) |
| 28 | + .run(setOf( |
| 29 | + "src/testInt/resources/compile/Generated.java" |
| 30 | + )) |
| 31 | + .shouldBeTrue() |
| 32 | + } |
| 33 | + } |
| 34 | +}) |
| 35 | + |
| 36 | +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 |
| 54 | +} |
0 commit comments