-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reordering the checks in shouldApplyUpdate + a simple unit test
- Loading branch information
1 parent
926388a
commit 6e6efcb
Showing
2 changed files
with
51 additions
and
6 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.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,45 @@ | ||
package org.codehaus.mojo.versions; | ||
|
||
import org.apache.maven.artifact.Artifact; | ||
import org.apache.maven.artifact.factory.ArtifactFactory; | ||
import org.apache.maven.artifact.versioning.ArtifactVersion; | ||
import org.apache.maven.artifact.versioning.VersionRange; | ||
import org.apache.maven.plugin.MojoExecutionException; | ||
import org.apache.maven.plugin.MojoFailureException; | ||
import org.apache.maven.project.MavenProject; | ||
import org.apache.maven.project.artifact.ProjectArtifact; | ||
import org.junit.Test; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
import java.util.Collections; | ||
|
||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyString; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class UpdateParentMojoTest { | ||
|
||
@Test | ||
public void testArtifactIdDoesNotExist() throws MojoExecutionException, XMLStreamException, MojoFailureException { | ||
UpdateParentMojo mojo = new UpdateParentMojo() { | ||
{ | ||
project = new MavenProject(); | ||
project.setParent(new MavenProject()); | ||
reactorProjects = Collections.emptyList(); | ||
forceUpdate = true; | ||
|
||
artifactFactory = mock(ArtifactFactory.class); | ||
when(artifactFactory.createDependencyArtifact(anyString(), anyString(), any(VersionRange.class), | ||
anyString(), anyString(), anyString())) | ||
.thenReturn(new ProjectArtifact(project)); | ||
} | ||
|
||
protected ArtifactVersion findLatestVersion(Artifact artifact, VersionRange versionRange, | ||
Boolean allowingSnapshots, boolean usePluginRepositories) { | ||
return null; | ||
} | ||
}; | ||
mojo.update(null); | ||
} | ||
} |