Skip to content

Commit 7041a0f

Browse files
committed
feat(citrusframework#1156): generate Java models alongside citrus classes
1 parent d1b04d7 commit 7041a0f

File tree

49 files changed

+2224
-607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2224
-607
lines changed

test-api-generator/citrus-test-api-generator-core/pom.xml

+62
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<name>Citrus :: Test API Generator :: Core</name>
1818
<description>Generates a Citrus Test-API for OpenAPI and WSDL specifications.</description>
1919

20+
<properties>
21+
<openapi-java-folder>${project.build.directory}/openapi-java-resources</openapi-java-folder>
22+
</properties>
23+
2024
<dependencies>
2125
<dependency>
2226
<groupId>org.citrusframework</groupId>
@@ -118,6 +122,64 @@
118122
</executions>
119123
</plugin>
120124

125+
<plugin>
126+
<groupId>org.apache.maven.plugins</groupId>
127+
<artifactId>maven-dependency-plugin</artifactId>
128+
<version>3.7.1</version>
129+
<configuration>
130+
<artifactItems>
131+
<artifactItem>
132+
<groupId>org.openapitools</groupId>
133+
<artifactId>openapi-generator</artifactId>
134+
<version>${org.openapitools.version}</version>
135+
<includes>Java/*Annotation*.mustache,Java/*Model*.mustache,Java/model*.mustache,Java/pojo*.mustache</includes>
136+
</artifactItem>
137+
</artifactItems>
138+
<outputDirectory>
139+
${openapi-java-folder}
140+
</outputDirectory>
141+
</configuration>
142+
<executions>
143+
<execution>
144+
<id>unpack-java-templates</id>
145+
<phase>generate-resources</phase>
146+
<goals>
147+
<goal>unpack</goal>
148+
</goals>
149+
</execution>
150+
</executions>
151+
</plugin>
152+
153+
<plugin>
154+
<groupId>org.apache.maven.plugins</groupId>
155+
<artifactId>maven-resources-plugin</artifactId>
156+
<version>3.3.1</version>
157+
<executions>
158+
<execution>
159+
<id>prepare-java-templates</id>
160+
<phase>process-resources</phase>
161+
<goals>
162+
<goal>copy-resources</goal>
163+
</goals>
164+
<configuration>
165+
<outputDirectory>${project.build.outputDirectory}/java-citrus</outputDirectory>
166+
<resources>
167+
<resource>
168+
<directory>
169+
${openapi-java-folder}/Java
170+
</directory>
171+
<includes>
172+
<include>
173+
*.mustache
174+
</include>
175+
</includes>
176+
</resource>
177+
</resources>
178+
</configuration>
179+
</execution>
180+
</executions>
181+
</plugin>
182+
121183
<plugin>
122184
<groupId>org.openapitools</groupId>
123185
<artifactId>openapi-generator-maven-plugin</artifactId>

test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java

+4-6
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public JavaCitrusCodegen() {
8585

8686
// set default
8787
additionalProperties.put(API_TYPE, API_TYPE_REST);
88+
additionalProperties.put("useJakartaEe", true);
8889

8990
// add additional reserved words used in CitrusAbstractTestRequest and its base class to prevent name collisions
9091
Set<String> reservedWordsTemp = reservedWords();
@@ -119,8 +120,7 @@ public JavaCitrusCodegen() {
119120
newString(API_ENDPOINT,
120121
"Which http client should be used (default " + httpClient + ")."));
121122
cliOptions.add(
122-
newString(
123-
API_TYPE,
123+
newString(API_TYPE,
124124
"Specifies the type of API to be generated specify SOAP to generate a SOAP API. By default a REST API will be generated"
125125
)
126126
);
@@ -135,10 +135,8 @@ public JavaCitrusCodegen() {
135135
newString(OPENAPI_SCHEMA,
136136
"Which OpenAPI schema should be used (default " + openapiSchema + ")."));
137137
cliOptions.add(
138-
newString(
139-
PREFIX,
140-
"Add a prefix before the name of the files. First character should be upper case (default "
141-
+ apiPrefix + ")."
138+
newString(PREFIX,
139+
"Add a prefix before the name of the files. First character should be upper case (default " + apiPrefix + ")."
142140
)
143141
);
144142
cliOptions.add(newString(PREFIX, "The api prefix (default " + apiPrefix + ")."));

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{package}};
244

25-
import jakarta.annotation.Generated;
265
import org.citrusframework.testapi.GeneratedApi;
276
import org.citrusframework.testapi.GeneratedApiRequest;
287
import jakarta.servlet.http.Cookie;
@@ -52,7 +31,7 @@ import java.util.List;
5231
import java.util.Map;
5332
import java.util.stream.Collectors;
5433

55-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
34+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
5635
public class {{classname}} implements GeneratedApi
5736
{
5837

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api_soap.mustache

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{package}};
244

25-
import jakarta.annotation.Generated;
265
import java.io.IOException;
276
import java.util.HashMap;
287
import java.util.Map;
@@ -45,7 +24,7 @@ import org.springframework.util.CollectionUtils;
4524

4625
import {{invokerPackage}}.citrus.{{prefix}}AbstractTestRequest;
4726

48-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
27+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
4928
public class {{classname}} implements GeneratedApi
5029
{
5130
public static final {{classname}} INSTANCE = new {{classname}}();

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_configuration.mustache

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{invokerPackage}}.spring;
244

@@ -29,13 +9,12 @@ import static org.springframework.beans.factory.config.BeanDefinition.SCOPE_PROT
299
import {{package}}.{{classname}};
3010
{{/apis}}
3111
{{/apiInfo}}
32-
import javax.annotation.processing.Generated;
3312
import org.springframework.context.annotation.Bean;
3413
import org.springframework.context.annotation.Configuration;
3514
import org.springframework.context.annotation.Scope;
3615

3716
@Configuration
38-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
17+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
3918
public class {{prefix}}BeanConfiguration {
4019
{{#apiInfo}}
4120
{{#apis}}

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{invokerPackage}}.citrus;
244

@@ -28,8 +8,6 @@ import java.util.Map;
288
import java.util.regex.Matcher;
299
import java.util.regex.Pattern;
3010

31-
import javax.annotation.processing.Generated;
32-
3311
import org.apache.commons.lang3.StringUtils;
3412
import org.springframework.beans.factory.config.BeanDefinition;
3513
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
@@ -42,7 +20,7 @@ import org.w3c.dom.Attr;
4220
import org.w3c.dom.Element;
4321
import org.w3c.dom.NamedNodeMap;
4422

45-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
23+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
4624
public class {{prefix}}BeanDefinitionParser implements BeanDefinitionParser {
4725
4826
private static final String COOKIE = "cookie";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*
2+
* Copyright the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/model.mustache

-1
This file was deleted.

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/model_doc.mustache

-1
This file was deleted.

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache

+2-24
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{invokerPackage}}.citrus.extension;
244

@@ -29,11 +9,9 @@ import {{package}}.{{classname}};
299
{{/apiInfo}}
3010
import {{invokerPackage}}.citrus.{{prefix}}BeanDefinitionParser;
3111

32-
import javax.annotation.processing.Generated;
33-
3412
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
3513

36-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
14+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
3715
public class {{prefix}}NamespaceHandler extends NamespaceHandlerSupport {
3816
3917
@Override

test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
1-
/*
2-
* Copyright the original author or authors.
3-
*
4-
* Licensed under the Apache License, Version 2.0 (the "License");
5-
* you may not use this file except in compliance with the License.
6-
* You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software
11-
* distributed under the License is distributed on an "AS IS" BASIS,
12-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13-
* See the License for the specific language governing permissions and
14-
* limitations under the License.
15-
*/
16-
17-
/**
18-
* ==================================================
19-
* GENERATED CLASS, ALL CHANGES WILL BE LOST
20-
* ==================================================
21-
*/
1+
{{>licenseInfo}}
222

233
package {{invokerPackage}}.citrus;
244

255
import static org.springframework.util.CollectionUtils.isEmpty;
266

27-
import jakarta.annotation.Generated;
287
import jakarta.annotation.Nullable;
298
import java.util.List;
309
import java.util.Map;
@@ -51,7 +30,7 @@ import org.slf4j.MarkerFactory;
5130
import org.springframework.beans.factory.annotation.Autowired;
5231
import org.springframework.beans.factory.annotation.Qualifier;
5332

54-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
33+
{{>additionalModelTypeAnnotations}}{{>generatedAnnotation}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}}
5534
public abstract class {{prefix}}AbstractTestRequest extends AbstractTestAction {
5635
5736
protected final Marker coverageMarker = MarkerFactory.getMarker("{{#lambda.uppercase}}{{prefix}}{{/lambda.uppercase}}-API-COVERAGE");

0 commit comments

Comments
 (0)