diff --git a/docs/generators/groovy.md b/docs/generators/groovy.md index 06b15957dde..4c2b6f644d5 100644 --- a/docs/generators/groovy.md +++ b/docs/generators/groovy.md @@ -59,6 +59,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/groovy| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| ## IMPORT MAPPING diff --git a/docs/generators/java-camel.md b/docs/generators/java-camel.md index 4a8a1392133..c3849943020 100644 --- a/docs/generators/java-camel.md +++ b/docs/generators/java-camel.md @@ -86,6 +86,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|server title name or client service name| |OpenAPI Spring| |unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false| |useBeanValidation|Use BeanValidation API annotations| |true| diff --git a/docs/generators/java-inflector.md b/docs/generators/java-inflector.md index 50f1bfb4817..e924a759037 100644 --- a/docs/generators/java-inflector.md +++ b/docs/generators/java-inflector.md @@ -61,6 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/gen/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| ## IMPORT MAPPING diff --git a/docs/generators/java-micronaut-client.md b/docs/generators/java-micronaut-client.md index c1ba0089f6b..0de7278de01 100644 --- a/docs/generators/java-micronaut-client.md +++ b/docs/generators/java-micronaut-client.md @@ -65,6 +65,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |test|Specify which test tool to generate files for|
**junit**
Use JUnit as test tool
**spock**
Use Spock as test tool
|junit| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|Client service name| |null| |useBeanValidation|Use BeanValidation API annotations| |true| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| diff --git a/docs/generators/java-msf4j.md b/docs/generators/java-msf4j.md index b02b75270d8..79aa36220fd 100644 --- a/docs/generators/java-msf4j.md +++ b/docs/generators/java-msf4j.md @@ -64,6 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useTags|use tags for creating interface and controller classnames| |false| diff --git a/docs/generators/java-pkmst.md b/docs/generators/java-pkmst.md index 4e1183c50be..f6b391ea431 100644 --- a/docs/generators/java-pkmst.md +++ b/docs/generators/java-pkmst.md @@ -66,6 +66,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |springBootAdminUri|Spring-Boot URI| |null| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|server title name or client service name| |null| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| |zipkinUri|Zipkin URI| |null| diff --git a/docs/generators/java-play-framework.md b/docs/generators/java-play-framework.md index b262f6e4442..002dc7eae11 100644 --- a/docs/generators/java-play-framework.md +++ b/docs/generators/java-play-framework.md @@ -66,6 +66,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |/app| |supportAsync|Support Async operations| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|server title name or client service name| |openapi-java-playframework| |useBeanValidation|Use BeanValidation API annotations| |true| |useInterfaces|Makes the controllerImp implements an interface to facilitate automatic completion when updating from version x to y of your spec| |true| diff --git a/docs/generators/java-undertow-server.md b/docs/generators/java-undertow-server.md index e8c9d5c33bc..6aa1f1fe2a1 100644 --- a/docs/generators/java-undertow-server.md +++ b/docs/generators/java-undertow-server.md @@ -61,6 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| ## IMPORT MAPPING diff --git a/docs/generators/java-vertx-web.md b/docs/generators/java-vertx-web.md index 24fe9e99f2b..4089bedda4a 100644 --- a/docs/generators/java-vertx-web.md +++ b/docs/generators/java-vertx-web.md @@ -61,6 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| ## IMPORT MAPPING diff --git a/docs/generators/java-vertx.md b/docs/generators/java-vertx.md index 873382854ae..27ba174790d 100644 --- a/docs/generators/java-vertx.md +++ b/docs/generators/java-vertx.md @@ -63,6 +63,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |vertxSwaggerRouterVersion|Specify the version of the swagger router library| |null| |withXml|whether to include support for application/xml content type and include XML annotations in the model (works with libraries that provide support for JSON and XML)| |false| diff --git a/docs/generators/java.md b/docs/generators/java.md index 132437fd9bd..4132f755c12 100644 --- a/docs/generators/java.md +++ b/docs/generators/java.md @@ -74,6 +74,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |supportStreaming|Support streaming endpoint (beta)| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |useAbstractionForFiles|Use alternative types instead of java.io.File to allow passing bytes without a file on disk. Available on resttemplate, webclient, libraries| |false| |useBeanValidation|Use BeanValidation API annotations| |false| |useGzipFeature|Send gzip-encoded requests| |false| diff --git a/docs/generators/jaxrs-cxf-cdi.md b/docs/generators/jaxrs-cxf-cdi.md index 4388a69e60c..9ac40926c75 100644 --- a/docs/generators/jaxrs-cxf-cdi.md +++ b/docs/generators/jaxrs-cxf-cdi.md @@ -70,6 +70,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/gen/java| |supportAsync|Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useSwaggerAnnotations|Whether to generate Swagger annotations.| |true| diff --git a/docs/generators/jaxrs-cxf-client.md b/docs/generators/jaxrs-cxf-client.md index 6d53881cb17..cd9d4fee230 100644 --- a/docs/generators/jaxrs-cxf-client.md +++ b/docs/generators/jaxrs-cxf-client.md @@ -61,6 +61,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/gen/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |useBeanValidation|Use BeanValidation API annotations| |false| |useGenericResponse|Use generic response| |false| |useGzipFeatureForTests|Use Gzip Feature for tests| |false| diff --git a/docs/generators/jaxrs-cxf-extended.md b/docs/generators/jaxrs-cxf-extended.md index 65495572e1f..7518926c80c 100644 --- a/docs/generators/jaxrs-cxf-extended.md +++ b/docs/generators/jaxrs-cxf-extended.md @@ -73,6 +73,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |supportMultipleSpringServices|Support generation of Spring services from multiple specifications| |false| |testDataControlFile|JSON file to control test data generation| |null| |testDataFile|JSON file to contain generated test data| |null| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useAnnotatedBasePath|Use @Path annotations for basePath| |false| |useBeanValidation|Use BeanValidation API annotations| |true| diff --git a/docs/generators/jaxrs-cxf.md b/docs/generators/jaxrs-cxf.md index 1818ba5b42e..ca2506a6033 100644 --- a/docs/generators/jaxrs-cxf.md +++ b/docs/generators/jaxrs-cxf.md @@ -68,6 +68,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useAnnotatedBasePath|Use @Path annotations for basePath| |false| |useBeanValidation|Use BeanValidation API annotations| |true| diff --git a/docs/generators/jaxrs-jersey.md b/docs/generators/jaxrs-jersey.md index aa4bf2ebf96..390aeca70a0 100644 --- a/docs/generators/jaxrs-jersey.md +++ b/docs/generators/jaxrs-jersey.md @@ -65,6 +65,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |supportJava6|Whether to support Java6 with the Jersey1/2 library.| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useTags|use tags for creating interface and controller classnames| |false| diff --git a/docs/generators/jaxrs-resteasy-eap.md b/docs/generators/jaxrs-resteasy-eap.md index a3ed32580ca..9a63b82d1ce 100644 --- a/docs/generators/jaxrs-resteasy-eap.md +++ b/docs/generators/jaxrs-resteasy-eap.md @@ -64,6 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useSwaggerFeature|Use dynamic Swagger generator| |false| diff --git a/docs/generators/jaxrs-resteasy.md b/docs/generators/jaxrs-resteasy.md index 6ff30a6051e..fea68a9800c 100644 --- a/docs/generators/jaxrs-resteasy.md +++ b/docs/generators/jaxrs-resteasy.md @@ -64,6 +64,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true| |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useTags|use tags for creating interface and controller classnames| |false| diff --git a/docs/generators/jaxrs-spec.md b/docs/generators/jaxrs-spec.md index 9c8059ccd14..61aa2962a0c 100644 --- a/docs/generators/jaxrs-spec.md +++ b/docs/generators/jaxrs-spec.md @@ -70,6 +70,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |supportAsync|Wrap responses in CompletionStage type, allowing asynchronous computation (requires JAX-RS 2.1).| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|a title describing the application| |OpenAPI Server| |useBeanValidation|Use BeanValidation API annotations| |true| |useSwaggerAnnotations|Whether to generate Swagger annotations.| |true| diff --git a/docs/generators/spring.md b/docs/generators/spring.md index d778596fbf1..849bd84b8f1 100644 --- a/docs/generators/spring.md +++ b/docs/generators/spring.md @@ -79,6 +79,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true| |sourceFolder|source folder for generated code| |src/main/java| |swaggerDocketConfig|Generate Spring OpenAPI Docket configuration class.| |false| +|testOutput|Set output folder for models and APIs tests| |${project.build.directory}/generated-test-sources/openapi| |title|server title name or client service name| |OpenAPI Spring| |unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).| |false| |useBeanValidation|Use BeanValidation API annotations| |true| diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java index 34c6b4116c3..aaa30709e10 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java @@ -351,7 +351,7 @@ public class DefaultGenerator implements Generator { if (modelTestFile.exists()) { this.templateProcessor.skip(modelTestFile.toPath(), "Test files never overwrite an existing file of the same name."); } else { - File written = processTemplateToFile(models, templateName, filename, generateModelTests, CodegenConstants.MODEL_TESTS); + File written = processTemplateToFile(models, templateName, filename, generateModelTests, CodegenConstants.MODEL_TESTS, config.modelTestFileFolder()); if (written != null) { files.add(written); if (config.isEnablePostProcessFile() && !dryRun) { @@ -639,7 +639,7 @@ public class DefaultGenerator implements Generator { if (apiTestFile.exists()) { this.templateProcessor.skip(apiTestFile.toPath(), "Test files never overwrite an existing file of the same name."); } else { - File written = processTemplateToFile(operation, templateName, filename, generateApiTests, CodegenConstants.API_TESTS); + File written = processTemplateToFile(operation, templateName, filename, generateApiTests, CodegenConstants.API_TESTS, config.apiTestFileFolder()); if (written != null) { files.add(written); if (config.isEnablePostProcessFile() && !dryRun) { @@ -1018,11 +1018,15 @@ public class DefaultGenerator implements Generator { } protected File processTemplateToFile(Map templateData, String templateName, String outputFilename, boolean shouldGenerate, String skippedByOption) throws IOException { + return processTemplateToFile(templateData, templateName, outputFilename, shouldGenerate, skippedByOption, this.config.getOutputDir()); + } + + private File processTemplateToFile(Map templateData, String templateName, String outputFilename, boolean shouldGenerate, String skippedByOption, String intendedOutputDir) throws IOException { String adjustedOutputFilename = outputFilename.replaceAll("//", "/").replace('/', File.separatorChar); File target = new File(adjustedOutputFilename); if (ignoreProcessor.allowsFile(target)) { if (shouldGenerate) { - Path outDir = java.nio.file.Paths.get(this.config.getOutputDir()).toAbsolutePath(); + Path outDir = java.nio.file.Paths.get(intendedOutputDir).toAbsolutePath(); Path absoluteTarget = target.toPath().toAbsolutePath(); if (!absoluteTarget.startsWith(outDir)) { throw new RuntimeException(String.format(Locale.ROOT, "Target files must be generated within the output directory; absoluteTarget=%s outDir=%s", absoluteTarget, outDir)); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 05cb3233ebf..2933bd3302b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -70,6 +70,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code public static final String DISCRIMINATOR_CASE_SENSITIVE = "discriminatorCaseSensitive"; public static final String OPENAPI_NULLABLE = "openApiNullable"; public static final String JACKSON = "jackson"; + public static final String TEST_OUTPUT = "testOutput"; + + public static final String DEFAULT_TEST_FOLDER = "${project.build.directory}/generated-test-sources/openapi"; protected String dateLibrary = "threetenbp"; protected boolean supportAsync = false; @@ -113,6 +116,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code protected List additionalModelTypeAnnotations = new LinkedList<>(); protected List additionalEnumTypeAnnotations = new LinkedList<>(); protected boolean openApiNullable = true; + protected String outputTestFolder = ""; protected DocumentationProvider documentationProvider; protected AnnotationLibrary annotationLibrary; @@ -262,6 +266,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code snapShotVersionOptions.put("false", "Use a Release Version"); snapShotVersion.setEnum(snapShotVersionOptions); cliOptions.add(snapShotVersion); + cliOptions.add(CliOption.newString(TEST_OUTPUT, "Set output folder for models and APIs tests").defaultValue(DEFAULT_TEST_FOLDER)); if (null != defaultDocumentationProvider()) { CliOption documentationProviderCliOption = new CliOption(DOCUMENTATION_PROVIDER, @@ -638,6 +643,10 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code } else if (dateLibrary.equals("legacy")) { additionalProperties.put("legacyDates", "true"); } + + if (additionalProperties.containsKey(TEST_OUTPUT)) { + setOutputTestFolder(additionalProperties.get(TEST_OUTPUT).toString()); + } } @Override @@ -697,12 +706,12 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code @Override public String apiTestFileFolder() { - return (outputFolder + File.separator + testFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); + return (outputTestFolder + File.separator + testFolder + File.separator + apiPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); } @Override public String modelTestFileFolder() { - return (outputFolder + File.separator + testFolder + File.separator + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); + return (outputTestFolder + File.separator + testFolder + File.separator + modelPackage().replace('.', File.separatorChar)).replace('/', File.separatorChar); } @Override @@ -1813,6 +1822,25 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code this.openApiNullable = openApiNullable; } + @Override + public void setOutputDir(String dir) { + super.setOutputDir(dir); + if (this.outputTestFolder.isEmpty()) { + setOutputTestFolder(dir); + } + } + + public String getOutputTestFolder() { + if (outputTestFolder.isEmpty()) { + return DEFAULT_TEST_FOLDER; + } + return outputTestFolder; + } + + public void setOutputTestFolder(String outputTestFolder) { + this.outputTestFolder = outputTestFolder; + } + @Override public DocumentationProvider getDocumentationProvider() { return documentationProvider; diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java index 7016aa95fe2..13160dc8cda 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/AbstractJavaCodegenTest.java @@ -350,6 +350,24 @@ public class AbstractJavaCodegenTest { Assert.assertEquals(codegen.modelTestFileFolder(), "/User/open.api.tools/test.folder/org/openapitools/codegen/model".replace('/', File.separatorChar)); } + @Test + public void apiTestFileFolderDirect() { + final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + codegen.setOutputTestFolder("/User/open.api.tools"); + codegen.setTestFolder("test.folder"); + codegen.setApiPackage("org.openapitools.codegen.api"); + Assert.assertEquals(codegen.apiTestFileFolder(), "/User/open.api.tools/test.folder/org/openapitools/codegen/api".replace('/', File.separatorChar)); + } + + @Test + public void modelTestFileFolderDirect() { + final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen(); + codegen.setOutputTestFolder("/User/open.api.tools"); + codegen.setTestFolder("test.folder"); + codegen.setModelPackage("org.openapitools.codegen.model"); + Assert.assertEquals(codegen.modelTestFileFolder(), "/User/open.api.tools/test.folder/org/openapitools/codegen/model".replace('/', File.separatorChar)); + } + @Test public void modelFileFolder() { final AbstractJavaCodegen codegen = new P_AbstractJavaCodegen();