Skip to content

Commit ff2d099

Browse files
committed
compile expected files of integration tests
1 parent 24170cd commit ff2d099

35 files changed

Lines changed: 161 additions & 20 deletions

File tree

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

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* Copyright 2023 https://github.com/openapi-processor/openapi-processor-core
33
* PDX-License-Identifier: Apache-2.0
44
*/
5+
56
package io.openapiprocessor.core
67

78
import io.kotest.core.spec.style.StringSpec
@@ -45,31 +46,42 @@ class CompileExpectedSpec: StringSpec({
4546
}
4647

4748
for (testSet in sources()) {
48-
"compile - $testSet".config(enabled = false) {
49+
"compile - $testSet".config(enabled = true) {
4950
val support = FileSupport(
5051
CompileExpectedSpec::class.java,
5152
testSet.inputs, testSet.outputs
5253
)
5354

54-
val diagnostics = DiagnosticCollector<JavaFileObject>()
55-
val compiler = ToolProvider.getSystemJavaCompiler()
56-
val manager = MemoryFileManager(compiler.getStandardFileManager(diagnostics, null, null))
57-
5855
val source = testSet.name
5956
val sourcePath = "/tests/$source"
60-
val expected = support.readTestItems(sourcePath, "outputs.yaml").items
61-
62-
val expectedFileNames = expected.map { it.replaceFirst("<model>", "model/${testSet.modelType}") }
63-
val additionalFileNames = support.readTestItems(sourcePath, "compile.yaml").items
6457

6558
val compilePaths = mutableListOf<Path>()
59+
if (source != "generated") {
60+
compilePaths.add(Path.of("src/testInt/resources/compile/Generated.java"))
61+
}
62+
compilePaths.add(Path.of("src/testInt/resources/compile/Mapping.java"))
63+
compilePaths.add(Path.of("src/testInt/resources/compile/Parameter.java"))
64+
compilePaths.add(Path.of("src/testInt/resources/compile/jakarta/Valid.java"))
65+
compilePaths.add(Path.of("src/testInt/resources/compile/jakarta/Size.java"))
66+
compilePaths.add(Path.of("src/testInt/resources/compile/javax/Valid.java"))
67+
68+
val expected = support.readTestItems(sourcePath, "outputs.yaml").items
69+
val expectedFileNames = expected.map { it.replaceFirst("<model>", "model/${testSet.modelType}") }
6670
expectedFileNames.forEach {
6771
compilePaths.add(Path.of("src/testInt/resources${sourcePath}/$it"))
6872
}
69-
additionalFileNames.forEach {
70-
compilePaths.add(Path.of("src/testInt/resources/$it"))
73+
74+
if (support.checkTestItems(sourcePath, "compile.yaml")) {
75+
val additionalFileNames = support.readTestItems(sourcePath, "compile.yaml").items
76+
additionalFileNames.forEach {
77+
compilePaths.add(Path.of("src/testInt/resources/$it"))
78+
}
7179
}
7280

81+
val diagnostics = DiagnosticCollector<JavaFileObject>()
82+
val compiler = ToolProvider.getSystemJavaCompiler()
83+
val manager = MemoryFileManager(compiler.getStandardFileManager(diagnostics, null, null))
84+
7385
val options = listOf<String>()
7486
val compilationUnit = manager.getJavaFileObjectsFromPaths(compilePaths)
7587
val task = compiler.getTask(null, manager, diagnostics, options, null, compilationUnit)
@@ -83,7 +95,6 @@ class CompileExpectedSpec: StringSpec({
8395
success.shouldBeTrue()
8496
}
8597
}
86-
8798
})
8899

89100
private fun sources(): Collection<TestSet> {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package annotation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.Target;
6+
7+
import static java.lang.annotation.ElementType.PARAMETER;
8+
import static java.lang.annotation.RetentionPolicy.CLASS;
9+
10+
@Documented
11+
@Retention(CLASS)
12+
@Target({PARAMETER})
13+
public @interface Parameter {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package http;
2+
3+
public class Multipart {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package jakarta.validation.constraints;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.Target;
6+
7+
import static java.lang.annotation.ElementType.FIELD;
8+
import static java.lang.annotation.ElementType.PARAMETER;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
11+
@Documented
12+
@Retention(RUNTIME)
13+
@Target({ FIELD, PARAMETER })
14+
//@Repeatable(List.class)
15+
public @interface Size {
16+
int max() default Integer.MAX_VALUE;
17+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package jakarta.validation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.Target;
6+
7+
import static java.lang.annotation.ElementType.FIELD;
8+
import static java.lang.annotation.ElementType.PARAMETER;
9+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
10+
11+
@Documented
12+
@Retention(RUNTIME)
13+
@Target({FIELD, PARAMETER})
14+
public @interface Valid {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package javax.servlet.http;
2+
3+
public class HttpServletRequest {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package javax.validation;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.Target;
6+
7+
import static java.lang.annotation.ElementType.*;
8+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
9+
10+
@Documented
11+
@Retention(RUNTIME)
12+
@Target({FIELD, PARAMETER, TYPE_USE})
13+
public @interface Valid {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package org.openapitools.jackson.nullable;
2+
3+
public class JsonNullable<T> {
4+
public static <T> JsonNullable<T> undefined() {
5+
return null;
6+
}
7+
}

openapi-processor-core/src/testInt/resources/compile/Annotation.java renamed to openapi-processor-core/src/testInt/resources/compile/oap/Annotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.lang.annotation.Retention;
55
import java.lang.annotation.Target;
66

7-
import static java.lang.annotation.ElementType.*;
7+
import static java.lang.annotation.ElementType.FIELD;
88
import static java.lang.annotation.RetentionPolicy.CLASS;
99

1010
@Documented

openapi-processor-core/src/testInt/resources/compile/Bar.java renamed to openapi-processor-core/src/testInt/resources/compile/oap/Bar.java

File renamed without changes.

0 commit comments

Comments
 (0)