diff --git a/src/test/java/org/apache/maven/plugins/dependency/RemoveDependencyMojoTest.java b/src/test/java/org/apache/maven/plugins/dependency/RemoveDependencyMojoTest.java index 06a5014b3..449493636 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/RemoveDependencyMojoTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/RemoveDependencyMojoTest.java @@ -38,6 +38,8 @@ import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.contains; @@ -157,7 +159,7 @@ void typeParameterUsedForMatching() throws Exception { mojo.execute(); String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); - assertTrue(!result.contains("test-jar"), "test-jar variant should be removed"); + assertFalse(result.contains("test-jar"), "test-jar variant should be removed"); assertTrue(result.contains("com.example"), "jar variant should remain"); } @@ -205,7 +207,7 @@ void modelSyncPreservesOtherVariantsOnRemove() throws Exception { mojo.execute(); // In-memory model should still have the jar variant - assertTrue(model.getDependencies().size() == 1, "model should have 1 dependency remaining"); + assertEquals(1, model.getDependencies().size(), "model should have 1 dependency remaining"); assertTrue( "jar".equals(model.getDependencies().get(0).getType()) || model.getDependencies().get(0).getType() == null, @@ -275,7 +277,7 @@ void removeDependencyFromProfileSucceeds() throws Exception { mojo.execute(); String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); - assertTrue(!result.contains("com.example"), "dependency should be removed"); + assertFalse(result.contains("com.example"), "dependency should be removed"); assertTrue(result.contains("dev"), "profile should remain"); } @@ -328,7 +330,7 @@ void managedRemovalWithChildModulesWarnsAndProceeds() throws Exception { assertDoesNotThrow(() -> mojo.execute()); String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); - assertTrue(!result.contains("lib"), "managed dep should be removed"); + assertFalse(result.contains("lib"), "managed dep should be removed"); } @Test @@ -374,7 +376,7 @@ void managedRemovalWithChildModulePomPathWarnsAndProceeds() throws Exception { assertDoesNotThrow(() -> mojo.execute()); String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); - assertTrue(!result.contains("lib"), "managed dep should be removed"); + assertFalse(result.contains("lib"), "managed dep should be removed"); verify(log).warn(contains("child-a/my-pom.xml")); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java index bef7be30b..62098d61d 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/TestCollectMojo.java @@ -34,8 +34,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; @MojoTest class TestCollectMojo { @@ -105,7 +105,7 @@ void testSilent(CollectDependenciesMojo mojo) throws Exception { assertFalse(mojo.getLog() instanceof DependencySilentLog); mojo.setSilent(true); - assertTrue(mojo.getLog() instanceof DependencySilentLog); + assertInstanceOf(DependencySilentLog.class, mojo.getLog()); mojo.setSilent(false); assertFalse(mojo.getLog() instanceof DependencySilentLog); diff --git a/src/test/java/org/apache/maven/plugins/dependency/pom/PomEditorTest.java b/src/test/java/org/apache/maven/plugins/dependency/pom/PomEditorTest.java index 4cb1081ce..e6a9f4a06 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/pom/PomEditorTest.java +++ b/src/test/java/org/apache/maven/plugins/dependency/pom/PomEditorTest.java @@ -752,9 +752,9 @@ void addDependencyIgnoresEmptyStringFields() throws IOException { String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); assertTrue(result.contains("1.0"), "version should be present"); - assertTrue(!result.contains(""), "empty scope should not create element"); - assertTrue(!result.contains(""), "empty type should not create element"); - assertTrue(!result.contains(""), "empty classifier should not create element"); + assertFalse(result.contains(""), "empty scope should not create element"); + assertFalse(result.contains(""), "empty type should not create element"); + assertFalse(result.contains(""), "empty classifier should not create element"); } @Test @@ -856,7 +856,7 @@ void removeDependencyFromProfile() throws IOException { assertTrue(removed, "should find and remove the profile dependency"); String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8); - assertTrue(!result.contains("profile-lib"), "profile dep should be removed"); + assertFalse(result.contains("profile-lib"), "profile dep should be removed"); assertTrue(result.contains("top-level"), "top-level dep should remain"); } diff --git a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java index 7f4e5be2a..23b647871 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java +++ b/src/test/java/org/apache/maven/plugins/dependency/resolvers/TestResolveMojo.java @@ -32,7 +32,7 @@ import static org.apache.maven.api.plugin.testing.MojoExtension.setVariableValueToObject; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.AssertionsKt.assertNotNull; @MojoTest @@ -77,7 +77,7 @@ void testSilent(ResolveDependenciesMojo mojo) { assertFalse(mojo.getLog() instanceof DependencySilentLog); mojo.setSilent(true); - assertTrue(mojo.getLog() instanceof DependencySilentLog); + assertInstanceOf(DependencySilentLog.class, mojo.getLog()); mojo.setSilent(false); assertFalse(mojo.getLog() instanceof DependencySilentLog); diff --git a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java index dc1d96589..ebab479c6 100644 --- a/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java +++ b/src/test/java/org/apache/maven/plugins/dependency/utils/translators/TestClassifierTypeTranslator.java @@ -141,8 +141,8 @@ void testClassifierAndType() { org.eclipse.aether.artifact.Artifact translatedArtifact = resultIter.next(); if (artifact.getArtifactId() == translatedArtifact.getArtifactId() && artifact.getGroupId() == translatedArtifact.getGroupId()) { - assertEquals(translatedArtifact.getClassifier(), classifier); - assertEquals(translatedArtifact.getExtension(), type); + assertEquals(classifier, translatedArtifact.getClassifier()); + assertEquals(type, translatedArtifact.getExtension()); found = true; break;