You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kh...@apache.org on 2022/04/15 15:12:53 UTC
[maven] 01/01: [MNG-7273] - Modeltest - Improvements
This is an automated email from the ASF dual-hosted git repository.
khmarbaise pushed a commit to branch MNG-7273
in repository https://gitbox.apache.org/repos/asf/maven.git
commit f81d66faa73d6449321d8d9887677b2e2d35c6d3
Author: Karl Heinz Marbaise <kh...@apache.org>
AuthorDate: Fri Nov 29 00:25:33 2019 +0100
[MNG-7273] - Modeltest - Improvements
---
maven-artifact/pom.xml | 5 ++
.../model/transform/ConsumerPomXMLFilterTest.java | 2 +-
maven-model/pom.xml | 22 +++++-
.../org/apache/maven/model/ActivationFileTest.java | 38 ++--------
.../org/apache/maven/model/ActivationOSTest.java | 36 ++--------
.../apache/maven/model/ActivationPropertyTest.java | 38 ++--------
.../org/apache/maven/model/ActivationTest.java | 38 ++--------
.../java/org/apache/maven/model/BuildTest.java | 38 ++--------
.../org/apache/maven/model/CiManagementTest.java | 38 ++--------
.../org/apache/maven/model/ContributorTest.java | 37 ++--------
.../maven/model/DependencyManagementTest.java | 36 ++--------
.../org/apache/maven/model/DependencyTest.java | 36 ++--------
.../maven/model/DeploymentRepositoryTest.java | 36 ++--------
.../java/org/apache/maven/model/DeveloperTest.java | 36 ++--------
.../maven/model/DistributionManagementTest.java | 36 ++--------
.../java/org/apache/maven/model/ExclusionTest.java | 36 ++--------
.../java/org/apache/maven/model/ExtensionTest.java | 36 ++--------
.../apache/maven/model/IssueManagementTest.java | 36 ++--------
.../java/org/apache/maven/model/LicenseTest.java | 36 ++--------
.../org/apache/maven/model/MailingListTest.java | 36 ++--------
.../java/org/apache/maven/model/ModelTest.java | 36 ++--------
.../org/apache/maven/model/ModelTestInterface.java | 83 ++++++++++++++++++++++
.../java/org/apache/maven/model/NotifierTest.java | 37 ++--------
.../org/apache/maven/model/OrganizationTest.java | 37 ++--------
.../java/org/apache/maven/model/ParentTest.java | 37 ++--------
.../maven/model/PluginConfigurationTest.java | 36 ++--------
.../apache/maven/model/PluginContainerTest.java | 36 ++--------
.../apache/maven/model/PluginExecutionTest.java | 36 ++--------
.../apache/maven/model/PluginManagementTest.java | 37 ++--------
.../java/org/apache/maven/model/PluginTest.java | 37 ++--------
.../org/apache/maven/model/PrerequisitesTest.java | 37 ++--------
.../java/org/apache/maven/model/ProfileTest.java | 36 ++--------
.../org/apache/maven/model/RelocationTest.java | 37 ++--------
.../org/apache/maven/model/ReportPluginTest.java | 37 ++--------
.../java/org/apache/maven/model/ReportSetTest.java | 36 ++--------
.../java/org/apache/maven/model/ReportingTest.java | 37 ++--------
.../apache/maven/model/RepositoryPolicyTest.java | 36 ++--------
.../org/apache/maven/model/RepositoryTest.java | 38 ++--------
.../java/org/apache/maven/model/ResourceTest.java | 38 ++--------
.../test/java/org/apache/maven/model/ScmTest.java | 36 ++--------
.../test/java/org/apache/maven/model/SiteTest.java | 37 ++--------
pom.xml | 8 ++-
42 files changed, 273 insertions(+), 1204 deletions(-)
diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml
index f47867b01..03c002c8f 100644
--- a/maven-artifact/pom.xml
+++ b/maven-artifact/pom.xml
@@ -41,6 +41,11 @@ under the License.
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/maven-model-transform/src/test/java/org/apache/maven/model/transform/ConsumerPomXMLFilterTest.java b/maven-model-transform/src/test/java/org/apache/maven/model/transform/ConsumerPomXMLFilterTest.java
index ee77d1244..d30f9f090 100644
--- a/maven-model-transform/src/test/java/org/apache/maven/model/transform/ConsumerPomXMLFilterTest.java
+++ b/maven-model-transform/src/test/java/org/apache/maven/model/transform/ConsumerPomXMLFilterTest.java
@@ -30,7 +30,7 @@ import java.util.function.Function;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
import org.junit.jupiter.api.Test;
-public class ConsumerPomXMLFilterTest extends AbstractXMLFilterTests
+class ConsumerPomXMLFilterTest extends AbstractXMLFilterTests
{
@Override
protected XmlPullParser getFilter( XmlPullParser orgParser )
diff --git a/maven-model/pom.xml b/maven-model/pom.xml
index 83f4bf54e..631b0b887 100644
--- a/maven-model/pom.xml
+++ b/maven-model/pom.xml
@@ -19,7 +19,8 @@ specific language governing permissions and limitations
under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
@@ -43,10 +44,29 @@ under the License.
<artifactId>hamcrest-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <compilerArgs>
+ <arg>-Xlint:deprecation</arg>
+ <arg>-Xlint:unchecked</arg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java
index cbfdc2a69..d4203100f 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ActivationFileTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code ActivationFile}.
*
* @author Benjamin Bentmann
*/
-public class ActivationFileTest
+class ActivationFileTest implements ModelTestInterface< ActivationFile >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new ActivationFile().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<ActivationFile> createValue()
{
- assertFalse( new ActivationFile().equals( null ) );
-
- new ActivationFile().equals( new ActivationFile() );
+ return ActivationFile.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- ActivationFile thing = new ActivationFile();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new ActivationFile().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java
index 3be5cd982..0dd51345d 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ActivationOSTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code ActivationOS}.
*
* @author Benjamin Bentmann
*/
-public class ActivationOSTest
+class ActivationOSTest implements ModelTestInterface< ActivationOS >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<ActivationOS> createValue()
{
- new ActivationOS().hashCode();
+ return ActivationOS.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new ActivationOS().equals( null ) );
-
- new ActivationOS().equals( new ActivationOS() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- ActivationOS thing = new ActivationOS();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new ActivationOS().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java
index 564adc010..84d7e0453 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ActivationPropertyTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code ActivationProperty}.
*
* @author Benjamin Bentmann
*/
-public class ActivationPropertyTest
+class ActivationPropertyTest implements ModelTestInterface< ActivationProperty >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new ActivationProperty().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<ActivationProperty> createValue()
{
- assertFalse( new ActivationProperty().equals( null ) );
-
- new ActivationProperty().equals( new ActivationProperty() );
+ return ActivationProperty.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- ActivationProperty thing = new ActivationProperty();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new ActivationProperty().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java b/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java
index 520c0a907..09163c71c 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ActivationTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Activation}.
*
* @author Benjamin Bentmann
*/
-public class ActivationTest
+class ActivationTest implements ModelTestInterface< Activation >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Activation().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<Activation> createValue()
{
- assertFalse( new Activation().equals( null ) );
-
- new Activation().equals( new Activation() );
+ return Activation.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- Activation thing = new Activation();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Activation().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/BuildTest.java b/maven-model/src/test/java/org/apache/maven/model/BuildTest.java
index 3a14bd3c3..811f0995e 100644
--- a/maven-model/src/test/java/org/apache/maven/model/BuildTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/BuildTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Build}.
*
* @author Benjamin Bentmann
*/
-public class BuildTest
+class BuildTest implements ModelTestInterface< Build >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Build().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<Build> createValue()
{
- assertFalse( new Build().equals( null ) );
-
- new Build().equals( new Build() );
+ return Build.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- Build thing = new Build();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Build().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java
index ee6d41d55..3a295fbe7 100644
--- a/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/CiManagementTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code CiManagement}.
*
* @author Benjamin Bentmann
*/
-public class CiManagementTest
+class CiManagementTest implements ModelTestInterface< CiManagement >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new CiManagement().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<CiManagement> createValue()
{
- assertFalse( new CiManagement().equals( null ) );
-
- new CiManagement().equals( new CiManagement() );
+ return CiManagement.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- CiManagement thing = new CiManagement();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new CiManagement().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java b/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java
index e2f3dbb5c..ece716b17 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ContributorTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Contributor}.
*
* @author Benjamin Bentmann
*/
-public class ContributorTest
+class ContributorTest implements ModelTestInterface< Contributor >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Contributor().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Contributor().equals( null ) );
-
- new Contributor().equals( new Contributor() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Contributor> createValue()
{
- Contributor thing = new Contributor();
- assertTrue( thing.equals( thing ) );
+ return Contributor.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Contributor().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java
index e63d22433..c172cb267 100644
--- a/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/DependencyManagementTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code DependencyManagement}.
*
* @author Benjamin Bentmann
*/
-public class DependencyManagementTest
+class DependencyManagementTest implements ModelTestInterface< DependencyManagement >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<DependencyManagement> createValue()
{
- new DependencyManagement().hashCode();
+ return DependencyManagement.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new DependencyManagement().equals( null ) );
-
- new DependencyManagement().equals( new DependencyManagement() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- DependencyManagement thing = new DependencyManagement();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new DependencyManagement().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java
index 6b7bc3f32..dac3d7ed7 100644
--- a/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/DependencyTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Dependency}.
*
* @author Benjamin Bentmann
*/
-public class DependencyTest
+class DependencyTest implements ModelTestInterface< Dependency >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Dependency> createValue()
{
- new Dependency().hashCode();
+ return Dependency.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Dependency().equals( null ) );
-
- new Dependency().equals( new Dependency() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Dependency thing = new Dependency();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Dependency().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java b/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java
index c648ffd29..c3664e87f 100644
--- a/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/DeploymentRepositoryTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code DeploymentRepository}.
*
* @author Benjamin Bentmann
*/
-public class DeploymentRepositoryTest
+class DeploymentRepositoryTest implements ModelTestInterface< DeploymentRepository >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<DeploymentRepository> createValue()
{
- new DeploymentRepository().hashCode();
+ return DeploymentRepository.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new DeploymentRepository().equals( null ) );
-
- new DeploymentRepository().equals( new DeploymentRepository() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- DeploymentRepository thing = new DeploymentRepository();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new DeploymentRepository().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java b/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java
index 61d86f084..746ed8439 100644
--- a/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/DeveloperTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Developer}.
*
* @author Benjamin Bentmann
*/
-public class DeveloperTest
+class DeveloperTest implements ModelTestInterface< Developer >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Developer> createValue()
{
- new Developer().hashCode();
+ return Developer.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Developer().equals( null ) );
-
- new Developer().equals( new Developer() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Developer thing = new Developer();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Developer().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java
index db8ba213b..9cc4288d4 100644
--- a/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/DistributionManagementTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code DistributionManagement}.
*
* @author Benjamin Bentmann
*/
-public class DistributionManagementTest
+class DistributionManagementTest implements ModelTestInterface< DistributionManagement >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<DistributionManagement> createValue()
{
- new DistributionManagement().hashCode();
+ return DistributionManagement.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new DistributionManagement().equals( null ) );
-
- new DistributionManagement().equals( new DistributionManagement() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- DistributionManagement thing = new DistributionManagement();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new DistributionManagement().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java b/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java
index 90e4b744d..c9abf4bb6 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ExclusionTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Exclusion}.
*
* @author Benjamin Bentmann
*/
-public class ExclusionTest
+class ExclusionTest implements ModelTestInterface< Exclusion >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Exclusion> createValue()
{
- new Exclusion().hashCode();
+ return Exclusion.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Exclusion().equals( null ) );
-
- new Exclusion().equals( new Exclusion() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Exclusion thing = new Exclusion();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Exclusion().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java b/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java
index 218ff50b6..f0a9c391b 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ExtensionTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Extension}.
*
* @author Benjamin Bentmann
*/
-public class ExtensionTest
+class ExtensionTest implements ModelTestInterface< Extension >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Extension> createValue()
{
- new Extension().hashCode();
+ return Extension.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Extension().equals( null ) );
-
- new Extension().equals( new Extension() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Extension thing = new Extension();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Extension().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java
index 27e1eb0a3..2c56880ad 100644
--- a/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/IssueManagementTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code IssueManagement}.
*
* @author Benjamin Bentmann
*/
-public class IssueManagementTest
+class IssueManagementTest implements ModelTestInterface< IssueManagement >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<IssueManagement> createValue()
{
- new IssueManagement().hashCode();
+ return IssueManagement.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new IssueManagement().equals( null ) );
-
- new IssueManagement().equals( new IssueManagement() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- IssueManagement thing = new IssueManagement();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new IssueManagement().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java b/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java
index dd56616fb..98b24da8e 100644
--- a/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/LicenseTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code License}.
*
* @author Benjamin Bentmann
*/
-public class LicenseTest
+class LicenseTest implements ModelTestInterface< License >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<License> createValue()
{
- new License().hashCode();
+ return License.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new License().equals( null ) );
-
- new License().equals( new License() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- License thing = new License();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new License().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java b/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java
index 5de9edcf3..d38528715 100644
--- a/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/MailingListTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code MailingList}.
*
* @author Benjamin Bentmann
*/
-public class MailingListTest
+class MailingListTest implements ModelTestInterface< MailingList >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<MailingList> createValue()
{
- new MailingList().hashCode();
+ return MailingList.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new MailingList().equals( null ) );
-
- new MailingList().equals( new MailingList() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- MailingList thing = new MailingList();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new MailingList().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ModelTest.java b/maven-model/src/test/java/org/apache/maven/model/ModelTest.java
index 37adc8216..01f869655 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ModelTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ModelTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Model}.
*
* @author Benjamin Bentmann
*/
-public class ModelTest
+class ModelTest implements ModelTestInterface< Model >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Model> createValue()
{
- new Model().hashCode();
+ return Model.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Model().equals( null ) );
-
- new Model().equals( new Model() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Model thing = new Model();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Model().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java b/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java
new file mode 100644
index 000000000..0f5c66224
--- /dev/null
+++ b/maven-model/src/test/java/org/apache/maven/model/ModelTestInterface.java
@@ -0,0 +1,83 @@
+package org.apache.maven.model;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.DisplayNameGeneration;
+import org.junit.jupiter.api.DisplayNameGenerator;
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+/**
+ * Interface as a test template for all model tests.
+ *
+ * @author Karl Heinz Marbaise
+ */
+@DisplayNameGeneration( ModelTestInterface.NameGenerator.class )
+interface ModelTestInterface< T >
+{
+
+ Class<T> createValue();
+
+ @Test
+ @DisplayName( "hashCode should not fail with null." )
+ default void hashCodeNullSafe()
+ {
+ assertThatCode( () -> createValue().hashCode() ).doesNotThrowAnyException();
+ }
+
+ @Test
+ @DisplayName( "equals should not fail with null." )
+ default void equalsNullSafe() throws ReflectiveOperationException
+ {
+ T newInstance = createValue().getDeclaredConstructor().newInstance();
+ assertThat( newInstance.equals( null ) ).isFalse();
+ }
+
+ @Test
+ @DisplayName( "equals should result in false for two different instances." )
+ default void equalsSameToBeFalse() throws ReflectiveOperationException
+ {
+ T firstInstance = createValue().getDeclaredConstructor().newInstance();
+ T secondInstance = createValue().getDeclaredConstructor().newInstance();
+ assertThat(firstInstance).isNotSameAs(secondInstance);
+ }
+
+ @Test
+ @DisplayName( "toString should not be null." )
+ default void toStringNullSafe() throws ReflectiveOperationException
+ {
+ assertThat( createValue().getDeclaredConstructor().newInstance().toString() ).isNotNull();
+ }
+
+ /**
+ * The @DisplayName will be the test class name without the trailing "Test".
+ */
+ class NameGenerator extends DisplayNameGenerator.Standard
+ {
+ public String generateDisplayNameForClass( Class<?> testClass )
+ {
+ String name = testClass.getSimpleName();
+ return name.substring(0, name.length() - 4);
+ }
+ }
+}
diff --git a/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java b/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java
index 026632ad6..48605ccd8 100644
--- a/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/NotifierTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Notifier}.
*
* @author Benjamin Bentmann
*/
-public class NotifierTest
+class NotifierTest implements ModelTestInterface< Notifier >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Notifier().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Notifier().equals( null ) );
-
- new Notifier().equals( new Notifier() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Notifier> createValue()
{
- Notifier thing = new Notifier();
- assertTrue( thing.equals( thing ) );
+ return Notifier.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Notifier().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java b/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java
index ef19d2a54..b5f694ed5 100644
--- a/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/OrganizationTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Organization}.
*
* @author Benjamin Bentmann
*/
-public class OrganizationTest
+class OrganizationTest implements ModelTestInterface< Organization >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Organization().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Organization().equals( null ) );
-
- new Organization().equals( new Organization() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Organization> createValue()
{
- Organization thing = new Organization();
- assertTrue( thing.equals( thing ) );
+ return Organization.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Organization().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ParentTest.java b/maven-model/src/test/java/org/apache/maven/model/ParentTest.java
index d8690fc3c..605c55c04 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ParentTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ParentTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Parent}.
*
* @author Benjamin Bentmann
*/
-public class ParentTest
+class ParentTest implements ModelTestInterface< Parent >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Parent().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Parent().equals( null ) );
-
- new Parent().equals( new Parent() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Parent> createValue()
{
- Parent thing = new Parent();
- assertTrue( thing.equals( thing ) );
+ return Parent.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Parent().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java
index 3e52df79f..5b92db970 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PluginConfigurationTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code PluginConfiguration}.
*
* @author Benjamin Bentmann
*/
-public class PluginConfigurationTest
+class PluginConfigurationTest implements ModelTestInterface< PluginConfiguration >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<PluginConfiguration> createValue()
{
- new PluginConfiguration().hashCode();
+ return PluginConfiguration.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new PluginConfiguration().equals( null ) );
-
- new PluginConfiguration().equals( new PluginConfiguration() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- PluginConfiguration thing = new PluginConfiguration();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new PluginConfiguration().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java
index ed4e9e3d7..ccda9dc14 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PluginContainerTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code PluginContainer}.
*
* @author Benjamin Bentmann
*/
-public class PluginContainerTest
+class PluginContainerTest implements ModelTestInterface< PluginContainer >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<PluginContainer> createValue()
{
- new PluginContainer().hashCode();
+ return PluginContainer.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new PluginContainer().equals( null ) );
-
- new PluginContainer().equals( new PluginContainer() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- PluginContainer thing = new PluginContainer();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new PluginContainer().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java
index 35b78bdd8..8a4852815 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PluginExecutionTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code PluginExecution}.
*
* @author Benjamin Bentmann
*/
-public class PluginExecutionTest
+class PluginExecutionTest implements ModelTestInterface< PluginExecution >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<PluginExecution> createValue()
{
- new PluginExecution().hashCode();
+ return PluginExecution.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new PluginExecution().equals( null ) );
-
- new PluginExecution().equals( new PluginExecution() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- PluginExecution thing = new PluginExecution();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new PluginExecution().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java
index b4d826624..f5e459bad 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PluginManagementTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code PluginManagement}.
*
* @author Benjamin Bentmann
*/
-public class PluginManagementTest
+class PluginManagementTest implements ModelTestInterface< PluginManagement >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new PluginManagement().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new PluginManagement().equals( null ) );
-
- new PluginManagement().equals( new PluginManagement() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<PluginManagement> createValue()
{
- PluginManagement thing = new PluginManagement();
- assertTrue( thing.equals( thing ) );
+ return PluginManagement.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new PluginManagement().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PluginTest.java b/maven-model/src/test/java/org/apache/maven/model/PluginTest.java
index d8e345b6b..5169d6750 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PluginTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PluginTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Plugin}.
*
* @author Benjamin Bentmann
*/
-public class PluginTest
+class PluginTest implements ModelTestInterface< Plugin >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Plugin().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Plugin().equals( null ) );
-
- new Plugin().equals( new Plugin() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Plugin> createValue()
{
- Plugin thing = new Plugin();
- assertTrue( thing.equals( thing ) );
+ return Plugin.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Plugin().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java b/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java
index 2c91e4710..bdd853fa3 100644
--- a/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/PrerequisitesTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Prerequisites}.
*
* @author Benjamin Bentmann
*/
-public class PrerequisitesTest
+class PrerequisitesTest implements ModelTestInterface< Prerequisites >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Prerequisites().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Prerequisites().equals( null ) );
-
- new Prerequisites().equals( new Prerequisites() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Prerequisites> createValue()
{
- Prerequisites thing = new Prerequisites();
- assertTrue( thing.equals( thing ) );
+ return Prerequisites.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Prerequisites().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java b/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java
index ac719e467..4fde5b7bc 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ProfileTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Profile}.
*
* @author Benjamin Bentmann
*/
-public class ProfileTest
+class ProfileTest implements ModelTestInterface< Profile >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Profile> createValue()
{
- new Profile().hashCode();
+ return Profile.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Profile().equals( null ) );
-
- new Profile().equals( new Profile() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Profile thing = new Profile();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Profile().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java b/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java
index ea825a6fd..93cef72e5 100644
--- a/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/RelocationTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Relocation}.
*
* @author Benjamin Bentmann
*/
-public class RelocationTest
+class RelocationTest implements ModelTestInterface< Relocation >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Relocation().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Relocation().equals( null ) );
-
- new Relocation().equals( new Relocation() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Relocation> createValue()
{
- Relocation thing = new Relocation();
- assertTrue( thing.equals( thing ) );
+ return Relocation.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Relocation().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java
index 094d2d5f6..0c1ff955e 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ReportPluginTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code ReportPlugin}.
*
* @author Benjamin Bentmann
*/
-public class ReportPluginTest
+class ReportPluginTest implements ModelTestInterface< ReportPlugin >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new ReportPlugin().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new ReportPlugin().equals( null ) );
-
- new ReportPlugin().equals( new ReportPlugin() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<ReportPlugin> createValue()
{
- ReportPlugin thing = new ReportPlugin();
- assertTrue( thing.equals( thing ) );
+ return ReportPlugin.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new ReportPlugin().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java
index c0bb2575c..52da631b4 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ReportSetTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code ReportSet}.
*
* @author Benjamin Bentmann
*/
-public class ReportSetTest
+class ReportSetTest implements ModelTestInterface< ReportSet >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<ReportSet> createValue()
{
- new ReportSet().hashCode();
+ return ReportSet.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new ReportSet().equals( null ) );
-
- new ReportSet().equals( new ReportSet() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- ReportSet thing = new ReportSet();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new ReportSet().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java b/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java
index 3b04d0240..4940c8050 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ReportingTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Reporting}.
*
* @author Benjamin Bentmann
*/
-public class ReportingTest
+class ReportingTest implements ModelTestInterface< Reporting >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Reporting().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Reporting().equals( null ) );
-
- new Reporting().equals( new Reporting() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Reporting> createValue()
{
- Reporting thing = new Reporting();
- assertTrue( thing.equals( thing ) );
+ return Reporting.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Reporting().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java b/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java
index 770bce206..5b13ee050 100644
--- a/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/RepositoryPolicyTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code RepositoryPolicy}.
*
* @author Benjamin Bentmann
*/
-public class RepositoryPolicyTest
+class RepositoryPolicyTest implements ModelTestInterface< RepositoryPolicy >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<RepositoryPolicy> createValue()
{
- new RepositoryPolicy().hashCode();
+ return RepositoryPolicy.class;
}
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new RepositoryPolicy().equals( null ) );
-
- new RepositoryPolicy().equals( new RepositoryPolicy() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- RepositoryPolicy thing = new RepositoryPolicy();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new RepositoryPolicy().toString() );
- }
-
}
diff --git a/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java b/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java
index 62f32d723..9a52d92bc 100644
--- a/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/RepositoryTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Repository}.
*
* @author Benjamin Bentmann
*/
-public class RepositoryTest
+class RepositoryTest implements ModelTestInterface< Repository >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Repository().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<Repository> createValue()
{
- assertFalse( new Repository().equals( null ) );
-
- new Repository().equals( new Repository() );
+ return Repository.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- Repository thing = new Repository();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Repository().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java b/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java
index 3e5b1b3a0..99921dbff 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ResourceTest.java
@@ -19,45 +19,17 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Resource}.
*
* @author Benjamin Bentmann
*/
-public class ResourceTest
+class ResourceTest implements ModelTestInterface< Resource >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Resource().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
+ @Override
+ public Class<Resource> createValue()
{
- assertFalse( new Resource().equals( null ) );
-
- new Resource().equals( new Resource() );
+ return Resource.class;
}
-
- @Test
- public void testEqualsIdentity()
- {
- Resource thing = new Resource();
- assertTrue( thing.equals( thing ) );
- }
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Resource().toString() );
- }
-
}
+
diff --git a/maven-model/src/test/java/org/apache/maven/model/ScmTest.java b/maven-model/src/test/java/org/apache/maven/model/ScmTest.java
index a6ccc248d..331e21fe8 100644
--- a/maven-model/src/test/java/org/apache/maven/model/ScmTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/ScmTest.java
@@ -19,45 +19,19 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Scm}.
*
* @author Benjamin Bentmann
*/
-public class ScmTest
+class ScmTest implements ModelTestInterface< Scm >
{
- @Test
- public void testHashCodeNullSafe()
+ @Override
+ public Class<Scm> createValue()
{
- new Scm().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Scm().equals( null ) );
-
- new Scm().equals( new Scm() );
- }
-
- @Test
- public void testEqualsIdentity()
- {
- Scm thing = new Scm();
- assertTrue( thing.equals( thing ) );
+ return Scm.class;
}
+}
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Scm().toString() );
- }
-}
diff --git a/maven-model/src/test/java/org/apache/maven/model/SiteTest.java b/maven-model/src/test/java/org/apache/maven/model/SiteTest.java
index 5fe49756c..8a4a23ab2 100644
--- a/maven-model/src/test/java/org/apache/maven/model/SiteTest.java
+++ b/maven-model/src/test/java/org/apache/maven/model/SiteTest.java
@@ -19,45 +19,16 @@ package org.apache.maven.model;
* under the License.
*/
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertFalse;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
/**
* Tests {@code Site}.
*
* @author Benjamin Bentmann
*/
-public class SiteTest
+class SiteTest implements ModelTestInterface< Site >
{
-
- @Test
- public void testHashCodeNullSafe()
- {
- new Site().hashCode();
- }
-
- @Test
- public void testEqualsNullSafe()
- {
- assertFalse( new Site().equals( null ) );
-
- new Site().equals( new Site() );
- }
-
- @Test
- public void testEqualsIdentity()
+ @Override
+ public Class<Site> createValue()
{
- Site thing = new Site();
- assertTrue( thing.equals( thing ) );
+ return Site.class;
}
-
- @Test
- public void testToStringNullSafe()
- {
- assertNotNull( new Site().toString() );
- }
-
}
diff --git a/pom.xml b/pom.xml
index f5e1dff20..f906e5239 100644
--- a/pom.xml
+++ b/pom.xml
@@ -453,9 +453,14 @@ under the License.
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
- <type>pom</type>
<version>${junitVersion}</version>
<scope>import</scope>
+ <type>pom</type>
+ </dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-core</artifactId>
+ <version>3.20.2</version>
</dependency>
</dependencies>
<!--bootstrap-start-comment-->
@@ -532,6 +537,7 @@ under the License.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <version>2.22.2</version>
<configuration>
<argLine>-Xmx256m</argLine>
<environmentVariables>