forked from mojohaus/versions
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves mojohaus#1197: Hande a no-version case in dependencyManageme…
…nt for CompareDependenciesMojo - also resolve Maven 4 incompatibility of dummy-aggregate-*-333 artifacts in it-repo
- Loading branch information
Showing
5 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ns-maven-plugin/src/test/java/org/codehaus/mojo/versions/CompareDependenciesMojoTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package org.codehaus.mojo.versions; | ||
|
||
import java.io.File; | ||
import java.util.Collections; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.model.DependencyManagement; | ||
import org.apache.maven.model.Model; | ||
import org.apache.maven.plugin.testing.AbstractMojoTestCase; | ||
import org.apache.maven.plugin.testing.MojoRule; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.ProjectBuilder; | ||
import org.apache.maven.project.ProjectBuildingRequest; | ||
import org.apache.maven.project.ProjectBuildingResult; | ||
import org.codehaus.mojo.versions.utils.DependencyBuilder; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyBoolean; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class CompareDependenciesMojoTest extends AbstractMojoTestCase { | ||
|
||
@Rule | ||
public final MojoRule mojoRule = new MojoRule(this); | ||
|
||
@Test | ||
public void testCompareVersionlessDependencies() throws Exception { | ||
CompareDependenciesMojo mojo = (CompareDependenciesMojo) mojoRule.lookupConfiguredMojo( | ||
new File("src/test/resources/org/codehaus/mojo/compare-dependencies/versionless"), | ||
"compare-dependencies"); | ||
ProjectBuildingResult result = mock(ProjectBuildingResult.class); | ||
when(result.getProblems()).thenReturn(Collections.emptyList()); | ||
when(result.getProject()).thenReturn(new MavenProject(new Model() { | ||
{ | ||
setDependencyManagement(new DependencyManagement() { | ||
{ | ||
setDependencies(Collections.singletonList(DependencyBuilder.newBuilder() | ||
.withGroupId("defaultGroup") | ||
.withArtifactId("artifactA") | ||
.withScope("test") | ||
.withVersion("1.0.0") | ||
.build())); | ||
} | ||
}); | ||
} | ||
})); | ||
|
||
ProjectBuilder projectBuilder = mock(ProjectBuilder.class); | ||
when(projectBuilder.build(any(Artifact.class), anyBoolean(), any(ProjectBuildingRequest.class))) | ||
.thenReturn(result); | ||
setVariableValueToObject(mojo, "projectBuilder", projectBuilder); | ||
setVariableValueToObject(mojo, "remotePom", "defaultGroup:other-artifact:1.0.0"); | ||
|
||
mojo.execute(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...aven-plugin/src/test/resources/org/codehaus/mojo/compare-dependencies/versionless/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>default-group</groupId> | ||
<artifactId>default-artifact</artifactId> | ||
<version>1.0.0</version> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>defaultGroup</groupId> | ||
<artifactId>artifactA</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
</project> |