From 4a7f46cba583763e9b2f04436fb981b0ba25c40d Mon Sep 17 00:00:00 2001 From: sullis Date: Sat, 19 Feb 2022 02:50:50 -0800 Subject: [PATCH] [java] openapi-generator-maven-plugin: add jaxrs-jersey2 test (#11658) --- .../openapi-generator-maven-plugin/README.md | 2 +- .../openapi-generator-maven-plugin/pom.xml | 10 +-- .../src/it/jaxrs-jersey2/invoker.properties | 3 + .../src/it/jaxrs-jersey2/pom.xml | 67 +++++++++++++++++++ .../jaxrs-jersey2/templates/README.mustache | 21 ++++++ .../src/it/jaxrs-jersey2/verify.groovy | 37 ++++++++++ 6 files changed, 134 insertions(+), 6 deletions(-) create mode 100644 modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/invoker.properties create mode 100644 modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/pom.xml create mode 100644 modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/templates/README.mustache create mode 100644 modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/verify.groovy diff --git a/modules/openapi-generator-maven-plugin/README.md b/modules/openapi-generator-maven-plugin/README.md index be709bea8af..3102d196ffa 100644 --- a/modules/openapi-generator-maven-plugin/README.md +++ b/modules/openapi-generator-maven-plugin/README.md @@ -12,7 +12,7 @@ Add to your `build->plugins` section (default phase is `generate-sources` phase) org.openapitools openapi-generator-maven-plugin - 5.3.0 + 5.4.0 diff --git a/modules/openapi-generator-maven-plugin/pom.xml b/modules/openapi-generator-maven-plugin/pom.xml index ffbcf5077bf..2666eb1072e 100644 --- a/modules/openapi-generator-maven-plugin/pom.xml +++ b/modules/openapi-generator-maven-plugin/pom.xml @@ -126,13 +126,12 @@ org.apache.maven.plugins maven-invoker-plugin - 3.2.1 + 3.2.2 + false + true verify - true - true - false - true + true @@ -146,6 +145,7 @@ integration-test + install run diff --git a/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/invoker.properties b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/invoker.properties new file mode 100644 index 00000000000..7ca0a57da2a --- /dev/null +++ b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/invoker.properties @@ -0,0 +1,3 @@ +invoker.goals = -nsu clean generate-sources +# The expected result of the build, possible values are "success" (default) and "failure" +invoker.buildResult = success diff --git a/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/pom.xml b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/pom.xml new file mode 100644 index 00000000000..06e8357fcdf --- /dev/null +++ b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/pom.xml @@ -0,0 +1,67 @@ + + + + + 4.0.0 + + org.openapitools.maven.its + jaxrs-jersey2 + 1.0-SNAPSHOT + + + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.10.0 + + 11 + 11 + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + + https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml + jaxrs-jersey + jersey2 + java8 + ${basedir}/out + ${project.basedir}/templates + + + + + + remote + generate-sources + + generate + + + + + + + diff --git a/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/templates/README.mustache b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/templates/README.mustache new file mode 100644 index 00000000000..cee4f752e72 --- /dev/null +++ b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/templates/README.mustache @@ -0,0 +1,21 @@ +# TEST TEST TEST + +# {{artifactId}} + +{{appName}} + +- API version: {{appVersion}} +{{^hideGenerationTimestamp}} + +- Build date: {{generatedDate}} +{{/hideGenerationTimestamp}} + +{{#appDescriptionWithNewLines}}{{{appDescriptionWithNewLines}}}{{/appDescriptionWithNewLines}} + +{{#infoUrl}} + For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +… etc. diff --git a/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/verify.groovy b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/verify.groovy new file mode 100644 index 00000000000..5ab77bc67d9 --- /dev/null +++ b/modules/openapi-generator-maven-plugin/src/it/jaxrs-jersey2/verify.groovy @@ -0,0 +1,37 @@ +/* + * Copyright 2022 OpenAPI-Generator Contributors (https://openapi-generator.tech) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +File readme = new File(basedir, "out/README.md") + +assert readme.isFile() +assert readme.text.contains("# TEST TEST TEST") +assert readme.text.contains("# openapi-jaxrs-server") +assert readme.text.contains("OpenAPI Petstore") + +File mavenPomXml = new File(basedir, "out/pom.xml") +assert mavenPomXml.isFile() + +File petApi = new File(basedir, "out/src/gen/java/org/openapitools/api/PetApi.java") +assert petApi.isFile() +assert petApi.text.contains("import org.openapitools.api.PetApiService;") + +File petApiService = new File(basedir, "out/src/gen/java/org/openapitools/api/PetApiService.java") +assert petApiService.isFile() +assert petApiService.text.contains("import javax.ws.rs.core.Response;") + +File petModel = new File(basedir, "out/src/gen/java/org/openapitools/model/Pet.java") +assert petModel.isFile() +assert petModel.text.contains("public class Pet")