This is an automated email from the ASF dual-hosted git repository. khmarbaise pushed a commit to branch MODELTESTS_IMPROVEMENT in repository https://gitbox.apache.org/repos/asf/maven.git
commit 4c8ede648bdc727138041dfa927ff0adf9ee0f37 Author: Karl Heinz Marbaise <[email protected]> AuthorDate: Fri Nov 29 00:25:33 2019 +0100 Improved code. --- maven-artifact/pom.xml | 5 ++ .../model/transform/CiFriendlyXMLFilterTest.java | 13 +--- .../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 | 16 +++-- 43 files changed, 280 insertions(+), 1218 deletions(-) diff --git a/maven-artifact/pom.xml b/maven-artifact/pom.xml index f47867b..03c002c 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/CiFriendlyXMLFilterTest.java b/maven-model-transform/src/test/java/org/apache/maven/model/transform/CiFriendlyXMLFilterTest.java index 80cf84d..09245c6 100644 --- a/maven-model-transform/src/test/java/org/apache/maven/model/transform/CiFriendlyXMLFilterTest.java +++ b/maven-model-transform/src/test/java/org/apache/maven/model/transform/CiFriendlyXMLFilterTest.java @@ -19,16 +19,11 @@ package org.apache.maven.model.transform; * under the License. */ -import static org.junit.jupiter.api.Assertions.assertEquals; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.TransformerException; - -import org.junit.jupiter.api.Test; import org.apache.maven.model.transform.sax.AbstractSAXFilter; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import org.xml.sax.SAXException; +import static org.junit.jupiter.api.Assertions.assertEquals; public class CiFriendlyXMLFilterTest extends AbstractXMLFilterTests { @@ -42,9 +37,7 @@ public class CiFriendlyXMLFilterTest extends AbstractXMLFilterTests } @Override - protected AbstractSAXFilter getFilter() - throws TransformerException, SAXException, ParserConfigurationException - { + protected AbstractSAXFilter getFilter() { return filter; } 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 4fe2c19..b1912ed 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 @@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test; import org.xml.sax.SAXException; import org.xml.sax.ext.LexicalHandler; -public class ConsumerPomXMLFilterTest extends AbstractXMLFilterTests +class ConsumerPomXMLFilterTest extends AbstractXMLFilterTests { @Override protected String omitXmlDeclaration() diff --git a/maven-model/pom.xml b/maven-model/pom.xml index 83f4bf5..631b0b8 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,11 +44,30 @@ 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> <configuration> 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 cbfdc2a..d420310 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 3be5cd9..0dd5134 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 564adc0..84d7e04 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 520c0a9..09163c7 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 3a14bd3..811f099 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 ee6d41d..3a295fb 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 e2f3dbb..ece716b 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 e63d224..c172cb2 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 6b7bc3f..dac3d7e 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 c648ffd..c3664e8 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 61d86f0..746ed84 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 db8ba21..9cc4288 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 90e4b74..c9abf4b 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 218ff50..f0a9c39 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 27e1eb0..2c56880 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 dd56616..98b24da 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 5de9edc..d385287 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 37adc82..01f8696 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 0000000..0f5c662 --- /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 026632a..48605cc 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 ef19d2a..b5f694e 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 d8690fc..605c55c 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 3e52df7..5b92db9 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 ed4e9e3..ccda9dc 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 35b78bd..8a48528 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 b4d8266..f5e459b 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 d8e345b..5169d67 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 2c91e47..bdd853f 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 ac719e4..4fde5b7 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 ea825a6..93cef72 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 094d2d5..0c1ff95 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 c0bb257..52da631 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 3b04d02..4940c80 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 770bce2..5b13ee0 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 62f32d7..9a52d92 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 3e5b1b3..99921db 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 a6ccc24..331e21f 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 5fe4975..8a4a23a 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 c1bb303..418fdc1 100644 --- a/pom.xml +++ b/pom.xml @@ -51,7 +51,7 @@ under the License. <classWorldsVersion>2.6.0</classWorldsVersion> <commonsCliVersion>1.4</commonsCliVersion> <commonsLangVersion>3.12.0</commonsLangVersion> - <junitVersion>5.7.0</junitVersion> + <junitVersion>5.8.0</junitVersion> <mockitoVersion>3.2.0</mockitoVersion> <plexusVersion>2.1.0</plexusVersion> <plexusInterpolationVersion>1.26</plexusInterpolationVersion> @@ -448,10 +448,16 @@ under the License. <scope>test</scope> </dependency> <dependency> - <groupId>org.junit.jupiter</groupId> - <artifactId>junit-jupiter-params</artifactId> + <groupId>org.junit</groupId> + <artifactId>junit-bom</artifactId> <version>${junitVersion}</version> - <scope>test</scope> + <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--> @@ -462,7 +468,6 @@ under the License. <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> - <version>${junitVersion}</version> <scope>test</scope> </dependency> <dependency> @@ -534,6 +539,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>
