diff --git a/pom.xml b/pom.xml
index 126486ac3e..f915f68c37 100644
--- a/pom.xml
+++ b/pom.xml
@@ -50,14 +50,16 @@
- core
- utils
- runtime
- validation
+ catalog
connectors
+ core
endpoints
+ runtime
+ test-api-generator
tools
- catalog
+ utils
+ utils
+ validation
@@ -250,7 +252,7 @@
3.2.0
4.1.105.Final
4.12.0
- 7.5.0
+ 7.5.0
4.7.6
3.0.4
4.25.0
@@ -525,7 +527,7 @@
org.openapitools
openapi-generator
- ${openapi-generator-maven-plugin}
+ ${org.openapitools.version}
provided
diff --git a/src/manual/connector-openapi.adoc b/src/manual/connector-openapi.adoc
index c0e24a1c8a..382d0c65e8 100644
--- a/src/manual/connector-openapi.adoc
+++ b/src/manual/connector-openapi.adoc
@@ -334,11 +334,11 @@ The generator provides the following features:
* generation of a Test API
** from OpenAPI Specification
** [TODO #1163] from WSDL via an intermediate step that generates a "light" OpenApi specification from a WSDL
-* integration into Citrus XML test cases
+* integration into <>
** integration into XML editors via generated XSD
*** schema validation
*** auto completion
-* integration into Citrus Java test cases via Java DSL [TODO #1161]
+* integration into <> via Java DSL [TODO #1161]
The following directory structure/table specifies the files, which are generated by the generator.
Note that the `Prefix` is a configuration parameter which should uniquely identify a generated API.
@@ -387,9 +387,9 @@ target/
==== Configuration of Test API generation
Code generation is typically performed during the build process.
-For the Citrus Test API Generator, it is carried out by a Maven plugin.
+For the Citrus Test API Generator, it is carried out by a Maven or Gradle plugin.
While the standard generator plugin, `org.openapitools:openapi-generator-maven-plugin`, can be employed for this purpose, configuring it can be cumbersome, especially when dealing with multiple APIs.
-To address this challenge, Citrus offers its adaptation of this standard generator Maven plugin.
+To address this challenge, Citrus offers its adaptation of this standard generator plugin.
This `Citrus OpenAPI Generator Plugin` simplifies the configuration of test API generation by providing predefined defaults and supporting the generation of multiple APIs.
Additionally, it enhances support for generating Spring integration files (`spring.handlers` and `spring.schemas`), thereby facilitating the integration of generated APIs into Spring-based applications.
Consequently, utilizing the Citrus Generator Plugin is recommended in most scenarios.
@@ -535,27 +535,26 @@ The following shows the configuration of test api generation for different scena
These are the primary elements you can configure in the `` section:
|===
-| Configuration element | Maven Property | Description | Default Value
+| Configuration element | Maven Property | Description | Default Value
| `schemaFolder` | `citrus.test.api.generator.schema.folder` | Location for the generated XSD schemas | `schema/xsd/%VERSION%`
| `resourceFolder` | `citrus.test.api.generator.resource.folder` | Location to which resources are generated | `generated-resources`
| `sourceFolder` | `citrus.test.api.generator.source.folder` | Location to which sources are generated | `generated-sources`
| `metaInfFolder` | `citrus.test.api.generator.meta.inf.folder` | Location to which spring meta files are generated/updated | `target/generated-test-resources/META-INF`
| `generateSpringIntegrationFiles` | `citrus.test.api.generator.generate.spring.integration.files` | Specifies whether spring integration files should be generated | `true`
-| Nested api element | | |
+| Nested `` element | | |
| `prefix` | `citrus.test.api.generator.prefix` | Specifies the prefix used for the test API, typically an acronym | (no default, required)
| `source` | `citrus.test.api.generator.source` | Specifies the source of the test API | (no default, required)
| `version` | `citrus.test.api.generator.version` | Specifies the version of the API, may be null | (none)
| `endpoint` | `citrus.test.api.generator.endpoint` | Specifies the endpoint of the test API | `applicationServiceClient`
| `type` | `citrus.test.api.generator.type` | Specifies the type of the test API | `REST`, other option is `SOAP`
| `useTags` | `citrus.test.api.generator.use.tags` | Specifies whether tags should be used by the generator | `true`
-| `invokerPackage` | `citrus.test.api.generator.invoker.package` | Package for the test API classes | `org.citrusframework.automation.%PREFIX%.%VERSION%`
+| `invokerPackage` | `citrus.test.api.generator.invoker.package` | Package for the test API classes | `org.citrusframework.automation.%PREFIX%.%VERSION%`
| `apiPackage` | `citrus.test.api.generator.api.package` | Package for the test API interface classes | `org.citrusframework.automation.%PREFIX%.%VERSION%.api`
| `modelPackage` | `citrus.test.api.generator.model.package` | Package for the test API model classes | `org.citrusframework.automation.%PREFIX%.%VERSION%.model`
-| `targetXmlnsNamespace` | `citrus.test.api.generator.namespace` | XML namespace used by the API | `http://www.citrusframework.org/schema/%VERSION%/%PREFIX%-api`
+| `targetXmlnsNamespace` | `citrus.test.api.generator.namespace` | XML namespace used by the API | `http://www.citrusframework.org/schema/%VERSION%/%PREFIX%-api`
|===
-
Note: `%PREFIX%` and `%VERSION%` are placeholders that will be replaced by their specific values as configured.
The plugin performs a conversion to lowercase for `PREFIX` used in package names and in `targetXmlnsNamespace`.
@@ -568,7 +567,6 @@ To run the generator, execute the following command in your project directory:
mvn citrus-test-api-generator-maven-plugin:create-test-api
----
-
This command will generate the classes and XSD files as configured for your APIs in the specified locations.
==== Spring meta file generation
@@ -683,8 +681,8 @@ Further examples can be found here `org.citrusframework.openapi.generator.Genera
----
To utilize the test API in Java, it's necessary to import the API configuration, that provides the respective request actions.
-The request to test can then be autowired, configured and autowired, as illustrated in the sample below.
-Further examples can be found here `org.citrusframework.openapi.generator.GetPetByIdTest`.
+The request to test can then be configured and autowired, as illustrated in the sample below.
+Further examples can be found here `org.citrusframework.openapi.generator.GetPetByIdIT`.
.Java DSL
[source,java,indent=0,role="secondary"]
diff --git a/test-api-generator/citrus-test-api-generator-core/pom.xml b/test-api-generator/citrus-test-api-generator-core/pom.xml
index c74f91249a..4681188d7e 100644
--- a/test-api-generator/citrus-test-api-generator-core/pom.xml
+++ b/test-api-generator/citrus-test-api-generator-core/pom.xml
@@ -18,7 +18,6 @@
Generates a Citrus Test-API for OpenAPI and WSDL specifications.
-
org.citrusframework
citrus-api
@@ -54,6 +53,7 @@
org.openapitools
openapi-generator
+ ${org.openapitools.version}
wsdl4j
@@ -67,18 +67,18 @@
${project.version}
test
-
- org.springframework.boot
- spring-boot-test
- ${spring.boot.test.version}
- test
-
org.citrusframework
citrus-validation-json
${project.version}
test
+
+ org.springframework.boot
+ spring-boot-test
+ ${spring.boot.version}
+ test
+
@@ -121,6 +121,7 @@
org.openapitools
openapi-generator-maven-plugin
+ ${org.openapitools.version}
org.citrusframework
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java b/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java
index a1c0de6e4c..d62d4c1a9d 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/JavaCitrusCodegen.java
@@ -16,6 +16,7 @@
package org.citrusframework.openapi.generator;
+import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toMap;
import static org.openapitools.codegen.CliOption.newString;
@@ -27,12 +28,16 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
+import lombok.Getter;
+import lombok.Setter;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@Getter
+@Setter
public class JavaCitrusCodegen extends AbstractJavaCodegen {
private static final Logger logger = LoggerFactory.getLogger(JavaCitrusCodegen.class);
@@ -68,6 +73,7 @@ public class JavaCitrusCodegen extends AbstractJavaCodegen {
public JavaCitrusCodegen() {
super();
+
// the root folder where all files are emitted
outputFolder = "generated-code" + File.separator + "java";
@@ -108,8 +114,9 @@ public JavaCitrusCodegen() {
);
setReservedWordsLowerCase(new ArrayList<>(reservedWordsTemp));
- // add posibility to set a new value for the properties
- cliOptions.add(newString(API_ENDPOINT,
+ // add possibility to set a new value for the properties
+ cliOptions.add(
+ newString(API_ENDPOINT,
"Which http client should be used (default " + httpClient + ")."));
cliOptions.add(
newString(
@@ -121,9 +128,11 @@ public JavaCitrusCodegen() {
newString(GENERATED_SCHEMA_FOLDER,
"The schema output directory (default " + generatedSchemaFolder + ").")
);
- cliOptions.add(newString(HTTP_PATH_PREFIX,
+ cliOptions.add(
+ newString(HTTP_PATH_PREFIX,
"Add a prefix to http path for all APIs (default " + httpPathPrefix + ")."));
- cliOptions.add(newString(OPENAPI_SCHEMA,
+ cliOptions.add(
+ newString(OPENAPI_SCHEMA,
"Which OpenAPI schema should be used (default " + openapiSchema + ")."));
cliOptions.add(
newString(
@@ -133,7 +142,8 @@ public JavaCitrusCodegen() {
)
);
cliOptions.add(newString(PREFIX, "The api prefix (default " + apiPrefix + ")."));
- cliOptions.add(newString(RESOURCE_FOLDER,
+ cliOptions.add(
+ newString(RESOURCE_FOLDER,
"Where the resource files are emitted (default " + resourceFolder + ")."));
cliOptions.add(
newString(TARGET_XMLNS_NAMESPACE,
@@ -184,8 +194,7 @@ public void processOpts() {
additionalProperties.put(API_ENDPOINT, httpClient);
if (additionalProperties.containsKey(GENERATED_SCHEMA_FOLDER)) {
- this.setGeneratedSchemaFolder(
- additionalProperties.get(GENERATED_SCHEMA_FOLDER).toString());
+ this.setGeneratedSchemaFolder(additionalProperties.get(GENERATED_SCHEMA_FOLDER).toString());
}
additionalProperties.put(GENERATED_SCHEMA_FOLDER, generatedSchemaFolder);
@@ -222,17 +231,14 @@ public void processOpts() {
additionalProperties.put(RESOURCE_FOLDER, resourceFolder);
if (additionalProperties.containsKey(TARGET_XMLNS_NAMESPACE)) {
- this.setTargetXmlnsNamespace(
- additionalProperties.get(TARGET_XMLNS_NAMESPACE).toString());
+ this.setTargetXmlnsNamespace(additionalProperties.get(TARGET_XMLNS_NAMESPACE).toString());
} else {
- this.targetXmlnsNamespace = String.format(
- "http://www.citrusframework.org/citrus-test-schema/%s-api", apiPrefix.toLowerCase());
+ this.targetXmlnsNamespace = format("http://www.citrusframework.org/citrus-test-schema/%s-api", apiPrefix.toLowerCase());
}
additionalProperties.put(TARGET_XMLNS_NAMESPACE, targetXmlnsNamespace);
// define different folders where the files will be emitted
- final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".",
- File.separator);
+ final String invokerFolder = (sourceFolder + File.separator + invokerPackage).replace(".", File.separator);
final String citrusFolder = invokerFolder + File.separator + "citrus";
final String extensionFolder = citrusFolder + File.separator + "extension";
final String springFolder = invokerFolder + File.separator + "spring";
@@ -244,7 +250,7 @@ public void processOpts() {
} else if (API_TYPE_SOAP.equals(apiType)) {
addSoapSupportingFiles(citrusFolder, schemaFolder);
} else {
- throw new IllegalArgumentException(String.format("Unknown API_TYPE: '%s'", apiType));
+ throw new IllegalArgumentException(format("Unknown API_TYPE: '%s'", apiType));
}
addDefaultSupportingFiles(citrusFolder, extensionFolder, springFolder);
@@ -260,74 +266,15 @@ public void preprocessOpenAPI(OpenAPI openAPI) {
additionalProperties.putAll(extensions);
Map infoExtensions = extensions.entrySet().stream()
- .filter(entry -> entry.getKey().toUpperCase(
- ).startsWith("X-"))
+ .filter(entry -> entry.getKey().toUpperCase().startsWith("X-"))
.collect(toMap(Entry::getKey, Entry::getValue));
additionalProperties.put("infoExtensions", infoExtensions);
}
}
- public void setApiPrefix(String apiPrefix) {
- this.apiPrefix = apiPrefix;
- }
-
- public String getHttpClient() {
- return httpClient;
- }
-
- public void setHttpClient(String httpClient) {
- this.httpClient = httpClient;
- }
-
- public String getHttpPathPrefix() {
- return httpPathPrefix;
- }
-
- public void setHttpPathPrefix(String httpPathPrefix) {
- this.httpPathPrefix = httpPathPrefix;
- }
-
- public String getOpenapiSchema() {
- return openapiSchema;
- }
-
- public void setOpenapiSchema(String openapiSchema) {
- this.openapiSchema = openapiSchema;
- }
-
- public String getResourceFolder() {
- return resourceFolder;
- }
-
- public void setResourceFolder(String resourceFolder) {
- this.resourceFolder = resourceFolder;
- }
-
- public String getGeneratedSchemaFolder() {
- return generatedSchemaFolder;
- }
-
- public void setGeneratedSchemaFolder(String generatedSchemaFolder) {
- this.generatedSchemaFolder = generatedSchemaFolder;
- }
-
- public String getTargetXmlnsNamespace() {
- return targetXmlnsNamespace;
- }
-
- public void setTargetXmlnsNamespace(String targetXmlnsNamespace) {
- this.targetXmlnsNamespace = targetXmlnsNamespace;
- }
-
- public String getApiPrefix() {
- return apiPrefix;
- }
-
private void addRestSupportingFiles(final String citrusFolder, String schemaFolder) {
- supportingFiles.add(new SupportingFile("schema.mustache", schemaFolder,
- apiPrefix.toLowerCase() + "-api.xsd"));
- supportingFiles.add(new SupportingFile("test_base.mustache", citrusFolder,
- apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
+ supportingFiles.add(new SupportingFile("schema.mustache", schemaFolder, apiPrefix.toLowerCase() + "-api.xsd"));
+ supportingFiles.add(new SupportingFile("test_base.mustache", citrusFolder, apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
}
private void addSoapSupportingFiles(final String citrusFolder, String schemaFolder) {
@@ -335,24 +282,15 @@ private void addSoapSupportingFiles(final String citrusFolder, String schemaFold
apiTemplateFiles().remove("api.mustache");
apiTemplateFiles().put("api_soap.mustache", ".java");
- supportingFiles.add(new SupportingFile("schema_soap.mustache", schemaFolder,
- apiPrefix.toLowerCase() + "-api.xsd"));
- supportingFiles.add(new SupportingFile("api_soap.mustache", citrusFolder,
- apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
- supportingFiles.add(new SupportingFile("test_base_soap.mustache", citrusFolder,
- apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
+ supportingFiles.add(new SupportingFile("schema_soap.mustache", schemaFolder, apiPrefix.toLowerCase() + "-api.xsd"));
+ supportingFiles.add(new SupportingFile("api_soap.mustache", citrusFolder, apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
+ supportingFiles.add(new SupportingFile("test_base_soap.mustache", citrusFolder, apiPrefix + ABSTRACT_TEST_REQUEST_JAVA));
}
- private void addDefaultSupportingFiles(final String citrusFolder, final String extensionFolder,
- final String springFolder) {
- supportingFiles.add(new SupportingFile("bean_configuration.mustache", springFolder,
- apiPrefix + "BeanConfiguration.java"));
- supportingFiles.add(new SupportingFile("bean_definition_parser.mustache", citrusFolder,
- apiPrefix + "BeanDefinitionParser.java"));
- supportingFiles.add(new SupportingFile("namespace_handler.mustache", extensionFolder,
- apiPrefix + "NamespaceHandler.java"));
- supportingFiles.add(new SupportingFile("api-model.mustache", resourceFolder,
- apiPrefix.toLowerCase() + "-api-model.csv"));
+ private void addDefaultSupportingFiles(final String citrusFolder, final String extensionFolder, final String springFolder) {
+ supportingFiles.add(new SupportingFile("bean_configuration.mustache", springFolder, apiPrefix + "BeanConfiguration.java"));
+ supportingFiles.add(new SupportingFile("bean_definition_parser.mustache", citrusFolder, apiPrefix + "BeanDefinitionParser.java"));
+ supportingFiles.add(new SupportingFile("namespace_handler.mustache", extensionFolder, apiPrefix + "NamespaceHandler.java"));
+ supportingFiles.add(new SupportingFile("api-model.mustache", resourceFolder, apiPrefix.toLowerCase() + "-api-model.csv"));
}
-
}
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/SimpleWsdlToOpenApiTransformer.java b/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/SimpleWsdlToOpenApiTransformer.java
index fc7487aff4..8243be5aa8 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/SimpleWsdlToOpenApiTransformer.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/java/org/citrusframework/openapi/generator/SimpleWsdlToOpenApiTransformer.java
@@ -86,9 +86,6 @@ public String transformToOpenApi() throws WsdlToOpenApiTransformationException {
/**
* Performs the actual transformation from bindings into OpenApi operations.
- *
- * @param bindings
- * @return
*/
private OpenAPI transformToOpenApi(Map, ?> bindings) {
OpenAPI openAPI = new OpenAPI();
@@ -100,10 +97,11 @@ private OpenAPI transformToOpenApi(Map, ?> bindings) {
Object key = entry.getKey();
Object value = entry.getValue();
- if (key instanceof QName && value instanceof Binding) {
- addOperations(openAPI, (QName) key, (Binding) value);
+ if (key instanceof QName qName && value instanceof Binding binding) {
+ addOperations(openAPI, qName, binding);
}
}
+
return openAPI;
}
@@ -138,6 +136,7 @@ private Info createInfo() {
Contact contact = new Contact();
contact.setName("org.citrusframework.openapi.generator.SimpleWsdlToOpenApiTransformer");
info.setContact(contact);
+
return info;
}
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache
index d384833fec..36d6186da8 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/api.mustache
@@ -52,7 +52,6 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class {{classname}} implements GeneratedApi
{
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache
index 3707465ce5..b6b205a521 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/bean_definition_parser.mustache
@@ -22,7 +22,6 @@
package {{invokerPackage}}.citrus;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,20 +30,17 @@ import java.util.regex.Pattern;
import javax.annotation.processing.Generated;
-import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.util.Assert;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class {{prefix}}BeanDefinitionParser implements BeanDefinitionParser {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache
index 5344d50a78..535f504b0b 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/namespace_handler.mustache
@@ -33,7 +33,6 @@ import javax.annotation.processing.Generated;
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class {{prefix}}NamespaceHandler extends NamespaceHandlerSupport {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache
index fbf2003a58..a3de4774fb 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache
+++ b/test-api-generator/citrus-test-api-generator-core/src/main/resources/java-citrus/test_base.mustache
@@ -22,7 +22,6 @@
package {{invokerPackage}}.citrus;
-
import static org.springframework.util.CollectionUtils.isEmpty;
import jakarta.annotation.Generated;
@@ -39,10 +38,10 @@ import org.citrusframework.http.actions.HttpClientRequestActionBuilder;
import org.citrusframework.http.actions.HttpClientResponseActionBuilder;
import org.citrusframework.http.actions.HttpClientResponseActionBuilder.HttpMessageBuilderSupport;
import org.citrusframework.http.client.HttpClient;
+import org.citrusframework.spi.Resources;
import org.citrusframework.message.Message;
import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
import org.citrusframework.testapi.GeneratedApi;
-import org.citrusframework.spi.Resources;
import org.citrusframework.validation.DelegatingPayloadVariableExtractor;
import org.citrusframework.validation.PathExpressionValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdTest.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdIT.java
similarity index 98%
rename from test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdTest.java
rename to test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdIT.java
index 6421cee946..72b9369ca3 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdTest.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/GetPetByIdIT.java
@@ -24,7 +24,7 @@
import org.citrusframework.message.Message;
import org.citrusframework.messaging.Producer;
import org.citrusframework.messaging.SelectiveConsumer;
-import org.citrusframework.openapi.generator.GetPetByIdTest.Config;
+import org.citrusframework.openapi.generator.GetPetByIdIT.Config;
import org.citrusframework.openapi.generator.rest.petstore.request.PetApi.GetPetByIdRequest;
import org.citrusframework.openapi.generator.rest.petstore.spring.PetStoreBeanConfiguration;
import org.citrusframework.spi.Resources;
@@ -40,7 +40,7 @@
@ExtendWith(CitrusSpringExtension.class)
@SpringBootTest(classes = {PetStoreBeanConfiguration.class, CitrusSpringConfig.class, Config.class})
-class GetPetByIdTest {
+class GetPetByIdIT {
@Autowired
private GetPetByIdRequest getPetByIdRequest;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenIT.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenIT.java
index dd4f52ece7..49230954ba 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenIT.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenIT.java
@@ -4,11 +4,9 @@
import java.io.File;
import java.io.IOException;
-import java.util.List;
import java.util.stream.Stream;
import org.apache.commons.lang3.stream.Streams;
import org.citrusframework.exceptions.CitrusRuntimeException;
-import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenTest.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenTest.java
index 57f49cd861..9c6874c5de 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenTest.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/JavaCitrusCodegenTest.java
@@ -5,6 +5,7 @@
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.HashMap;
@@ -32,6 +33,31 @@
class JavaCitrusCodegenTest {
+ /**
+ * Get the absolute path to the test resources directory.
+ *
+ * @param pathToFileInTestResources The file within {@code src/test/resources} to look for
+ * @return the absolute path to the file
+ */
+ private String getTestResource(String pathToFileInTestResources) {
+ URL resourceUrl = getClass().getClassLoader().getResource(pathToFileInTestResources);
+ assert resourceUrl != null;
+ File inputSpecFile = new File(resourceUrl.getFile());
+ return inputSpecFile.getAbsolutePath();
+ }
+
+ /**
+ * Get the absolute path to the project's target directory.
+ *
+ * @param pathToFileInTargetDirectory The file within {@code target} to look for
+ * @return the absolute path to the file
+ */
+ private static String getAbsoluteTargetDirectoryPath(String pathToFileInTargetDirectory) {
+ String projectBaseDir = System.getProperty("user.dir"); // Base directory of the project
+ File outputDirFile = new File(projectBaseDir, "target/" + pathToFileInTargetDirectory);
+ return outputDirFile.getAbsolutePath();
+ }
+
@Test
void retrieveGeneratorBsSpi() {
JavaCitrusCodegen codegen = (JavaCitrusCodegen) CodegenConfigLoader.forName("java-citrus");
@@ -83,10 +109,13 @@ void areAdditionalPropertiesProcessedTest() {
@Test
void areReservedWordsEscapedTest() throws IOException {
+ String absoluteInputSpecPath = getTestResource("apis/petstore_reservedWords.yaml");
+ String absoluteOutputDirPath = getAbsoluteTargetDirectoryPath("JavaCitrusCodegenTest/petstore_escapedWords");
+
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName(CODEGEN_NAME)
- .setInputSpec("src/test/resources/apis/petstore_reservedWords.yaml")
- .setOutputDir("target/JavaCitrusCodegenTest/petstore_escapedWords");
+ .setInputSpec(absoluteInputSpecPath)
+ .setOutputDir(absoluteOutputDirPath);
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
@@ -105,10 +134,13 @@ void areReservedWordsEscapedTest() throws IOException {
@Test
void arePathParamsFieldsPresent() throws IOException {
+ String absoluteInputSpecPath = getTestResource("apis/petstore.yaml");
+ String absoluteOutputDirPath = getAbsoluteTargetDirectoryPath("JavaCitrusCodegenTest/petstore");
+
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName(CODEGEN_NAME)
- .setInputSpec("src/test/resources/apis/petstore.yaml")
- .setOutputDir("target/JavaCitrusCodegenTest/petstore");
+ .setInputSpec(absoluteInputSpecPath)
+ .setOutputDir(absoluteOutputDirPath);
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
@@ -130,10 +162,13 @@ void arePathParamsFieldsPresent() throws IOException {
@Test
void areBasicAuthFieldsPresent() throws IOException {
+ String absoluteInputSpecPath = getTestResource("apis/petstore.yaml");
+ String absoluteOutputDirPath = getAbsoluteTargetDirectoryPath("JavaCitrusCodegenTest/petstore");
+
final CodegenConfigurator configurator = new CodegenConfigurator()
.setGeneratorName(CODEGEN_NAME)
- .setInputSpec("src/test/resources/apis/petstore.yaml")
- .setOutputDir("target/JavaCitrusCodegenTest/petstore");
+ .setInputSpec(absoluteInputSpecPath)
+ .setOutputDir(absoluteOutputDirPath);
final ClientOptInput clientOptInput = configurator.toClientOptInput();
DefaultGenerator generator = new DefaultGenerator();
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/ServiceLoaderTest.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/ServiceLoaderTest.java
index 6b17f01f13..419cea9ade 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/ServiceLoaderTest.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/ServiceLoaderTest.java
@@ -5,8 +5,8 @@
import java.util.List;
import java.util.ServiceLoader;
import java.util.ServiceLoader.Provider;
-import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
import org.citrusframework.openapi.generator.util.TestApiActionBuilderCustomizer;
+import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
import org.junit.jupiter.api.Test;
class ServiceLoaderTest {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/SpringBeanConfigurationIT.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/SpringBeanConfigurationIT.java
index 2f5dbf7179..15dfb85dc3 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/SpringBeanConfigurationIT.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/SpringBeanConfigurationIT.java
@@ -9,10 +9,10 @@
import org.citrusframework.http.client.HttpClient;
import org.citrusframework.http.client.HttpEndpointConfiguration;
import org.citrusframework.junit.jupiter.spring.CitrusSpringSupport;
+import org.citrusframework.openapi.generator.SpringBeanConfigurationIT.ClientConfiguration;
import org.citrusframework.openapi.generator.rest.petstore.request.PetApi.AddPetRequest;
import org.citrusframework.openapi.generator.rest.petstore.spring.PetStoreBeanConfiguration;
import org.junit.jupiter.api.Test;
-import org.citrusframework.openapi.generator.SpringBeanConfigurationIT.ClientConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.ApplicationContext;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/util/TestApiActionBuilderCustomizer.java b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/util/TestApiActionBuilderCustomizer.java
index 0aaa9761ab..1b0b8824a7 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/util/TestApiActionBuilderCustomizer.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/java/org/citrusframework/openapi/generator/util/TestApiActionBuilderCustomizer.java
@@ -1,7 +1,6 @@
package org.citrusframework.openapi.generator.util;
import org.citrusframework.TestAction;
-import org.citrusframework.TestActionBuilder;
import org.citrusframework.actions.SendMessageAction.SendMessageActionBuilder;
import org.citrusframework.context.TestContext;
import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/multiparttest-rest-resource.yaml b/test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/multiparttest-rest-resource.yaml
index b77b55c4d2..cfac634788 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/multiparttest-rest-resource.yaml
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/apis/multiparttest-rest-resource.yaml
@@ -7,9 +7,9 @@ info:
x-citrus-app: MPT
x-citrus-api-name: multiparttest-rest-resource
contact:
- name: IT-Services-CI TAuBE
- email: IT-Serv-CI-ETAdl@post.ch
- url: https://confluence.pnet.ch/pages/viewpage.action?pageId=314828825
+ name: Citrusframework Authors
+ email: citrus-dev@googlegroups.com
+ url: https://citrusframework.org
tags:
- name: multiparttest-controller
paths:
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestAbstractTestRequest.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestAbstractTestRequest.java
index 478a8e8742..01092606ba 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestAbstractTestRequest.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestAbstractTestRequest.java
@@ -22,7 +22,6 @@
package org.citrusframework.openapi.generator.rest.multiparttest.citrus;
-
import static org.springframework.util.CollectionUtils.isEmpty;
import jakarta.annotation.Generated;
@@ -39,10 +38,10 @@
import org.citrusframework.http.actions.HttpClientResponseActionBuilder;
import org.citrusframework.http.actions.HttpClientResponseActionBuilder.HttpMessageBuilderSupport;
import org.citrusframework.http.client.HttpClient;
+import org.citrusframework.spi.Resources;
import org.citrusframework.message.Message;
import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
import org.citrusframework.testapi.GeneratedApi;
-import org.citrusframework.spi.Resources;
import org.citrusframework.validation.DelegatingPayloadVariableExtractor;
import org.citrusframework.validation.PathExpressionValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestBeanDefinitionParser.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestBeanDefinitionParser.java
index 1ca5480c9e..37df5ee8b9 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestBeanDefinitionParser.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/MultipartTestBeanDefinitionParser.java
@@ -22,7 +22,6 @@
package org.citrusframework.openapi.generator.rest.multiparttest.citrus;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,20 +30,17 @@
import javax.annotation.processing.Generated;
-import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.util.Assert;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class MultipartTestBeanDefinitionParser implements BeanDefinitionParser {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/extension/MultipartTestNamespaceHandler.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/extension/MultipartTestNamespaceHandler.java
index 9f36ba2472..4517c7a801 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/extension/MultipartTestNamespaceHandler.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/citrus/extension/MultipartTestNamespaceHandler.java
@@ -29,7 +29,6 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class MultipartTestNamespaceHandler extends NamespaceHandlerSupport {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/request/MultiparttestControllerApi.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/request/MultiparttestControllerApi.java
index bde720eb16..7ced338bb8 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/request/MultiparttestControllerApi.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/multiparttest/request/MultiparttestControllerApi.java
@@ -52,7 +52,6 @@
import java.util.Map;
import java.util.stream.Collectors;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class MultiparttestControllerApi implements GeneratedApi
{
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreAbstractTestRequest.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreAbstractTestRequest.java
index 1e9282b44b..29a409ea85 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreAbstractTestRequest.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreAbstractTestRequest.java
@@ -22,7 +22,6 @@
package org.citrusframework.openapi.generator.rest.petstore.citrus;
-
import static org.springframework.util.CollectionUtils.isEmpty;
import jakarta.annotation.Generated;
@@ -39,10 +38,10 @@
import org.citrusframework.http.actions.HttpClientResponseActionBuilder;
import org.citrusframework.http.actions.HttpClientResponseActionBuilder.HttpMessageBuilderSupport;
import org.citrusframework.http.client.HttpClient;
+import org.citrusframework.spi.Resources;
import org.citrusframework.message.Message;
import org.citrusframework.testapi.ApiActionBuilderCustomizerService;
import org.citrusframework.testapi.GeneratedApi;
-import org.citrusframework.spi.Resources;
import org.citrusframework.validation.DelegatingPayloadVariableExtractor;
import org.citrusframework.validation.PathExpressionValidationContext;
import org.citrusframework.validation.json.JsonMessageValidationContext;
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreBeanDefinitionParser.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreBeanDefinitionParser.java
index b52f5b5f42..f7ee721e6c 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreBeanDefinitionParser.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/PetStoreBeanDefinitionParser.java
@@ -22,7 +22,6 @@
package org.citrusframework.openapi.generator.rest.petstore.citrus;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,20 +30,17 @@
import javax.annotation.processing.Generated;
-import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.util.Assert;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class PetStoreBeanDefinitionParser implements BeanDefinitionParser {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/extension/PetStoreNamespaceHandler.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/extension/PetStoreNamespaceHandler.java
index 84de90fb2c..b7bb6298c1 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/extension/PetStoreNamespaceHandler.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/citrus/extension/PetStoreNamespaceHandler.java
@@ -31,7 +31,6 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class PetStoreNamespaceHandler extends NamespaceHandlerSupport {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/PetApi.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/PetApi.java
index 0eb28542e6..570912da01 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/PetApi.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/PetApi.java
@@ -52,7 +52,6 @@
import java.util.Map;
import java.util.stream.Collectors;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class PetApi implements GeneratedApi
{
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/StoreApi.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/StoreApi.java
index e8062b4fb0..b7d6754a4f 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/StoreApi.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/StoreApi.java
@@ -52,7 +52,6 @@
import java.util.Map;
import java.util.stream.Collectors;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class StoreApi implements GeneratedApi
{
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/UserApi.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/UserApi.java
index d52e4351f1..7c89b95787 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/UserApi.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/rest/petstore/request/UserApi.java
@@ -52,7 +52,6 @@
import java.util.Map;
import java.util.stream.Collectors;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class UserApi implements GeneratedApi
{
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/OpenApiFromWsdlBeanDefinitionParser.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/OpenApiFromWsdlBeanDefinitionParser.java
index e59e1bc033..6bb955eb0b 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/OpenApiFromWsdlBeanDefinitionParser.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/OpenApiFromWsdlBeanDefinitionParser.java
@@ -22,7 +22,6 @@
package org.citrusframework.openapi.generator.soap.bookservice.citrus;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -31,20 +30,17 @@
import javax.annotation.processing.Generated;
-import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.BeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.springframework.core.Conventions;
import org.springframework.util.Assert;
-import org.apache.commons.lang3.StringUtils;
import org.springframework.util.xml.DomUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class OpenApiFromWsdlBeanDefinitionParser implements BeanDefinitionParser {
diff --git a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/extension/OpenApiFromWsdlNamespaceHandler.java b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/extension/OpenApiFromWsdlNamespaceHandler.java
index b844e884ca..9c2f110274 100644
--- a/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/extension/OpenApiFromWsdlNamespaceHandler.java
+++ b/test-api-generator/citrus-test-api-generator-core/src/test/resources/org/citrusframework/openapi/generator/JavaCitrusCodegenIntegrationTest/expectedgen/soap/bookservice/citrus/extension/OpenApiFromWsdlNamespaceHandler.java
@@ -29,7 +29,6 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
-
@Generated(value = "org.citrusframework.openapi.generator.JavaCitrusCodegen")
public class OpenApiFromWsdlNamespaceHandler extends NamespaceHandlerSupport {
diff --git a/test-api-generator/citrus-test-api-generator-maven-plugin/pom.xml b/test-api-generator/citrus-test-api-generator-maven-plugin/pom.xml
index e92fd84d94..134d44aee9 100644
--- a/test-api-generator/citrus-test-api-generator-maven-plugin/pom.xml
+++ b/test-api-generator/citrus-test-api-generator-maven-plugin/pom.xml
@@ -36,13 +36,18 @@
-
org.citrusframework
citrus-test-api-generator-core
${project.version}
+
+ org.openapitools
+ openapi-generator-maven-plugin
+ ${org.openapitools.version}
+
+
commons-io
commons-io
diff --git a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/CodeGenMojoWrapper.java b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/CodeGenMojoWrapper.java
index 513f9ace80..5b1d088727 100644
--- a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/CodeGenMojoWrapper.java
+++ b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/CodeGenMojoWrapper.java
@@ -16,16 +16,16 @@
package org.citrusframework.maven.plugin;
-import static org.citrusframework.openapi.generator.JavaCitrusCodegen.CODEGEN_NAME;
import static java.lang.String.format;
+import static org.citrusframework.openapi.generator.JavaCitrusCodegen.CODEGEN_NAME;
-import org.citrusframework.openapi.generator.JavaCitrusCodegen;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
+import org.citrusframework.openapi.generator.JavaCitrusCodegen;
import org.openapitools.codegen.plugin.CodeGenMojo;
/**
@@ -96,5 +96,4 @@ private void setPrivateField(String fieldName, Object fieldValue) throws MojoExe
format("Could not reflectively set field value '%s' for field '%s'", fieldValue, fieldName));
}
}
-
}
diff --git a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/SpringMetaFileGenerator.java b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/SpringMetaFileGenerator.java
index 2e1cdd2e0f..1d1f475bee 100644
--- a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/SpringMetaFileGenerator.java
+++ b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/SpringMetaFileGenerator.java
@@ -19,7 +19,6 @@
import static java.lang.String.format;
import static java.util.Collections.emptyList;
-import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiConfig;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
@@ -30,6 +29,7 @@
import java.util.function.BiConsumer;
import org.apache.maven.plugin.MojoExecutionException;
import org.citrusframework.exceptions.CitrusRuntimeException;
+import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiConfig;
/**
* Utility class responsible for generating the Spring meta files 'spring.handlers' and 'spring.schemas', used
@@ -52,9 +52,7 @@ public SpringMetaFileGenerator(TestApiGeneratorMojo testApiGeneratorMojo) {
}
public void generateSpringIntegrationMetaFiles() throws MojoExecutionException {
-
- String springMetafileDirectory = format("%s/%s", testApiGeneratorMojo.getMavenProject().getBasedir(),
- testApiGeneratorMojo.metaInfFolder());
+ String springMetafileDirectory = format("%s/%s", testApiGeneratorMojo.getMavenProject().getBasedir(), testApiGeneratorMojo.metaInfFolder());
File metaFolder = new File(springMetafileDirectory);
if (!metaFolder.exists() && !metaFolder.mkdirs()) {
throw new CitrusRuntimeException(
@@ -70,7 +68,6 @@ public void generateSpringIntegrationMetaFiles() throws MojoExecutionException {
}
private void writeSpringSchemaMetaFile(File springMetafileDirectory) throws MojoExecutionException {
-
String filename = "spring.schemas";
writeSpringMetaFile(springMetafileDirectory, filename, (fileWriter, apiConfig) -> {
String targetXmlnsNamespace = TestApiGeneratorMojo.replaceDynamicVarsToLowerCase(apiConfig.getTargetXmlnsNamespace(), apiConfig.getPrefix(),
@@ -94,14 +91,11 @@ private void writeSpringHandlerMetaFile(File springMetafileDirectory) throws Moj
});
}
- private void writeSpringMetaFile(File springMetafileDirectory, String filename, BiConsumer contentFormatter)
- throws MojoExecutionException {
-
+ private void writeSpringMetaFile(File springMetafileDirectory, String filename, BiConsumer contentFormatter) throws MojoExecutionException {
File handlerFile = new File(format("%s/%s", springMetafileDirectory.getPath(), filename));
List filteredLines = readAndFilterLines(handlerFile);
try (FileWriter fileWriter = new FileWriter(handlerFile)) {
-
for (String line : filteredLines) {
fileWriter.write(format("%s%n", line));
}
@@ -109,7 +103,6 @@ private void writeSpringMetaFile(File springMetafileDirectory, String filename,
for (ApiConfig apiConfig : testApiGeneratorMojo.getApiConfigs()) {
contentFormatter.accept(fileWriter, apiConfig);
}
-
} catch (IOException e) {
throw new MojoExecutionException("Unable to write spring meta file!", e);
}
@@ -133,7 +126,6 @@ private void writeSpringMetaFile(File springMetafileDirectory, String filename,
* @throws CitrusRuntimeException if an error occurs while reading the file
*/
private static List readAndFilterLines(File file) {
-
if (!file.exists()) {
return emptyList();
}
diff --git a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/TestApiGeneratorMojo.java b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/TestApiGeneratorMojo.java
index aeee254011..d37b4d8ffe 100644
--- a/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/TestApiGeneratorMojo.java
+++ b/test-api-generator/citrus-test-api-generator-maven-plugin/src/main/java/org/citrusframework/maven/plugin/TestApiGeneratorMojo.java
@@ -16,18 +16,20 @@
package org.citrusframework.maven.plugin;
+import static java.lang.String.format;
+import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.citrusframework.openapi.generator.JavaCitrusCodegen.API_ENDPOINT;
import static org.citrusframework.openapi.generator.JavaCitrusCodegen.API_TYPE;
import static org.citrusframework.openapi.generator.JavaCitrusCodegen.PREFIX;
import static org.citrusframework.openapi.generator.JavaCitrusCodegen.TARGET_XMLNS_NAMESPACE;
-import static java.lang.String.format;
-import static org.apache.commons.lang3.StringUtils.isBlank;
import com.google.common.annotations.VisibleForTesting;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
@@ -66,8 +68,8 @@ public class TestApiGeneratorMojo extends AbstractMojo {
public static final String DEFAULT_RESOURCE_FOLDER = "generated-test-resources";
public static final String DEFAULT_BASE_PACKAGE = "org.citrusframework.automation.%PREFIX%.%VERSION%";
public static final String DEFAULT_INVOKER_PACKAGE = DEFAULT_BASE_PACKAGE;
- public static final String DEFAULT_API_PACKAGE = DEFAULT_BASE_PACKAGE+".api";
- public static final String DEFAULT_MODEL_PACKAGE = DEFAULT_BASE_PACKAGE+".model";
+ public static final String DEFAULT_API_PACKAGE = DEFAULT_BASE_PACKAGE + ".api";
+ public static final String DEFAULT_MODEL_PACKAGE = DEFAULT_BASE_PACKAGE + ".model";
public static final String DEFAULT_SCHEMA_FOLDER_TEMPLATE = "schema/xsd/%VERSION%";
public static final ApiType DEFAULT_API_TYPE = ApiType.REST;
@@ -173,7 +175,6 @@ public String schemaFolder(ApiConfig apiConfig) {
@Override
public void execute() throws MojoExecutionException {
-
for (int index = 0; index < apis.size(); index++) {
ApiConfig apiConfig = apis.get(index);
validateApiConfig(index, apiConfig);
@@ -199,6 +200,7 @@ CodeGenMojo configureCodeGenMojo(ApiConfig apiConfig) throws MojoExecutionExcept
codeGenMojo.setPluginContext(getPluginContext());
codeGenMojo.setBuildContext(buildContext);
+
return codeGenMojo;
}
@@ -217,7 +219,6 @@ private void requireNonBlankParameter(String name, int index, String parameterVa
* Replace the placeholders '%PREFIX%' and '%VERSION%' in the given text.
*/
static String replaceDynamicVars(String text, String prefix, String version) {
-
if (text == null) {
return null;
}
@@ -244,6 +245,8 @@ public enum ApiType {
* Note that the default values are not properly set by maven processor. Therefore, the default values have been assigned additionally
* on field level.
*/
+ @Getter
+ @Setter
public static class ApiConfig {
public static final String DEFAULT_ENDPOINT = "PREFIX_ENDPOINT";
@@ -324,83 +327,10 @@ public static class ApiConfig {
@Parameter(property = API_NAMESPACE_PROPERTY, defaultValue = DEFAULT_TARGET_NAMESPACE_TEMPLATE)
private String targetXmlnsNamespace = DEFAULT_TARGET_NAMESPACE_TEMPLATE;
-
- public String getPrefix() {
- return prefix;
- }
-
- public void setPrefix(String prefix) {
- this.prefix = prefix;
- }
-
- public String getSource() {
- return source;
- }
-
- public void setSource(String source) {
- this.source = source;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
public String qualifiedEndpoint() {
return DEFAULT_ENDPOINT.equals(endpoint) ? getPrefix().toLowerCase() + "Endpoint" : endpoint;
}
- public void setEndpoint(String endpoint) {
- this.endpoint = endpoint;
- }
-
- public ApiType getType() {
- return type;
- }
-
- public void setType(ApiType type) {
- this.type = type;
- }
-
- public void setUseTags(boolean useTags) {
- this.useTags = useTags;
- }
-
- public String getInvokerPackage() {
- return invokerPackage;
- }
-
- public void setInvokerPackage(String invokerPackage) {
- this.invokerPackage = invokerPackage;
- }
-
- public String getApiPackage() {
- return apiPackage;
- }
-
- public void setApiPackage(String apiPackage) {
- this.apiPackage = apiPackage;
- }
-
- public String getModelPackage() {
- return modelPackage;
- }
-
- public void setModelPackage(String modelPackage) {
- this.modelPackage = modelPackage;
- }
-
- public String getTargetXmlnsNamespace() {
- return targetXmlnsNamespace;
- }
-
- public void setTargetXmlnsNamespace(String targetXmlnsNamespace) {
- this.targetXmlnsNamespace = targetXmlnsNamespace;
- }
-
Map toConfigOptionsProperties() {
Map configOptionsProperties = new HashMap<>();
@@ -419,8 +349,5 @@ Map toConfigOptionsProperties() {
return configOptionsProperties;
}
-
}
-
-
}
diff --git a/test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoUnitTest.java b/test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoUnitTest.java
index 1bb8781631..8309b94dcb 100644
--- a/test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoUnitTest.java
+++ b/test-api-generator/citrus-test-api-generator-maven-plugin/src/test/java/org/citrusframework/maven/plugin/TestApiGeneratorMojoUnitTest.java
@@ -1,5 +1,7 @@
package org.citrusframework.maven.plugin;
+import static java.lang.Boolean.TRUE;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.DEFAULT_API_PACKAGE;
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.DEFAULT_API_TYPE;
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.DEFAULT_INVOKER_PACKAGE;
@@ -11,16 +13,11 @@
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.DEFAULT_TARGET_NAMESPACE_TEMPLATE;
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.replaceDynamicVars;
import static org.citrusframework.maven.plugin.TestApiGeneratorMojo.replaceDynamicVarsToLowerCase;
-import static java.lang.Boolean.TRUE;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.Mockito.doReturn;
import static org.springframework.test.util.ReflectionTestUtils.getField;
import jakarta.validation.constraints.NotNull;
-import org.citrusframework.maven.plugin.TestApiGeneratorMojo;
-import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiConfig;
-import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiType;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@@ -30,6 +27,8 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
+import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiConfig;
+import org.citrusframework.maven.plugin.TestApiGeneratorMojo.ApiType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
diff --git a/test-api-generator/pom.xml b/test-api-generator/pom.xml
index f6298e3e11..b33d0f717e 100644
--- a/test-api-generator/pom.xml
+++ b/test-api-generator/pom.xml
@@ -19,19 +19,64 @@
true
+
+ citrus-test-api-generator-core
+ citrus-test-api-generator-maven-plugin
+
+
org.junit.jupiter
junit-jupiter-engine
- ${junit.jupiter.version}
+ ${junit.jupiter.version}
+ test
+
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ ${junit.jupiter.version}
test
-
- citrus-test-api-generator-core
- citrus-test-api-generator-maven-plugin
-
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+
+ *IntegrationTest.java
+ *IT.java
+
+
+
+
+ org.apache.maven.surefire
+ surefire-junit-platform
+ ${maven.surefire.plugin.version}
+
+
+
+
+ org.apache.maven.plugins
+ maven-failsafe-plugin
+
+
+ *IntegrationTest.java
+ *IT.java
+
+
+
+
+ org.apache.maven.surefire
+ surefire-junit-platform
+ ${maven.surefire.plugin.version}
+
+
+
+
+
-