From a7a878a47528d59a121f9636886213ac146808a8 Mon Sep 17 00:00:00 2001 From: Sylwester Lachiewicz Date: Sat, 22 Jun 2024 11:34:14 +0200 Subject: [PATCH] Convert tests to JUnit 5 and some cleanups --- pom.xml | 30 +++-- .../AbstractStrictPatternArtifactFilter.java | 2 +- .../artifact/filter/ScopeArtifactFilter.java | 4 +- .../resolve/transform/EclipseAetherNode.java | 27 ++-- .../AbstractPatternArtifactFilterTest.java | 44 +++---- ...stractStrictPatternArtifactFilterTest.java | 118 +++++++++--------- .../GNPatternIncludesArtifactFilter.java | 2 +- .../OldPatternIncludesArtifactFilter.java | 2 +- .../filter/ScopeArtifactFilterTest.java | 57 +++++---- .../AbstractArtifactFeatureFilterTest.java | 12 +- .../filter/collection/TestArtifactFilter.java | 22 ++-- .../collection/TestClassifierFilter.java | 20 +-- .../collection/TestFilterArtifacts.java | 29 +++-- .../filter/collection/TestGroupIdFilter.java | 28 ++--- .../TestProjectTransitivityFilter.java | 18 +-- .../filter/collection/TestScopeFilter.java | 53 ++++---- .../filter/collection/TestTypeFilter.java | 24 ++-- .../ArtifactIncludeFilterTransformerTest.java | 34 ++--- .../transform/ArtifactIncludeNodeTest.java | 16 +-- .../EclipseAetherFilterTransformerTest.java | 91 +++++--------- .../transform/EclipseAetherNodeTest.java | 16 +-- 21 files changed, 321 insertions(+), 328 deletions(-) diff --git a/pom.xml b/pom.xml index 73879e7..5524fbe 100644 --- a/pom.xml +++ b/pom.xml @@ -106,15 +106,15 @@ test - junit - junit - 4.13.2 + org.mockito + mockito-core + 4.11.0 test org.mockito - mockito-core - 4.8.0 + mockito-junit-jupiter + 4.11.0 test @@ -127,19 +127,35 @@ org.codehaus.plexus plexus-container-default + + junit + junit + + + org.junit.jupiter + junit-jupiter-api + test + org.openjdk.jmh jmh-core - 1.35 + 1.37 test org.openjdk.jmh jmh-generator-annprocess - 1.35 + 1.37 test + + + maven_central + Maven Central + https://repo.maven.apache.org/maven2/ + + diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java index 420b040..4f5c061 100644 --- a/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java +++ b/src/main/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilter.java @@ -130,7 +130,7 @@ private boolean matches(String token, String pattern) { boolean matches; // support full wildcard and implied wildcard - if ("*".equals(pattern) || pattern.length() == 0) { + if ("*".equals(pattern) || pattern.isEmpty()) { matches = true; } // support contains wildcard diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java index ac47979..1bd34d2 100644 --- a/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java +++ b/src/main/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilter.java @@ -189,8 +189,8 @@ public void reportMissedCriteria(Logger logger) { report = true; } - if (report && logger.isDebugEnabled()) { - logger.debug("The following scope filters were not used: " + buffer); + if (report) { + logger.debug("The following scope filters were not used: {}", buffer); } } } diff --git a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java index 05e51cc..e2de58b 100644 --- a/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java +++ b/src/main/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNode.java @@ -62,22 +62,25 @@ public org.apache.maven.model.Dependency getDependency() { mavenDependency.setOptional(nodeDependency.isOptional()); } if (nodeDependency.getExclusions() != null) { - List mavenExclusions = - new ArrayList<>(nodeDependency.getExclusions().size()); + mavenDependency.setExclusions(getExclusions(nodeDependency)); + } + + return mavenDependency; + } - for (Exclusion aetherExclusion : nodeDependency.getExclusions()) { - org.apache.maven.model.Exclusion mavenExclusion = new org.apache.maven.model.Exclusion(); + private static List getExclusions(Dependency nodeDependency) { + List mavenExclusions = + new ArrayList<>(nodeDependency.getExclusions().size()); - mavenExclusion.setGroupId(aetherExclusion.getGroupId()); - mavenExclusion.setArtifactId(aetherExclusion.getArtifactId()); - // that's all folks, although Aether has more metadata + for (Exclusion aetherExclusion : nodeDependency.getExclusions()) { + org.apache.maven.model.Exclusion mavenExclusion = new org.apache.maven.model.Exclusion(); - mavenExclusions.add(mavenExclusion); - } + mavenExclusion.setGroupId(aetherExclusion.getGroupId()); + mavenExclusion.setArtifactId(aetherExclusion.getArtifactId()); + // that's all folks, although Aether has more metadata - mavenDependency.setExclusions(mavenExclusions); + mavenExclusions.add(mavenExclusion); } - - return mavenDependency; + return mavenExclusions; } } diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java index 53da5e4..724fb05 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractPatternArtifactFilterTest.java @@ -25,10 +25,10 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.resolver.filter.ArtifactFilter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -41,7 +41,7 @@ public abstract class AbstractPatternArtifactFilterTest { protected abstract boolean isInclusionNotExpected(); @Test - public void testShouldTriggerBothPatternsWithWildcards() { + public void shouldTriggerBothPatternsWithWildcards() { final String groupId1 = "group"; final String artifactId1 = "artifact"; @@ -76,7 +76,7 @@ public void testShouldTriggerBothPatternsWithWildcards() { } @Test - public void testShouldTriggerBothPatternsWithNonColonWildcards() { + public void shouldTriggerBothPatternsWithNonColonWildcards() { final String groupId1 = "group"; final String artifactId1 = "artifact"; @@ -111,7 +111,7 @@ public void testShouldTriggerBothPatternsWithNonColonWildcards() { } @Test - public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId() { + public void shouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId() { final String groupId = "group"; final String artifactId = "artifact"; @@ -131,7 +131,7 @@ public void testShouldIncludeDirectlyMatchedArtifactByGroupIdArtifactId() { } @Test - public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId() { + public void shouldIncludeDirectlyMatchedArtifactByDependencyConflictId() { final String groupId = "group"; final String artifactId = "artifact"; @@ -151,7 +151,7 @@ public void testShouldIncludeDirectlyMatchedArtifactByDependencyConflictId() { } @Test - public void testShouldNotIncludeWhenGroupIdDiffers() { + public void shouldNotIncludeWhenGroupIdDiffers() { final String groupId = "group"; final String artifactId = "artifact"; @@ -175,7 +175,7 @@ public void testShouldNotIncludeWhenGroupIdDiffers() { } @Test - public void testShouldNotIncludeWhenArtifactIdDiffers() { + public void shouldNotIncludeWhenArtifactIdDiffers() { final String groupId = "group"; final String artifactId = "artifact"; @@ -199,7 +199,7 @@ public void testShouldNotIncludeWhenArtifactIdDiffers() { } @Test - public void testShouldNotIncludeWhenBothIdElementsDiffer() { + public void shouldNotIncludeWhenBothIdElementsDiffer() { final String groupId = "group"; final String artifactId = "artifact"; @@ -223,7 +223,7 @@ public void testShouldNotIncludeWhenBothIdElementsDiffer() { } @Test - public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled() { + public void shouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsEnabled() { final String groupId = "group"; final String artifactId = "artifact"; @@ -250,7 +250,7 @@ public void testShouldIncludeWhenPatternMatchesDependencyTrailAndTransitivityIsE } @Test - public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard() { + public void shouldIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWildcard() { final String groupId = "group"; final String artifactId = "artifact"; @@ -277,7 +277,7 @@ public void testIncludeWhenPatternMatchesDepTrailWithTransitivityUsingNonColonWi } @Test - public void testShouldNotIncludeWhenNegativeMatch() { + public void shouldNotIncludeWhenNegativeMatch() { final String groupId = "group"; final String artifactId = "artifact"; @@ -300,7 +300,7 @@ public void testShouldNotIncludeWhenNegativeMatch() { } @Test - public void testShouldIncludeWhenWildcardMatchesInsideSequence() { + public void shouldIncludeWhenWildcardMatchesInsideSequence() { final String groupId = "group"; final String artifactId = "artifact"; @@ -323,7 +323,7 @@ public void testShouldIncludeWhenWildcardMatchesInsideSequence() { } @Test - public void testShouldIncludeWhenWildcardMatchesOutsideSequence() { + public void shouldIncludeWhenWildcardMatchesOutsideSequence() { final String groupId = "group"; final String artifactId = "artifact"; @@ -347,7 +347,7 @@ public void testShouldIncludeWhenWildcardMatchesOutsideSequence() { } @Test - public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId() { + public void shouldIncludeWhenWildcardMatchesMiddleOfArtifactId() { final String groupId = "group"; final String artifactId = "some-artifact-id"; @@ -371,7 +371,7 @@ public void testShouldIncludeWhenWildcardMatchesMiddleOfArtifactId() { } @Test - public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse() { + public void shouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse() { final String groupId = "some.group.id"; final String artifactId = "some-artifact-id"; @@ -395,7 +395,7 @@ public void testShouldIncludeWhenWildcardCoversPartOfGroupIdAndEverythingElse() } @Test - public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent() { + public void shouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMatchParent() { final String groupId = "group"; final String artifactId = "artifact"; @@ -430,7 +430,7 @@ public void testShouldIncludeTransitiveDependencyWhenWildcardMatchesButDoesntMat } @Test - public void testShouldIncludeJarsWithAndWithoutClassifier() { + public void shouldIncludeJarsWithAndWithoutClassifier() { final String groupId = "com.mycompany.myproject"; final String artifactId = "some-artifact-id"; @@ -453,7 +453,7 @@ public void testShouldIncludeJarsWithAndWithoutClassifier() { } @Test - public void testWithVersionRange() { + public void checkWithVersionRange() { final String groupId = "com.mycompany.myproject"; final String artifactId = "some-artifact-id"; @@ -476,7 +476,7 @@ public void testWithVersionRange() { } @Test - public void testmassembly955() { + public void checkMassembly955() { Artifact artifact1 = mock(Artifact.class); when(artifact1.getGroupId()).thenReturn("org.python"); when(artifact1.getArtifactId()).thenReturn("jython-standalone"); @@ -507,7 +507,7 @@ public void testmassembly955() { } @Test - public void testPartialWildcardShouldNotMatchEmptyComponent() { + public void partialWildcardShouldNotMatchEmptyComponent() { Artifact artifact = mock(Artifact.class); when(artifact.getGroupId()).thenReturn("test-group"); when(artifact.getArtifactId()).thenReturn("test-artifact"); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java index baca82f..dccb8b3 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/AbstractStrictPatternArtifactFilterTest.java @@ -21,16 +21,16 @@ import java.util.Collections; import java.util.List; -import junit.framework.AssertionFailedError; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.handler.DefaultArtifactHandler; import org.apache.maven.artifact.versioning.VersionRange; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.opentest4j.AssertionFailedError; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests subclasses of AbstractStrictPatternArtifactFilter. @@ -41,275 +41,275 @@ public abstract class AbstractStrictPatternArtifactFilterTest { protected Artifact artifact; - @Before + @BeforeEach public void setUp() { artifact = createArtifact("groupId", "artifactId", "type", "version"); } @Test - public void testExactIncluded() { + public void checkExactIncluded() { assertIncluded("groupId:artifactId"); } @Test - public void testExactExcluded() { + public void checkExactExcluded() { assertExcluded("differentGroupId:differentArtifactId"); } @Test - public void testGroupIdIncluded() { + public void checkGroupIdIncluded() { assertIncluded("groupId"); } @Test - public void testGroupIdExcluded() { + public void checkgroupIdExcluded() { assertExcluded("differentGroupId"); } @Test - public void testGroupIdWildcardIncluded() { + public void checkGroupIdWildcardIncluded() { assertIncluded("*"); } @Test - public void testGroupIdImplicitWildcardIncluded() { + public void checkGroupIdImplicitWildcardIncluded() { assertIncluded(""); } @Test - public void testGroupIdStartsWithWildcardIncluded() { + public void checkGroupIdStartsWithWildcardIncluded() { assertIncluded("groupId*"); } @Test - public void testGroupIdStartsWithPartialWildcardIncluded() { + public void checkGroupIdStartsWithPartialWildcardIncluded() { assertIncluded("group*"); } @Test - public void testGroupIdStartsWithWildcardExcluded() { + public void checkGroupIdStartsWithWildcardExcluded() { assertExcluded("different*"); } @Test - public void testGroupIdEndsWithWildcardIncluded() { + public void checkGroupIdEndsWithWildcardIncluded() { assertIncluded("*groupId"); } @Test - public void testGroupIdEndsWithPartialWildcardIncluded() { + public void checkGroupIdEndsWithPartialWildcardIncluded() { assertIncluded("*Id"); } @Test - public void testGroupIdEndsWithWildcardExcluded() { + public void checkGroupIdEndsWithWildcardExcluded() { assertExcluded("*different"); } @Test - public void testGroupIdContainsWildcardIncluded() { + public void checkGroupIdContainsWildcardIncluded() { assertIncluded("*oup*"); } @Test - public void testGroupIdContainsWildcardExcluded() { + public void checkGroupIdContainsWildcardExcluded() { assertExcluded("*different*"); } @Test - public void testArtifactIdIncluded() { + public void checkArtifactIdIncluded() { assertIncluded(":artifactId"); } @Test - public void testArtifactIdExcluded() { + public void checkArtifactIdExcluded() { assertExcluded(":differentArtifactId"); } @Test - public void testArtifactIdWildcardIncluded() { + public void checkArtifactIdWildcardIncluded() { assertIncluded(":*"); } @Test - public void testArtifactIdImplicitWildcardIncluded() { + public void checkArtifactIdImplicitWildcardIncluded() { assertIncluded(":"); } @Test - public void testArtifactIdStartsWithWildcardIncluded() { + public void checkArtifactIdStartsWithWildcardIncluded() { assertIncluded(":artifactId*"); } @Test - public void testArtifactIdStartsWithPartialWildcardIncluded() { + public void checkArtifactIdStartsWithPartialWildcardIncluded() { assertIncluded(":artifact*"); } @Test - public void testArtifactIdStartsWithWildcardExcluded() { + public void checkArtifactIdStartsWithWildcardExcluded() { assertExcluded(":different*"); } @Test - public void testArtifactIdEndsWithWildcardIncluded() { + public void checkArtifactIdEndsWithWildcardIncluded() { assertIncluded(":*artifactId"); } @Test - public void testArtifactIdEndsWithPartialWildcardIncluded() { + public void checkArtifactIdEndsWithPartialWildcardIncluded() { assertIncluded(":*Id"); } @Test - public void testArtifactIdEndsWithWildcardExcluded() { + public void checkArtifactIdEndsWithWildcardExcluded() { assertExcluded(":*different"); } @Test - public void testArtifactIdContainsWildcardIncluded() { + public void checkArtifactIdContainsWildcardIncluded() { assertIncluded(":*fact*"); } @Test - public void testArtifactIdContainsWildcardExcluded() { + public void checkArtifactIdContainsWildcardExcluded() { assertExcluded(":*different*"); } @Test - public void testTypeIncluded() { + public void checkTypeIncluded() { assertIncluded("::type"); } @Test - public void testTypeExcluded() { + public void checkTypeExcluded() { assertExcluded("::differentType"); } @Test - public void testTypeWildcardIncluded() { + public void checkTypeWildcardIncluded() { assertIncluded("::*"); } @Test - public void testTypeImplicitWildcardIncluded() { + public void checkTypeImplicitWildcardIncluded() { assertIncluded("::"); } @Test - public void testTypeStartsWithWildcardIncluded() { + public void checkTypeStartsWithWildcardIncluded() { assertIncluded("::type*"); } @Test - public void testTypeStartsWithPartialWildcardIncluded() { + public void checkTypeStartsWithPartialWildcardIncluded() { assertIncluded("::t*"); } @Test - public void testTypeStartsWithWildcardExcluded() { + public void checkTypeStartsWithWildcardExcluded() { assertExcluded("::different*"); } @Test - public void testTypeEndsWithWildcardIncluded() { + public void checkTypeEndsWithWildcardIncluded() { assertIncluded("::*type"); } @Test - public void testTypeEndsWithPartialWildcardIncluded() { + public void checkTypeEndsWithPartialWildcardIncluded() { assertIncluded("::*e"); } @Test - public void testTypeEndsWithWildcardExcluded() { + public void checkTypeEndsWithWildcardExcluded() { assertExcluded("::*different"); } @Test - public void testTypeContainsWildcardIncluded() { + public void checkTypeContainsWildcardIncluded() { assertIncluded("::*yp*"); } @Test - public void testTypeContainsWildcardExcluded() { + public void checkTypeContainsWildcardExcluded() { assertExcluded("::*different*"); } @Test - public void testVersionIncluded() { + public void checkVersionIncluded() { assertIncluded(":::version"); } @Test - public void testVersionExcluded() { + public void checkVersionExcluded() { assertExcluded(":::differentVersion"); } @Test - public void testVersionWildcardIncluded() { + public void checkVersionWildcardIncluded() { assertIncluded(":::*"); } @Test - public void testVersionImplicitWildcardIncluded() { + public void checkVersionImplicitWildcardIncluded() { assertIncluded(":::"); } @Test - public void testVersionStartsWithWildcardIncluded() { + public void checkVersionStartsWithWildcardIncluded() { assertIncluded(":::version*"); } @Test - public void testVersionStartsWithPartialWildcardIncluded() { + public void checkVersionStartsWithPartialWildcardIncluded() { assertIncluded(":::ver*"); } @Test - public void testVersionStartsWithWildcardExcluded() { + public void checkVersionStartsWithWildcardExcluded() { assertExcluded(":::different*"); } @Test - public void testVersionEndsWithWildcardIncluded() { + public void checkVersionEndsWithWildcardIncluded() { assertIncluded(":::*version"); } @Test - public void testVersionEndsWithPartialWildcardIncluded() { + public void checkVersionEndsWithPartialWildcardIncluded() { assertIncluded(":::*ion"); } @Test - public void testVersionEndsWithWildcardExcluded() { + public void checkVersionEndsWithWildcardExcluded() { assertExcluded(":::*different"); } @Test - public void testVersionContainsWildcardIncluded() { + public void checkVersionContainsWildcardIncluded() { assertIncluded(":::*si*"); } @Test - public void testVersionContainsWildcardExcluded() { + public void checkVersionContainsWildcardExcluded() { assertExcluded(":::*different*"); } @Test - public void testComplex() { + public void checkComplex() { assertIncluded("group*:*Id:*:version"); } @Test - public void testSnapshotVersion() { + public void checkSnapshotVersion() { artifact = createArtifact("groupId", "artifactId", "type", "version-12345678.123456-1"); assertIncluded(":::*-SNAPSHOT"); } @Test - public void testRangeVersion() { + public void checkRangeVersion() { artifact = createArtifact("groupId", "artifactId", "type", "1.0.1"); assertIncluded("groupId:artifactId:type:[1.0.1]"); assertIncluded("groupId:artifactId:type:[1.0,1.1)"); @@ -320,7 +320,7 @@ public void testRangeVersion() { } @Test - public void testWildcardsWithRangeVersion() { + public void checkWildcardsWithRangeVersion() { artifact = createArtifact("groupId", "artifactId", "type", "1.0.1"); assertIncluded(":::[1.0.1]"); assertIncluded(":artifact*:*:[1.0,1.1)"); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java index dea56da..9e28968 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/GNPatternIncludesArtifactFilter.java @@ -239,7 +239,7 @@ public boolean hasMissedCriteria() { private static final char[] ANY = new char[] {'*'}; static char[] emptyOrChars(String str) { - return str != null && str.length() > 0 ? str.toCharArray() : EMPTY; + return str != null && !str.isEmpty() ? str.toCharArray() : EMPTY; } static char[] anyOrChars(char[] str) { diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java index 3b67083..3258dfb 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/OldPatternIncludesArtifactFilter.java @@ -215,7 +215,7 @@ private boolean matches(final String token, final String pattern) { boolean matches; // support full wildcard and implied wildcard - if ("*".equals(pattern) || pattern.length() == 0) { + if ("*".equals(pattern) || pattern.isEmpty()) { matches = true; } // support contains wildcard diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java index 46f44b4..1cde74d 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/ScopeArtifactFilterTest.java @@ -22,17 +22,17 @@ import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class ScopeArtifactFilterTest { +class ScopeArtifactFilterTest { @Test - public void testExcludedArtifactWithRangeShouldNotCauseNPE() throws Exception { + void checkExcludedArtifactWithRangeShouldNotCauseNPE() throws Exception { ArtifactStubFactory factory = new ArtifactStubFactory(); Artifact excluded = factory.createArtifact( @@ -50,7 +50,7 @@ public void testExcludedArtifactWithRangeShouldNotCauseNPE() throws Exception { } @Test - public void testNullScopeDisabled() { + void checkNullScopeDisabled() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeNullScope(false); @@ -58,7 +58,7 @@ public void testNullScopeDisabled() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_TestScope() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledTestScope() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeTestScope(true); @@ -71,7 +71,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_TestScope() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_CompileScope() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledCompileScope() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeCompileScope(true); @@ -84,7 +84,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_CompileScope() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_RuntimeScope() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledRuntimeScope() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeRuntimeScope(true); @@ -97,7 +97,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_RuntimeScope() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedScope() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledProvidedScope() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeProvidedScope(true); @@ -110,7 +110,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedScope() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemScope() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledSystemScope() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeSystemScope(true); @@ -123,7 +123,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemScope() { } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedAndRuntimeScopes() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledProvidedAndRuntimeScopes() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeRuntimeScope(true); filter.setIncludeProvidedScope(true); @@ -137,7 +137,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_ProvidedAndRuntimeS } @Test - public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemAndRuntimeScopes() { + void checkFineGrainedIncludeOnlyScopesThatWereEnabledSystemAndRuntimeScopes() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeRuntimeScope(true); filter.setIncludeSystemScope(true); @@ -151,8 +151,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemAndRuntimeSco } @Test - public void - testFineGrainedWithImplications_CompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() { + void checkFineGrainedWithImplicationsCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeCompileScopeWithImplications(true); @@ -166,7 +165,7 @@ public void testFineGrained_IncludeOnlyScopesThatWereEnabled_SystemAndRuntimeSco } @Test - public void testFineGrainedWithImplications_RuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() { + void checkFineGrainedWithImplicationsRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeRuntimeScopeWithImplications(true); @@ -180,7 +179,7 @@ public void testFineGrainedWithImplications_RuntimeScopeShouldIncludeOnlyArtifac } @Test - public void testFineGrainedWithImplications_TestScopeShouldIncludeAllScopes() { + void checkFineGrainedWithImplicationsTestScopeShouldIncludeAllScopes() { ScopeArtifactFilter filter = new ScopeArtifactFilter(); filter.setIncludeTestScopeWithImplications(true); @@ -194,7 +193,7 @@ public void testFineGrainedWithImplications_TestScopeShouldIncludeAllScopes() { } @Test - public void testScopesShouldIncludeArtifactWithSameScope() { + void checkScopesShouldIncludeArtifactWithSameScope() { verifyIncluded(Artifact.SCOPE_COMPILE, Artifact.SCOPE_COMPILE); verifyIncluded(Artifact.SCOPE_PROVIDED, Artifact.SCOPE_PROVIDED); verifyIncluded(Artifact.SCOPE_RUNTIME, Artifact.SCOPE_RUNTIME); @@ -204,7 +203,7 @@ public void testScopesShouldIncludeArtifactWithSameScope() { } @Test - public void testCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() { + void checkCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCompileScopes() { String scope = Artifact.SCOPE_COMPILE; verifyIncluded(scope, null); @@ -217,7 +216,7 @@ public void testCompileScopeShouldIncludeOnlyArtifactsWithNullSystemProvidedOrCo } @Test - public void testRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() { + void checkRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileScopes() { String scope = Artifact.SCOPE_RUNTIME; verifyIncluded(scope, null); @@ -230,7 +229,7 @@ public void testRuntimeScopeShouldIncludeOnlyArtifactsWithNullRuntimeOrCompileSc } @Test - public void testTestScopeShouldIncludeAllScopes() { + void checkScopeShouldIncludeAllScopes() { String scope = Artifact.SCOPE_TEST; verifyIncluded(scope, null); @@ -243,7 +242,7 @@ public void testTestScopeShouldIncludeAllScopes() { } @Test - public void testProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes() { + void checkProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes() { String scope = Artifact.SCOPE_PROVIDED; verifyIncluded(scope, null); @@ -257,7 +256,7 @@ public void testProvidedScopeShouldIncludeOnlyArtifactsWithNullOrProvidedScopes( } @Test - public void testSystemScopeShouldIncludeOnlyArtifactsWithNullOrSystemScopes() { + void checkSystemScopeShouldIncludeOnlyArtifactsWithNullOrSystemScopes() { String scope = Artifact.SCOPE_SYSTEM; verifyIncluded(scope, null); @@ -276,8 +275,8 @@ private void verifyIncluded(String filterScope, String artifactScope) { ArtifactFilter filter = new ScopeArtifactFilter(filterScope); assertTrue( - "Artifact scope: " + artifactScope + " NOT included using filter scope: " + filterScope, - filter.include(artifact)); + filter.include(artifact), + "Artifact scope: " + artifactScope + " NOT included using filter scope: " + filterScope); } private void verifyExcluded(String filterScope, String artifactScope) { @@ -286,20 +285,20 @@ private void verifyExcluded(String filterScope, String artifactScope) { ArtifactFilter filter = new ScopeArtifactFilter(filterScope); assertFalse( - "Artifact scope: " + artifactScope + " NOT excluded using filter scope: " + filterScope, - filter.include(artifact)); + filter.include(artifact), + "Artifact scope: " + artifactScope + " NOT excluded using filter scope: " + filterScope); } private void verifyIncluded(ScopeArtifactFilter filter, String artifactScope) { Artifact artifact = createMockArtifact(artifactScope); - assertTrue("Artifact scope: " + artifactScope + " SHOULD BE included", filter.include(artifact)); + assertTrue(filter.include(artifact), "Artifact scope: " + artifactScope + " SHOULD BE included"); } private void verifyExcluded(ScopeArtifactFilter filter, String artifactScope) { Artifact artifact = createMockArtifact(artifactScope); - assertFalse("Artifact scope: " + artifactScope + " SHOULD BE excluded", filter.include(artifact)); + assertFalse(filter.include(artifact), "Artifact scope: " + artifactScope + " SHOULD BE excluded"); } private Artifact createMockArtifact(String scope) { diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java index e00e136..5e6800f 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/AbstractArtifactFeatureFilterTest.java @@ -25,9 +25,9 @@ import java.util.Set; import org.apache.maven.artifact.Artifact; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Abstract test case for subclasses of AbstractArtifactFeatureFilter @@ -48,7 +48,7 @@ private Object createObjectViaReflection(Class clazz, Object[] conArgs) } @Test - public abstract void testParsing() throws Exception; + public abstract void checkParsing() throws Exception; public void parsing() throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, @@ -69,7 +69,7 @@ public void parsing() } @Test - public abstract void testFiltering() throws Exception; + public abstract void checkFiltering() throws Exception; public Set filtering() throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException, @@ -83,7 +83,7 @@ public Set filtering() } @Test - public abstract void testFiltering2() throws Exception; + public abstract void checkFiltering2() throws Exception; public Set filtering2() throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException, @@ -97,7 +97,7 @@ public Set filtering2() } @Test - public abstract void testFiltering3() throws Exception; + public abstract void checkFiltering3() throws Exception; public void filtering3() throws SecurityException, IllegalArgumentException, NoSuchMethodException, InstantiationException, diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java index c80a187..91e656f 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestArtifactFilter.java @@ -22,31 +22,31 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * TestCases for ArtifactFilter */ -public class TestArtifactFilter extends AbstractArtifactFeatureFilterTest { +class TestArtifactFilter extends AbstractArtifactFeatureFilterTest { - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { filterClass = ArtifactIdFilter.class; ArtifactStubFactory factory = new ArtifactStubFactory(null, false); artifacts = factory.getArtifactArtifacts(); } @Test - public void testParsing() throws Exception { + public void checkParsing() throws Exception { parsing(); } @Test - public void testFiltering() throws Exception { + public void checkFiltering() throws Exception { Set result = filtering(); for (Artifact artifact : result) { assertEquals("two", artifact.getArtifactId()); @@ -54,7 +54,7 @@ public void testFiltering() throws Exception { } @Test - public void testFiltering2() throws Exception { + public void checkFiltering2() throws Exception { Set result = filtering2(); for (Artifact artifact : result) { assertTrue(artifact.getArtifactId().equals("two") @@ -63,7 +63,7 @@ public void testFiltering2() throws Exception { } @Test - public void testFiltering3() throws Exception { + public void checkFiltering3() throws Exception { filtering3(); } } diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java index 2577318..8935a9c 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestClassifierFilter.java @@ -22,30 +22,30 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * Test case for ClassifierFilter */ -public class TestClassifierFilter extends AbstractArtifactFeatureFilterTest { +class TestClassifierFilter extends AbstractArtifactFeatureFilterTest { - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { filterClass = ClassifierFilter.class; ArtifactStubFactory factory = new ArtifactStubFactory(null, false); artifacts = factory.getClassifiedArtifacts(); } @Test - public void testParsing() throws Exception { + public void checkParsing() throws Exception { parsing(); } @Test - public void testFiltering() throws Exception { + public void checkFiltering() throws Exception { Set result = filtering(); for (Artifact artifact : result) { assertTrue(artifact.getClassifier().equals("one") @@ -54,7 +54,7 @@ public void testFiltering() throws Exception { } @Test - public void testFiltering2() throws Exception { + public void checkFiltering2() throws Exception { Set result = filtering2(); for (Artifact artifact : result) { assertTrue(artifact.getClassifier().equals("two") @@ -63,7 +63,7 @@ public void testFiltering2() throws Exception { } @Test - public void testFiltering3() throws Exception { + public void checkFiltering3() throws Exception { filtering3(); } } diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java index 361741c..3fb1118 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestFilterArtifacts.java @@ -27,17 +27,16 @@ import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.*; /** * @author Brian Fox */ -public class TestFilterArtifacts { +class TestFilterArtifacts { @Test - public void testNullFilters() throws IOException, ArtifactFilterException { + void checkNullFilters() throws IOException, ArtifactFilterException { // TODO: convert these old tests to use the abstract test case for dep // plugin @@ -69,7 +68,7 @@ public void testNullFilters() throws IOException, ArtifactFilterException { } @Test - public void testArtifactFilter() { + void checkArtifactFilter() { Set a = new HashSet<>(); FilterArtifacts fa = new FilterArtifacts(); ArtifactsFilter scope = new ScopeFilter("compile", "system"); @@ -81,13 +80,13 @@ public void testArtifactFilter() { assertEquals(1, fa.getFilters().size()); fa.addFilter(type); assertEquals(2, fa.getFilters().size()); - assertTrue(fa.getFilters().get(0) instanceof ScopeFilter); - assertTrue(fa.getFilters().get(1) instanceof TypeFilter); + assertInstanceOf(ScopeFilter.class, fa.getFilters().get(0)); + assertInstanceOf(TypeFilter.class, fa.getFilters().get(1)); fa.addFilter(1, trans); assertEquals(3, fa.getFilters().size()); - assertTrue(fa.getFilters().get(0) instanceof ScopeFilter); - assertTrue(fa.getFilters().get(1) instanceof ProjectTransitivityFilter); - assertTrue(fa.getFilters().get(2) instanceof TypeFilter); + assertInstanceOf(ScopeFilter.class, fa.getFilters().get(0)); + assertInstanceOf(ProjectTransitivityFilter.class, fa.getFilters().get(1)); + assertInstanceOf(TypeFilter.class, fa.getFilters().get(2)); ArrayList list = new ArrayList<>(fa.getFilters()); @@ -96,13 +95,13 @@ public void testArtifactFilter() { fa.setFilters(list); assertEquals(3, fa.getFilters().size()); - assertTrue(fa.getFilters().get(0) instanceof ScopeFilter); - assertTrue(fa.getFilters().get(1) instanceof ProjectTransitivityFilter); - assertTrue(fa.getFilters().get(2) instanceof TypeFilter); + assertInstanceOf(ScopeFilter.class, fa.getFilters().get(0)); + assertInstanceOf(ProjectTransitivityFilter.class, fa.getFilters().get(1)); + assertInstanceOf(TypeFilter.class, fa.getFilters().get(2)); } @Test - public void testArtifactFilterWithClassifier() throws IOException, ArtifactFilterException { + void checkArtifactFilterWithClassifier() throws IOException, ArtifactFilterException { File outputFolder = new File("target/filters/"); FileUtils.deleteDirectory(outputFolder); ArtifactStubFactory fact = new ArtifactStubFactory(outputFolder, false); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java index 906c14f..660e842 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestGroupIdFilter.java @@ -22,31 +22,31 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * TestCases for GroupIdFilter */ -public class TestGroupIdFilter extends AbstractArtifactFeatureFilterTest { +class TestGroupIdFilter extends AbstractArtifactFeatureFilterTest { - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { filterClass = GroupIdFilter.class; ArtifactStubFactory factory = new ArtifactStubFactory(null, false); artifacts = factory.getGroupIdArtifacts(); } @Test - public void testParsing() throws Exception { + public void checkParsing() throws Exception { parsing(); } @Test - public void testFiltering() throws Exception { + public void checkFiltering() throws Exception { Set result = filtering(); for (Artifact artifact : result) { assertTrue( @@ -55,7 +55,7 @@ public void testFiltering() throws Exception { } @Test - public void testFiltering2() throws Exception { + public void checkFiltering2() throws Exception { Set result = filtering2(); for (Artifact artifact : result) { assertTrue( @@ -64,12 +64,12 @@ public void testFiltering2() throws Exception { } @Test - public void testFiltering3() throws Exception { + public void checkFiltering3() throws Exception { filtering3(); } @Test - public void testFiltering4() throws Exception { + void chckFiltering4() throws Exception { // include o* from groupIds one,two should leave one Set result = filtering(); assertEquals(1, result.size()); @@ -90,7 +90,7 @@ public void testFiltering4() throws Exception { } @Test - public void testMultipleInclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException { + void checkMultipleInclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException { ArtifactsFilter filter = new GroupIdFilter("one,two", null); assertEquals(4, artifacts.size()); @@ -101,7 +101,7 @@ public void testMultipleInclude() throws SecurityException, IllegalArgumentExcep } @Test - public void testMultipleExclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException { + void checkMultipleExclude() throws SecurityException, IllegalArgumentException, ArtifactFilterException { ArtifactsFilter filter = new GroupIdFilter(null, "one,two"); assertEquals(4, artifacts.size()); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java index 322c640..93235f9 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestProjectTransitivityFilter.java @@ -22,23 +22,23 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * @author Brian Fox */ -public class TestProjectTransitivityFilter { +class TestProjectTransitivityFilter { Set artifacts; Set directArtifacts; Set classifiedArtifacts; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { ArtifactStubFactory fact = new ArtifactStubFactory(null, false); artifacts = fact.getScopedArtifacts(); directArtifacts = fact.getReleaseAndSnapshotArtifacts(); @@ -48,14 +48,14 @@ public void setUp() throws Exception { } @Test - public void testAll() { + void checkAll() { ProjectTransitivityFilter filter = new ProjectTransitivityFilter(directArtifacts, false); Set result = filter.filter(artifacts); assertEquals(11, result.size()); } @Test - public void testExclude() { + void checkExclude() { ProjectTransitivityFilter filter = new ProjectTransitivityFilter(directArtifacts, false); assertFalse(filter.isExcludeTransitive()); filter.setExcludeTransitive(true); @@ -71,7 +71,7 @@ public void testExclude() { } @Test - public void testClassified() { + void checkClassified() { ProjectTransitivityFilter filter = new ProjectTransitivityFilter(classifiedArtifacts, true); Set result = filter.filter(artifacts); assertEquals(4, result.size()); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java index 60231a6..ffbcacc 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestScopeFilter.java @@ -22,138 +22,137 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; /** * @author Brian Fox */ -public class TestScopeFilter { +class TestScopeFilter { Set artifacts; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { ArtifactStubFactory factory = new ArtifactStubFactory(null, false); artifacts = factory.getScopedArtifacts(); } @Test - public void testScopeCompile() throws ArtifactFilterException { + void checkScopeCompile() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_COMPILE, null); Set result = filter.filter(artifacts); assertEquals(3, result.size()); } @Test - public void testScopeRuntime() throws ArtifactFilterException { + void checkScopeRuntime() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_RUNTIME, null); Set result = filter.filter(artifacts); assertEquals(2, result.size()); } @Test - public void testScopeTest() throws ArtifactFilterException { + void checkScopeTest() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_TEST, null); Set result = filter.filter(artifacts); assertEquals(5, result.size()); } @Test - public void testScopeProvided() throws ArtifactFilterException { + void checkScopeProvided() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_PROVIDED, null); Set result = filter.filter(artifacts); - assertTrue(result.size() > 0); + assertFalse(result.isEmpty()); for (Artifact artifact : result) { assertEquals(Artifact.SCOPE_PROVIDED, artifact.getScope()); } } @Test - public void testScopeSystem() throws ArtifactFilterException { + void checkScopeSystem() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(Artifact.SCOPE_SYSTEM, null); Set result = filter.filter(artifacts); - assertTrue(result.size() > 0); + assertFalse(result.isEmpty()); for (Artifact artifact : result) { assertEquals(Artifact.SCOPE_SYSTEM, artifact.getScope()); } } @Test - public void testScopeFilterNull() throws ArtifactFilterException { + void checkScopeFilterNull() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter(null, null); Set result = filter.filter(artifacts); assertEquals(5, result.size()); } @Test - public void testScopeFilterEmpty() throws ArtifactFilterException { + void checkScopeFilterEmpty() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter("", ""); Set result = filter.filter(artifacts); assertEquals(5, result.size()); } @Test - public void testExcludeProvided() throws ArtifactFilterException { + void checkExcludeProvided() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_PROVIDED); Set result = filter.filter(artifacts); assertNotNull(result); - assertTrue(result.size() > 0); + assertFalse(result.isEmpty()); for (Artifact artifact : result) { assertFalse(Artifact.SCOPE_PROVIDED.equalsIgnoreCase(artifact.getScope())); } } @Test - public void testExcludeSystem() throws ArtifactFilterException { + void checkExcludeSystem() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_SYSTEM); Set result = filter.filter(artifacts); assertNotNull(result); - assertTrue(result.size() > 0); + assertFalse(result.isEmpty()); for (Artifact artifact : result) { assertFalse(Artifact.SCOPE_SYSTEM.equalsIgnoreCase(artifact.getScope())); } } @Test - public void testExcludeCompile() throws ArtifactFilterException { + void checkExcludeCompile() throws ArtifactFilterException { ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_COMPILE); Set result = filter.filter(artifacts); assertEquals(2, result.size()); } @Test - public void testExcludeTest() { + void checkExcludeTest() { try { ScopeFilter filter = new ScopeFilter("", Artifact.SCOPE_TEST); filter.filter(artifacts); - Assert.fail("Expected an Exception"); + fail("Expected an Exception"); } catch (ArtifactFilterException ignored) { } } @Test - public void testBadScope() { + void checkBadScope() { ScopeFilter filter = new ScopeFilter("cOmpile", ""); try { filter.filter(artifacts); - Assert.fail("Expected an Exception"); + fail("Expected an Exception"); } catch (ArtifactFilterException ignored) { } try { filter = new ScopeFilter("", "coMpile"); filter.filter(artifacts); - Assert.fail("Expected an Exception"); + fail("Expected an Exception"); } catch (ArtifactFilterException ignored) { } } @Test - public void testSettersGetters() { + void checkSettersGetters() { ScopeFilter filter = new ScopeFilter("include", "exclude"); assertEquals("include", filter.getIncludeScope()); assertEquals("exclude", filter.getExcludeScope()); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java index 7f84056..db7e013 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/collection/TestTypeFilter.java @@ -26,26 +26,26 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.testing.ArtifactStubFactory; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; /** * @author Brian Fox */ -public class TestTypeFilter { +class TestTypeFilter { Set artifacts; - @Before - public void setUp() throws Exception { + @BeforeEach + void setUp() throws Exception { ArtifactStubFactory factory = new ArtifactStubFactory(null, false); artifacts = factory.getTypedArtifacts(); } @Test - public void testTypeParsing() { + void checkTypeParsing() { TypeFilter filter = new TypeFilter("war,jar", "sources,zip,"); List includes = filter.getIncludes(); List excludes = filter.getExcludes(); @@ -59,7 +59,7 @@ public void testTypeParsing() { } @Test - public void testFiltering() { + void checkFiltering() { TypeFilter filter = new TypeFilter("war,jar", "war,zip,"); Set result = filter.filter(artifacts); assertEquals(1, result.size()); @@ -70,7 +70,7 @@ public void testFiltering() { } @Test - public void testFiltering2() { + void checkFiltering2() { TypeFilter filter = new TypeFilter(null, "war,jar,"); Set result = filter.filter(artifacts); assertEquals(3, result.size()); @@ -81,14 +81,14 @@ public void testFiltering2() { } @Test - public void testFiltering3() { + void checkFiltering3() { TypeFilter filter = new TypeFilter(null, null); Set result = filter.filter(artifacts); assertEquals(5, result.size()); } @Test - public void testFilteringOrder() throws IOException { + void checkFilteringOrder() throws IOException { TypeFilter filter = new TypeFilter("war,jar", "zip"); Set artifacts = new LinkedHashSet<>(); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java index b310498..c3708d9 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeFilterTransformerTest.java @@ -37,25 +37,25 @@ import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter; import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class ArtifactIncludeFilterTransformerTest { +class ArtifactIncludeFilterTransformerTest { private ArtifactIncludeFilterTransformer transformer; private final ArtifactStubFactory artifactFactory = new ArtifactStubFactory(); - @Before - public void setUp() { + @BeforeEach + void setUp() { transformer = new ArtifactIncludeFilterTransformer(); } @Test - public void testTransformAndFilter() throws Exception { + void checkTransformAndFilter() throws Exception { AndFilter filter = new AndFilter(Arrays.asList( ScopeFilter.including("compile"), new ExclusionsFilter(Collections.singletonList("x:a")))); @@ -71,7 +71,7 @@ public void testTransformAndFilter() throws Exception { } @Test - public void testTransformExclusionsFilter() throws Exception { + void checkTransformExclusionsFilter() throws Exception { ExclusionsFilter filter = new ExclusionsFilter(Collections.singletonList("x:a")); ArtifactFilter dependencyFilter = filter.transform(transformer); @@ -82,7 +82,7 @@ public void testTransformExclusionsFilter() throws Exception { } @Test - public void testTransformOrFilter() throws Exception { + void checkTransformOrFilter() throws Exception { OrFilter filter = new OrFilter(Arrays.asList(ScopeFilter.including("compile"), ScopeFilter.including("test"))); ArtifactFilter dependencyFilter = filter.transform(transformer); @@ -95,7 +95,7 @@ public void testTransformOrFilter() throws Exception { } @Test - public void testTransformScopeFilter() throws Exception { + void checkTransformScopeFilter() throws Exception { ScopeFilter filter = ScopeFilter.including(Collections.singletonList("runtime")); ArtifactFilter dependencyFilter = filter.transform(transformer); @@ -108,7 +108,7 @@ public void testTransformScopeFilter() throws Exception { } @Test - public void testTransformScopeFilterIncludeNullScope() throws Exception { + void checkTransformScopeFilterIncludeNullScope() throws Exception { ScopeFilter filter = ScopeFilter.including(); Artifact artifact = newArtifact("g:a:v", null); @@ -122,7 +122,7 @@ public void testTransformScopeFilterIncludeNullScope() throws Exception { } @Test - public void testTransformPatternExclusionsFilter() throws Exception { + void checkTransformPatternExclusionsFilter() throws Exception { PatternExclusionsFilter filter = new PatternExclusionsFilter(Collections.singletonList("x:*")); PatternExcludesArtifactFilter dependencyFilter = (PatternExcludesArtifactFilter) filter.transform(transformer); @@ -133,7 +133,7 @@ public void testTransformPatternExclusionsFilter() throws Exception { } @Test - public void testTransformPatternExclusionsFilterActTransitivily() throws Exception { + void checkTransformPatternExclusionsFilterActTransitivily() throws Exception { PatternExclusionsFilter filter = new PatternExclusionsFilter(Collections.singletonList("x:*")); transformer.setActTransitivelyPattern(true); @@ -156,7 +156,7 @@ public void testTransformPatternExclusionsFilterActTransitivily() throws Excepti } @Test - public void testTransformPatternInclusionsFilter() throws Exception { + void checkTransformPatternInclusionsFilter() throws Exception { PatternInclusionsFilter filter = new PatternInclusionsFilter(Collections.singletonList("g:*")); PatternIncludesArtifactFilter dependencyFilter = (PatternIncludesArtifactFilter) filter.transform(transformer); @@ -167,7 +167,7 @@ public void testTransformPatternInclusionsFilter() throws Exception { } @Test - public void testTransformPatternInclusionsFilterActTransitivily() throws Exception { + void checkTransformPatternInclusionsFilterActTransitivily() throws Exception { PatternInclusionsFilter filter = new PatternInclusionsFilter(Collections.singletonList("x:*")); transformer.setActTransitivelyPattern(true); @@ -190,7 +190,7 @@ public void testTransformPatternInclusionsFilterActTransitivily() throws Excepti } @Test - public void testTransformAbstractFilter() throws Exception { + void checkTransformAbstractFilter() throws Exception { AbstractFilter snapshotFilter = new AbstractFilter() { @Override public boolean accept(Node node, List parents) { diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java index e4e99f4..126cc18 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/ArtifactIncludeNodeTest.java @@ -23,15 +23,15 @@ import org.apache.maven.model.Dependency; import org.apache.maven.plugin.testing.ArtifactStubFactory; import org.apache.maven.shared.artifact.filter.resolve.Node; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -public class ArtifactIncludeNodeTest { +class ArtifactIncludeNodeTest { private final ArtifactStubFactory artifactFactory = new ArtifactStubFactory(); @Test - public void testGAV() throws Exception { + void checkGav() throws Exception { Node node = new ArtifactIncludeNode(newArtifact("g:a:v", null)); Dependency dependency = node.getDependency(); @@ -45,7 +45,7 @@ public void testGAV() throws Exception { } @Test - public void testClassifier() throws Exception { + void checkClassifier() throws Exception { Node node = new ArtifactIncludeNode(newArtifact("g:a::c:v", null)); Dependency dependency = node.getDependency(); @@ -59,7 +59,7 @@ public void testClassifier() throws Exception { } @Test - public void testType() throws Exception { + void checkType() throws Exception { Node node = new ArtifactIncludeNode(newArtifact("g:a:pom:v", null)); Dependency dependency = node.getDependency(); @@ -72,7 +72,7 @@ public void testType() throws Exception { } @Test - public void testScope() throws Exception { + void checkScope() throws Exception { Node node = new ArtifactIncludeNode(newArtifact("g:a:v", "s")); Dependency dependency = node.getDependency(); @@ -86,7 +86,7 @@ public void testScope() throws Exception { } @Test - public void testOptional() throws Exception { + void checkOptional() throws Exception { Node node = new ArtifactIncludeNode(newArtifact("g:a:pom:v", null, null)); assertEquals("false", node.getDependency().getOptional()); diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java index 1f75c92..8c42772 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherFilterTransformerTest.java @@ -31,7 +31,6 @@ import org.apache.maven.shared.artifact.filter.resolve.PatternExclusionsFilter; import org.apache.maven.shared.artifact.filter.resolve.PatternInclusionsFilter; import org.apache.maven.shared.artifact.filter.resolve.ScopeFilter; -import org.apache.maven.shared.artifact.filter.resolve.TransformableFilter; import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.graph.DefaultDependencyNode; import org.eclipse.aether.graph.Dependency; @@ -43,126 +42,106 @@ import org.eclipse.aether.util.filter.PatternExclusionsDependencyFilter; import org.eclipse.aether.util.filter.PatternInclusionsDependencyFilter; import org.eclipse.aether.util.filter.ScopeDependencyFilter; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class EclipseAetherFilterTransformerTest { +class EclipseAetherFilterTransformerTest { private final EclipseAetherFilterTransformer transformer = new EclipseAetherFilterTransformer(); @Test - public void testTransformAndFilter() { + void checkTransformAndFilter() { AndFilter filter = new AndFilter(Arrays.asList( ScopeFilter.including("compile"), new ExclusionsFilter(Collections.singletonList("x:a")))); AndDependencyFilter dependencyFilter = (AndDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "compile"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "compile"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("x:a:v", "compile"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v", "compile"), Collections.emptyList())); - assertFalse( - dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); - assertFalse( - dependencyFilter.accept(newDependencyNode("x:a:v", "test"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v", "test"), Collections.emptyList())); } @Test - public void testTransformExclusionsFilter() { + void checkTransformExclusionsFilter() { ExclusionsFilter filter = new ExclusionsFilter(Collections.singletonList("x:a")); ExclusionsDependencyFilter dependencyFilter = (ExclusionsDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "compile"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "compile"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("x:a:v", "compile"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v", "compile"), Collections.emptyList())); } @Test - public void testTransformOrFilter() { - OrFilter filter = new OrFilter( - Arrays.asList(ScopeFilter.including("compile"), ScopeFilter.including("test"))); + void checkTransformOrFilter() { + OrFilter filter = new OrFilter(Arrays.asList(ScopeFilter.including("compile"), ScopeFilter.including("test"))); OrDependencyFilter dependencyFilter = (OrDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "compile"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "compile"), Collections.emptyList())); - assertTrue( - dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); } @Test - public void testTransformScopeFilter() { + void checkTransformScopeFilter() { ScopeFilter filter = ScopeFilter.including(Collections.singletonList("runtime")); ScopeDependencyFilter dependencyFilter = (ScopeDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("g:a:v", "compile"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:v", "compile"), Collections.emptyList())); - assertFalse( - dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:v", "test"), Collections.emptyList())); } @Test - public void testTransformPatternExclusionsFilter() { + void checkTransformPatternExclusionsFilter() { PatternExclusionsFilter filter = new PatternExclusionsFilter(Collections.singletonList("x:*")); PatternExclusionsDependencyFilter dependencyFilter = (PatternExclusionsDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("x:a:v", "runtime"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v", "runtime"), Collections.emptyList())); } @Test - public void testTransformPatternInclusionsFilter() { + void checkTransformPatternInclusionsFilter() { PatternInclusionsFilter filter = new PatternInclusionsFilter(Collections.singletonList("g:*")); PatternInclusionsDependencyFilter dependencyFilter = (PatternInclusionsDependencyFilter) filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("x:a:v", "runtime"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v", "runtime"), Collections.emptyList())); } @Test - public void testTransformClassifierPatternInclusionsFilter() { + void checkTransformClassifierPatternInclusionsFilter() { PatternInclusionsFilter filter = new PatternInclusionsFilter(Collections.singletonList("g:*:*:c:*")); DependencyFilter dependencyFilter = filter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:v:c:*", "runtime"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:v:c:*", "runtime"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:v", "runtime"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("x:a:v:c:*", "runtime"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("x:a:v:c:*", "runtime"), Collections.emptyList())); } @Test - public void testTransformAbstractFilter() { + void checkTransformAbstractFilter() { AbstractFilter snapshotFilter = new AbstractFilter() { @Override public boolean accept(Node node, List parents) { @@ -172,11 +151,9 @@ public boolean accept(Node node, List parents) { DependencyFilter dependencyFilter = snapshotFilter.transform(transformer); - assertTrue(dependencyFilter.accept( - newDependencyNode("g:a:1.0-SNAPSHOT", "compile"), Collections.emptyList())); + assertTrue(dependencyFilter.accept(newDependencyNode("g:a:1.0-SNAPSHOT", "compile"), Collections.emptyList())); - assertFalse(dependencyFilter.accept( - newDependencyNode("g:a:1.0", "compile"), Collections.emptyList())); + assertFalse(dependencyFilter.accept(newDependencyNode("g:a:1.0", "compile"), Collections.emptyList())); } private DependencyNode newDependencyNode(String string, String scope) { diff --git a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java index 1ee82a5..737fddd 100644 --- a/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java +++ b/src/test/java/org/apache/maven/shared/artifact/filter/resolve/transform/EclipseAetherNodeTest.java @@ -28,13 +28,13 @@ import org.eclipse.aether.graph.Dependency; import org.eclipse.aether.graph.DependencyNode; import org.eclipse.aether.graph.Exclusion; -import org.junit.Test; +import org.junit.jupiter.api.Test; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.*; -public class EclipseAetherNodeTest { +class EclipseAetherNodeTest { @Test - public void testGAV() { + void checkGav() { Node node = new EclipseAetherNode(newDependencyNode("g:a:v", null)); org.apache.maven.model.Dependency mavenDependency = node.getDependency(); @@ -48,7 +48,7 @@ public void testGAV() { } @Test - public void testClassifier() { + void checkClassifier() { Node node = new EclipseAetherNode(newDependencyNode("g:a::c:v", null)); org.apache.maven.model.Dependency mavenDependency = node.getDependency(); @@ -62,7 +62,7 @@ public void testClassifier() { } @Test - public void testScope() { + void checkScope() { Node node = new EclipseAetherNode(newDependencyNode("g:a:c:v", "s")); org.apache.maven.model.Dependency mavenDependency = node.getDependency(); @@ -76,7 +76,7 @@ public void testScope() { } @Test - public void testOptional() { + void checkOptional() { Node node = new EclipseAetherNode(newDependencyNode("g:a:v", null, (Boolean) null)); assertNull(node.getDependency().getOptional()); @@ -92,7 +92,7 @@ public void testOptional() { } @Test - public void testExclusions() { + void checkExclusions() { Node node = new EclipseAetherNode(newDependencyNode("g:a:v", null, Collections.singletonList("eg:ea"))); assertEquals(1, node.getDependency().getExclusions().size());