@@ -126,6 +126,11 @@ private static ArtifactMetadataSource mockArtifactMetaDataSource() throws Artifa
126
126
new DefaultArtifactVersion ( "1.0.0" ),
127
127
new DefaultArtifactVersion ( "0.9.0" ) );
128
128
}
129
+ else if ( "issue-670-artifact" .equals ( artifact .getArtifactId () ) )
130
+ {
131
+ return Arrays .asList ( new DefaultArtifactVersion ( "0.0.1-1" ),
132
+ new DefaultArtifactVersion ( "0.0.1-1-impl-SNAPSHOT" ) );
133
+ }
129
134
else if ( "unknown-artifact" .equals ( artifact .getArtifactId () ) )
130
135
{
131
136
return Collections .emptyList ();
@@ -236,4 +241,51 @@ public void testParentDowngradeForbiddenWithRange()
236
241
}
237
242
assertThat ( changeRecorder .getChanges (), is ( empty () ) );
238
243
}
244
+
245
+ @ Test
246
+ public void testAllowSnapshots ()
247
+ throws MojoExecutionException , XMLStreamException , MojoFailureException
248
+ {
249
+ mojo .allowSnapshots = true ;
250
+ mojo .getProject ().setParent ( new MavenProject ()
251
+ {{
252
+ setGroupId ( "default-group" );
253
+ setArtifactId ( "issue-670-artifact" );
254
+ setVersion ( "0.0.1-1" );
255
+ }} );
256
+
257
+ try ( MockedStatic <PomHelper > pomHelper = mockStatic ( PomHelper .class ) )
258
+ {
259
+ pomHelper .when ( () -> PomHelper .setProjectParentVersion ( any (), any () ) )
260
+ .thenReturn ( true );
261
+ mojo .update ( null );
262
+ }
263
+ assertThat ( changeRecorder .getChanges (), hasItem ( new VersionChange ( "default-group" ,
264
+ "issue-670-artifact" , "0.0.1-1" ,
265
+ "0.0.1-1-impl-SNAPSHOT" ) ) );
266
+ }
267
+
268
+ @ Test
269
+ public void testAllowSnapshotsWithParentVersion ()
270
+ throws MojoExecutionException , XMLStreamException , MojoFailureException
271
+ {
272
+ mojo .allowSnapshots = true ;
273
+ mojo .parentVersion = "0.0.1-1-impl-SNAPSHOT" ;
274
+ mojo .getProject ().setParent ( new MavenProject ()
275
+ {{
276
+ setGroupId ( "default-group" );
277
+ setArtifactId ( "issue-670-artifact" );
278
+ setVersion ( "0.0.1-1" );
279
+ }} );
280
+
281
+ try ( MockedStatic <PomHelper > pomHelper = mockStatic ( PomHelper .class ) )
282
+ {
283
+ pomHelper .when ( () -> PomHelper .setProjectParentVersion ( any (), any () ) )
284
+ .thenReturn ( true );
285
+ mojo .update ( null );
286
+ }
287
+ assertThat ( changeRecorder .getChanges (), hasItem ( new VersionChange ( "default-group" ,
288
+ "issue-670-artifact" , "0.0.1-1" ,
289
+ "0.0.1-1-impl-SNAPSHOT" ) ) );
290
+ }
239
291
}
0 commit comments