diff --git a/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml b/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml
index c02f3ef16..fd969cb4f 100644
--- a/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml
+++ b/datamodel/odata-v4/odata-v4-generator-maven-plugin/pom.xml
@@ -68,12 +68,6 @@
junit-jupiter-api
test
-
- junit
- junit
- 4.13.2
- test
-
org.assertj
assertj-core
diff --git a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojoTest.java b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojoTest.java
index 0bb355589..f15be6ab9 100644
--- a/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojoTest.java
+++ b/datamodel/odata-v4/odata-v4-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odatav4/generator/DataModelGeneratorMojoTest.java
@@ -1,27 +1,25 @@
package com.sap.cloud.sdk.datamodel.odatav4.generator;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
-import java.io.File;
-import java.net.URL;
-
-import org.apache.maven.plugin.testing.MojoRule;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.junit.jupiter.api.Test;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import com.sap.cloud.sdk.datamodel.odata.utility.NameSource;
import com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy;
import com.sap.cloud.sdk.datamodel.odatav4.generator.annotation.DefaultAnnotationStrategy;
+@MojoTest
class DataModelGeneratorMojoTest
{
+ private static final String TEST_POM = "src/test/resources/DataModelGeneratorMojoTest/pom.xml";
+
@Test
- void test()
+ @InjectMojo( goal = "generate", pom = TEST_POM )
+ void test( DataModelGeneratorMojo mojo )
throws Throwable
{
- final DataModelGeneratorMojo mojo = loadTestProject();
final DataModelGenerator generator = mojo.getDataModelGenerator();
assertSoftly(softly -> {
@@ -51,28 +49,4 @@ void test()
softly.assertThat(generator.isServiceMethodsPerEntitySet()).isTrue();
});
}
-
- private DataModelGeneratorMojo loadTestProject()
- throws Throwable
- {
- final URL resource = getClass().getClassLoader().getResource(getClass().getSimpleName());
- assertThat(resource).isNotNull();
-
- final File pomFile = new File(resource.getFile());
-
- final MojoRule rule = new MojoRule();
- // hacky workaround to invoke the internal call to "testCase.setUp()" inside MojoRule
- // exploiting the fact that the setup is not teared down after "evaluate" returns
- // this workaround is applied because "lookupConfiguredMojo" is not available on AbstractMojoTestCase
- // and this way we can skip the effort to re-implement what is already available in MojoRule
- rule.apply(new Statement()
- {
- @Override
- public void evaluate()
- {
-
- }
- }, Description.createSuiteDescription("dummy")).evaluate();
- return (DataModelGeneratorMojo) rule.lookupConfiguredMojo(pomFile, "generate");
- }
}
diff --git a/datamodel/odata/odata-generator-maven-plugin/pom.xml b/datamodel/odata/odata-generator-maven-plugin/pom.xml
index 92946d733..a1bb85de1 100644
--- a/datamodel/odata/odata-generator-maven-plugin/pom.xml
+++ b/datamodel/odata/odata-generator-maven-plugin/pom.xml
@@ -69,12 +69,6 @@
test
-
- junit
- junit
- 4.13.2
- test
-
org.assertj
assertj-core
diff --git a/datamodel/odata/odata-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odata/generator/DataModelGeneratorMojoTest.java b/datamodel/odata/odata-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odata/generator/DataModelGeneratorMojoTest.java
index 354275c52..8811244b0 100644
--- a/datamodel/odata/odata-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odata/generator/DataModelGeneratorMojoTest.java
+++ b/datamodel/odata/odata-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/odata/generator/DataModelGeneratorMojoTest.java
@@ -1,27 +1,24 @@
package com.sap.cloud.sdk.datamodel.odata.generator;
-import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;
-import java.io.File;
-import java.net.URL;
-
-import org.apache.maven.plugin.testing.MojoRule;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.junit.jupiter.api.Test;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import com.sap.cloud.sdk.datamodel.odata.generator.annotation.DefaultAnnotationStrategy;
import com.sap.cloud.sdk.datamodel.odata.utility.NameSource;
import com.sap.cloud.sdk.datamodel.odata.utility.S4HanaNamingStrategy;
+@MojoTest
class DataModelGeneratorMojoTest
{
+ private static final String TEST_POM = "src/test/resources/DataModelGeneratorMojoTest/pom.xml";
+
@Test
- void test()
- throws Throwable
+ @InjectMojo( goal = "generate", pom = TEST_POM )
+ void test( DataModelGeneratorMojo mojo )
{
- final DataModelGeneratorMojo mojo = loadTestProject();
final DataModelGenerator generator = mojo.getDataModelGenerator();
assertSoftly(softly -> {
@@ -51,28 +48,4 @@ void test()
softly.assertThat(generator.isServiceMethodsPerEntitySet()).isTrue();
});
}
-
- private DataModelGeneratorMojo loadTestProject()
- throws Throwable
- {
- final URL resource = getClass().getClassLoader().getResource(getClass().getSimpleName());
- assertThat(resource).isNotNull();
-
- final File pomFile = new File(resource.getFile());
-
- final MojoRule rule = new MojoRule();
- // hacky workaround to invoke the internal call to "testCase.setUp()" inside MojoRule
- // exploiting the fact that the setup is not teared down after "evaluate" returns
- // this workaround is applied because "lookupConfiguredMojo" is not available on AbstractMojoTestCase
- // and this way we can skip the effort to re-implement what is already available in MojoRule
- rule.apply(new Statement()
- {
- @Override
- public void evaluate()
- {
-
- }
- }, Description.createSuiteDescription("dummy")).evaluate();
- return (DataModelGeneratorMojo) rule.lookupConfiguredMojo(pomFile, "generate");
- }
}
diff --git a/datamodel/openapi/openapi-generator-maven-plugin/pom.xml b/datamodel/openapi/openapi-generator-maven-plugin/pom.xml
index 1d9d21759..44dae3e82 100644
--- a/datamodel/openapi/openapi-generator-maven-plugin/pom.xml
+++ b/datamodel/openapi/openapi-generator-maven-plugin/pom.xml
@@ -68,13 +68,6 @@
junit-jupiter-api
test
-
-
- junit
- junit
- 4.13.2
- test
-
org.assertj
assertj-core
diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoIntegrationTest.java b/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoIntegrationTest.java
index 82dea91ec..113ebfe24 100644
--- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoIntegrationTest.java
+++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoIntegrationTest.java
@@ -3,17 +3,15 @@
import static org.assertj.core.api.Assertions.assertThat;
import java.io.File;
-import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.function.Predicate;
-import org.apache.maven.plugin.testing.MojoRule;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import com.sap.cloud.sdk.datamodel.openapi.generator.model.ApiMaturity;
import com.sap.cloud.sdk.datamodel.openapi.generator.model.GenerationConfiguration;
@@ -25,22 +23,26 @@
* module. However, it was found that the OpenAPI generator behaves strange when it comes to accessing the templates as
* resources on the classpath. This issue was not caught in the {@code DataModelGeneratorIntegrationTest}.
*/
+@MojoTest
class DataModelGeneratorMojoIntegrationTest
{
- @TempDir
- File outputDirectory;
-
+ private static final String TEST_POM =
+ "src/test/resources/DataModelGeneratorMojoIntegrationTest/sodastore/input/pom.xml";
private static final String FOLDER_WITH_EXPECTED_CONTENT =
"src/test/resources/" + DataModelGeneratorMojoIntegrationTest.class.getSimpleName() + "/sodastore/output";
+ @TempDir
+ File outputDirectory;
+
@Test
- void generateAndCompareSodastoreLibrary()
+ @InjectMojo( goal = "generate", pom = TEST_POM )
+ void generateAndCompareSodastoreLibrary( DataModelGeneratorMojo mojo )
throws Throwable
{
final String outputFolderWithActualContent =
Paths.get(outputDirectory.getAbsolutePath()).resolve("output").toString();
- generateSodastoreLibrary(outputFolderWithActualContent);
+ generateSodastoreLibrary(mojo, outputFolderWithActualContent);
assertThatDirectoriesHaveSameContent(
Paths.get(FOLDER_WITH_EXPECTED_CONTENT),
@@ -49,17 +51,16 @@ void generateAndCompareSodastoreLibrary()
// Run this test method manually to overwrite the folder containing the expected content with the latest generator state
// @Test
- void regenerateExpectedSodastoreLibrary()
+ @InjectMojo( goal = "generate", pom = TEST_POM )
+ void regenerateExpectedSodastoreLibrary( DataModelGeneratorMojo mojo )
throws Throwable
{
- generateSodastoreLibrary(FOLDER_WITH_EXPECTED_CONTENT);
+ generateSodastoreLibrary(mojo, FOLDER_WITH_EXPECTED_CONTENT);
}
- private void generateSodastoreLibrary( final String outputDirectory )
+ private void generateSodastoreLibrary( DataModelGeneratorMojo mojo, final String outputDirectory )
throws Throwable
{
- final DataModelGeneratorMojo mojo = loadTestProject();
-
final GenerationConfiguration configuration = mojo.retrieveGenerationConfiguration().get();
assertThat(configuration.getApiMaturity()).isEqualTo(ApiMaturity.RELEASED);
@@ -84,28 +85,4 @@ private static void assertThatDirectoriesHaveSameContent( final Path a, final Pa
Files.walk(a).filter(isFile).forEach(p -> assertThat(p).hasSameTextualContentAs(b.resolve(a.relativize(p))));
Files.walk(b).filter(isFile).forEach(p -> assertThat(p).hasSameTextualContentAs(a.resolve(b.relativize(p))));
}
-
- private DataModelGeneratorMojo loadTestProject()
- throws Throwable
- {
- final URL resource = getClass().getClassLoader().getResource(getClass().getSimpleName() + "/sodastore/input");
- assertThat(resource).isNotNull();
-
- final File pomFile = new File(resource.getFile());
-
- final MojoRule rule = new MojoRule();
- // hacky workaround to invoke the internal call to "testCase.setUp()" inside MojoRule
- // exploiting the fact that the setup is not teared down after "evaluate" returns
- // this workaround is applied because "lookupConfiguredMojo" is not available on AbstractMojoTestCase
- // and this way we can skip the effort to re-implement what is already available in MojoRule
- rule.apply(new Statement()
- {
- @Override
- public void evaluate()
- {
-
- }
- }, Description.createSuiteDescription("dummy")).evaluate();
- return (DataModelGeneratorMojo) rule.lookupConfiguredMojo(pomFile, "generate");
- }
}
diff --git a/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoUnitTest.java b/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoUnitTest.java
index 7e66ca37c..aa632f7a6 100644
--- a/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoUnitTest.java
+++ b/datamodel/openapi/openapi-generator-maven-plugin/src/test/java/com/sap/cloud/sdk/datamodel/openapi/generator/DataModelGeneratorMojoUnitTest.java
@@ -4,14 +4,12 @@
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import java.io.File;
-import java.net.URL;
+import org.apache.maven.api.plugin.testing.InjectMojo;
+import org.apache.maven.api.plugin.testing.MojoTest;
import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.testing.MojoRule;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import com.sap.cloud.sdk.datamodel.openapi.generator.exception.OpenApiGeneratorException;
import com.sap.cloud.sdk.datamodel.openapi.generator.model.ApiMaturity;
@@ -19,20 +17,29 @@
import io.vavr.control.Try;
+@MojoTest
class DataModelGeneratorMojoUnitTest
{
+ private static final String RESOURCE_PATH = "src/test/resources/DataModelGeneratorMojoUnitTest";
+ private static final String ALL_PARAMETERS_POM = RESOURCE_PATH + "/testInvocationWithAllParameters/pom.xml";
+ private static final String MANDATORY_PARAMETERS_POM =
+ RESOURCE_PATH + "/testInvocationWithMandatoryParameters/pom.xml";
+ private static final String EMPTY_REQUIRED_PARAMETER_POM = RESOURCE_PATH + "/testEmptyRequiredParameter/pom.xml";
+ private static final String SKIP_EXECUTION_POM = RESOURCE_PATH + "/testSkipExecution/pom.xml";
+ private static final String UNEXPECTED_API_MATURITY_POM =
+ RESOURCE_PATH + "/testInvocationWithUnexpectedApiMaturity/pom.xml";
+ private static final String ADDITIONAL_PROPERTIES_POM =
+ RESOURCE_PATH + "/testAdditionalPropertiesAndEnablingAnyOfOneOf/pom.xml";
+
@TempDir
File outputDirectory;
- private DataModelGeneratorMojo sut;
-
@Test
- void testInvocationWithAllParameters()
+ @InjectMojo( goal = "generate", pom = ALL_PARAMETERS_POM )
+ void testInvocationWithAllParameters( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testInvocationWithAllParameters");
-
- final GenerationConfiguration configuration = sut.retrieveGenerationConfiguration().get();
+ final GenerationConfiguration configuration = mojo.retrieveGenerationConfiguration().get();
assertThat(configuration.getApiMaturity()).isEqualTo(ApiMaturity.RELEASED);
assertThat(configuration.isVerbose()).isTrue();
@@ -44,18 +51,17 @@ void testInvocationWithAllParameters()
assertThat(configuration.deleteOutputDirectory()).isTrue();
assertThat(configuration.isOneOfAnyOfGenerationEnabled()).isFalse();
- sut.setOutputDirectory(outputDirectory.getAbsolutePath());
+ mojo.setOutputDirectory(outputDirectory.getAbsolutePath());
- sut.execute();
+ mojo.execute();
}
@Test
- void testInvocationWithMandatoryParameters()
+ @InjectMojo( goal = "generate", pom = MANDATORY_PARAMETERS_POM )
+ void testInvocationWithMandatoryParameters( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testInvocationWithMandatoryParameters");
-
- final GenerationConfiguration configuration = sut.retrieveGenerationConfiguration().get();
+ final GenerationConfiguration configuration = mojo.retrieveGenerationConfiguration().get();
assertThat(configuration.getApiMaturity()).isEqualTo(ApiMaturity.RELEASED);
assertThat(configuration.isVerbose()).isFalse();
@@ -66,18 +72,17 @@ void testInvocationWithMandatoryParameters()
assertThat(configuration.getApiPackage()).isEqualTo("com.sap.cloud.sdk.datamodel.rest.test.api");
assertThat(configuration.deleteOutputDirectory()).isFalse();
- sut.setOutputDirectory(outputDirectory.getAbsolutePath());
+ mojo.setOutputDirectory(outputDirectory.getAbsolutePath());
- sut.execute();
+ mojo.execute();
}
@Test
- void testEmptyRequiredParameter()
+ @InjectMojo( goal = "generate", pom = EMPTY_REQUIRED_PARAMETER_POM )
+ void testEmptyRequiredParameter( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testEmptyRequiredParameter");
-
- final Try mojoExecutionTry = Try.run(sut::execute);
+ final Try mojoExecutionTry = Try.run(mojo::execute);
assertThat(mojoExecutionTry.isFailure()).isTrue();
@@ -91,61 +96,34 @@ void testEmptyRequiredParameter()
}
@Test
- void testSkipExecution()
+ @InjectMojo( goal = "generate", pom = SKIP_EXECUTION_POM )
+ void testSkipExecution( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testSkipExecution");
-
- sut.execute();
+ mojo.execute();
//no reasonable assertion possible
}
@Test
- void testInvocationWithUnexpectedApiMaturity()
+ @InjectMojo( goal = "generate", pom = UNEXPECTED_API_MATURITY_POM )
+ void testInvocationWithUnexpectedApiMaturity( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testInvocationWithUnexpectedApiMaturity");
-
assertThatExceptionOfType(MojoExecutionException.class)
- .isThrownBy(sut::execute)
+ .isThrownBy(mojo::execute)
.withCauseInstanceOf(IllegalArgumentException.class);
}
@Test
- void testAdditionalPropertiesAndEnablingAnyOfOneOf()
+ @InjectMojo( goal = "generate", pom = ADDITIONAL_PROPERTIES_POM )
+ void testAdditionalPropertiesAndEnablingAnyOfOneOf( DataModelGeneratorMojo mojo )
throws Throwable
{
- sut = loadTestProject("/testAdditionalPropertiesAndEnablingAnyOfOneOf");
-
- assertThat(sut.retrieveGenerationConfiguration().get().getAdditionalProperties())
+ assertThat(mojo.retrieveGenerationConfiguration().get().getAdditionalProperties())
.containsEntry("param1", "val1")
.containsEntry("param2", "val2")
.containsEntry("useAbstractionForFiles", "true");
- assertThat(sut.retrieveGenerationConfiguration().get().isOneOfAnyOfGenerationEnabled()).isTrue();
- }
-
- private DataModelGeneratorMojo loadTestProject( String testDir )
- throws Throwable
- {
- final URL resource = getClass().getClassLoader().getResource(getClass().getSimpleName() + testDir);
- assertThat(resource).isNotNull();
-
- final File pomFile = new File(resource.getFile());
-
- final MojoRule rule = new MojoRule();
- // hacky workaround to invoke the internal call to "testCase.setUp()" inside MojoRule
- // exploiting the fact that the setup is not teared down after "evaluate" returns
- // this workaround is applied because "lookupConfiguredMojo" is not available on AbstractMojoTestCase
- // and this way we can skip the effort to re-implement what is already available in MojoRule
- rule.apply(new Statement()
- {
- @Override
- public void evaluate()
- {
-
- }
- }, Description.createSuiteDescription("dummy")).evaluate();
- return (DataModelGeneratorMojo) rule.lookupConfiguredMojo(pomFile, "generate");
+ assertThat(mojo.retrieveGenerationConfiguration().get().isOneOfAnyOfGenerationEnabled()).isTrue();
}
}
diff --git a/pom.xml b/pom.xml
index c5892f113..14b7dd6ec 100644
--- a/pom.xml
+++ b/pom.xml
@@ -111,9 +111,9 @@
2.0.13
3.9.11
3.15.2
- 3.3.0
+ 3.4.0
3.2.3
- 7.16.0
+ 7.17.0
2.2.40
2.1.35
1.6.11