Skip to content

Commit 83460cf

Browse files
committed
move tests around
1 parent b933678 commit 83460cf

1 file changed

Lines changed: 36 additions & 37 deletions

File tree

modules/openapi-generator/src/test/java/org/openapitools/codegen/kotlin/spring/KotlinSpringServerCodegenTest.java

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,42 @@ public void generateSerializableModelWithXimplements() throws Exception {
10271027
);
10281028
}
10291029

1030+
@Test
1031+
public void generateNonSerializableModelWithXimplements() throws Exception {
1032+
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
1033+
output.deleteOnExit();
1034+
String outputPath = output.getAbsolutePath().replace('\\', '/');
1035+
1036+
KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
1037+
codegen.setOutputDir(output.getAbsolutePath());
1038+
1039+
ClientOptInput input = new ClientOptInput()
1040+
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml"))
1041+
.config(codegen);
1042+
DefaultGenerator generator = new DefaultGenerator();
1043+
1044+
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
1045+
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
1046+
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
1047+
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
1048+
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
1049+
1050+
generator.opts(input).generate();
1051+
1052+
Path path = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Dog.kt");
1053+
assertFileContains(
1054+
path,
1055+
"@get:JsonProperty(\"likesFetch\", required = true) override val likesFetch: kotlin.Boolean,",
1056+
") : Pet, com.some.pack.Fetchable {"
1057+
);
1058+
assertFileNotContains(
1059+
path,
1060+
"import java.io.Serializable",
1061+
") : Pet, Serializable, com.some.pack.Fetchable {",
1062+
") : Pet, Serializable {",
1063+
"private const val serialVersionUID: kotlin.Long = 1"
1064+
);
1065+
}
10301066

10311067
private Path generateApiSources(
10321068
boolean includeHttpRequestContext,
@@ -1192,43 +1228,6 @@ public void nonReactiveWithoutHttpRequestContextNone() throws Exception {
11921228
);
11931229
}
11941230

1195-
@Test
1196-
public void generateNonSerializableModelWithXimplements() throws Exception {
1197-
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
1198-
output.deleteOnExit();
1199-
String outputPath = output.getAbsolutePath().replace('\\', '/');
1200-
1201-
KotlinSpringServerCodegen codegen = new KotlinSpringServerCodegen();
1202-
codegen.setOutputDir(output.getAbsolutePath());
1203-
1204-
ClientOptInput input = new ClientOptInput()
1205-
.openAPI(TestUtils.parseSpec("src/test/resources/3_0/kotlin/petstore-with-x-kotlin-implements.yaml"))
1206-
.config(codegen);
1207-
DefaultGenerator generator = new DefaultGenerator();
1208-
1209-
generator.setGeneratorPropertyDefault(CodegenConstants.MODELS, "true");
1210-
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_TESTS, "false");
1211-
generator.setGeneratorPropertyDefault(CodegenConstants.MODEL_DOCS, "false");
1212-
generator.setGeneratorPropertyDefault(CodegenConstants.APIS, "false");
1213-
generator.setGeneratorPropertyDefault(CodegenConstants.SUPPORTING_FILES, "false");
1214-
1215-
generator.opts(input).generate();
1216-
1217-
Path path = Paths.get(outputPath + "/src/main/kotlin/org/openapitools/model/Dog.kt");
1218-
assertFileContains(
1219-
path,
1220-
"@get:JsonProperty(\"likesFetch\", required = true) override val likesFetch: kotlin.Boolean,",
1221-
") : Pet, com.some.pack.Fetchable {"
1222-
);
1223-
assertFileNotContains(
1224-
path,
1225-
"import java.io.Serializable",
1226-
") : Pet, Serializable, com.some.pack.Fetchable {",
1227-
") : Pet, Serializable {",
1228-
"private const val serialVersionUID: kotlin.Long = 1"
1229-
);
1230-
}
1231-
12321231
@Test
12331232
public void reactiveWithoutFlow() throws Exception {
12341233
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();

0 commit comments

Comments
 (0)