Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -275,7 +277,7 @@ void removeDependencyFromProfileSucceeds() throws Exception {
mojo.execute();

String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8);
assertTrue(!result.contains("<groupId>com.example</groupId>"), "dependency should be removed");
assertFalse(result.contains("<groupId>com.example</groupId>"), "dependency should be removed");
assertTrue(result.contains("<id>dev</id>"), "profile should remain");
}

Expand Down Expand Up @@ -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("<artifactId>lib</artifactId>"), "managed dep should be removed");
assertFalse(result.contains("<artifactId>lib</artifactId>"), "managed dep should be removed");
}

@Test
Expand Down Expand Up @@ -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("<artifactId>lib</artifactId>"), "managed dep should be removed");
assertFalse(result.contains("<artifactId>lib</artifactId>"), "managed dep should be removed");
verify(log).warn(contains("child-a/my-pom.xml"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,9 +752,9 @@ void addDependencyIgnoresEmptyStringFields() throws IOException {

String result = new String(Files.readAllBytes(pomFile.toPath()), StandardCharsets.UTF_8);
assertTrue(result.contains("<version>1.0</version>"), "version should be present");
assertTrue(!result.contains("<scope>"), "empty scope should not create element");
assertTrue(!result.contains("<type>"), "empty type should not create element");
assertTrue(!result.contains("<classifier>"), "empty classifier should not create element");
assertFalse(result.contains("<scope>"), "empty scope should not create element");
assertFalse(result.contains("<type>"), "empty type should not create element");
assertFalse(result.contains("<classifier>"), "empty classifier should not create element");
}

@Test
Expand Down Expand Up @@ -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");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading