Skip to content

Commit

Permalink
mojohaus#690: Adding a unit test testing the issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jarmoniuk committed Sep 18, 2022
1 parent a54e87f commit 3eea42e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/org/codehaus/mojo/versions/UpdateParentMojoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -325,4 +325,25 @@ private void testSkipResolution( String version )
assertThat( changeRecorder.getChanges(), hasItem( new VersionChange( "default-group",
"parent-artifact", "1.0.0", version ) ) );
}

@Test
public void testShouldUpgradeToSnapshot() throws MojoExecutionException, XMLStreamException, MojoFailureException
{
mojo.getProject().setParent( new MavenProject()
{{
setGroupId( "default-group" );
setArtifactId( "parent-artifact" );
setVersion( "0.9.0" );
}} );
mojo.allowSnapshots = true;
mojo.parentVersion = "[0,1.0.1-SNAPSHOT]";
try ( MockedStatic<PomHelper> pomHelper = mockStatic( PomHelper.class ) )
{
pomHelper.when( () -> PomHelper.setProjectParentVersion( any(), any() ) ).thenReturn( true );
mojo.update( null );
}
assertThat( changeRecorder.getChanges(),
hasItem( new VersionChange( "default-group", "parent-artifact", "0.9.0",
"1.0.1-SNAPSHOT" ) ) );
}
}

0 comments on commit 3eea42e

Please sign in to comment.