1717
1818import org .junit .jupiter .api .Test ;
1919import org .openrewrite .DocumentExample ;
20- import org .openrewrite .config .Environment ;
21- import org .openrewrite .test .RecipeSpec ;
2220import org .openrewrite .test .RewriteTest ;
2321
22+ import static org .assertj .core .api .Assertions .assertThat ;
2423import static org .openrewrite .maven .Assertions .pomXml ;
2524
2625class UpgradeWro4jMavenPluginVersionTest implements RewriteTest {
2726
28- @ Override
29- public void defaults (RecipeSpec spec ) {
30- spec .recipe (Environment .builder ()
31- .scanRuntimeClasspath ("org.openrewrite.java.migrate.wro4j" )
32- .build ()
33- .activateRecipes ("org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion" ));
34- }
35-
3627 @ DocumentExample
3728 @ Test
38- void property () {
29+ void v1OnJava11 () {
3930 rewriteRun (
31+ spec -> spec .recipeFromResources ("org.openrewrite.java.migrate.UpgradePluginsForJava11" ),
4032 // as taken from Spring PetClinic 1.5.x
4133 //language=xml
4234 pomXml (
4335 """
4436 <project>
45- <properties>
46- <wro4j.version>1.8.0</wro4j.version>
47- </properties>
4837 <groupId>com.mycompany.app</groupId>
4938 <artifactId>my-app</artifactId>
5039 <version>1</version>
40+ <properties>
41+ <wro4j.version>1.8.0</wro4j.version>
42+ </properties>
5143 <build>
5244 <plugins>
5345 <plugin>
@@ -61,12 +53,41 @@ void property() {
6153 """ ,
6254 """
6355 <project>
56+ <groupId>com.mycompany.app</groupId>
57+ <artifactId>my-app</artifactId>
58+ <version>1</version>
6459 <properties>
6560 <wro4j.version>1.10.1</wro4j.version>
6661 </properties>
62+ <build>
63+ <plugins>
64+ <plugin>
65+ <groupId>ro.isdc.wro4j</groupId>
66+ <artifactId>wro4j-maven-plugin</artifactId>
67+ <version>${wro4j.version}</version>
68+ </plugin>
69+ </plugins>
70+ </build>
71+ </project>
72+ """
73+ )
74+ );
75+ }
76+
77+ @ Test
78+ void v2OnJava17 () {
79+ rewriteRun (
80+ spec -> spec .recipeFromResources ("org.openrewrite.java.migrate.UpgradePluginsForJava17" ),
81+ pomXml (
82+ //language=xml
83+ """
84+ <project>
6785 <groupId>com.mycompany.app</groupId>
6886 <artifactId>my-app</artifactId>
6987 <version>1</version>
88+ <properties>
89+ <wro4j.version>1.8.0</wro4j.version>
90+ </properties>
7091 <build>
7192 <plugins>
7293 <plugin>
@@ -77,7 +98,11 @@ void property() {
7798 </plugins>
7899 </build>
79100 </project>
80- """
101+ """ ,
102+ spec -> spec .after (actual -> {
103+ assertThat (actual ).contains ("<wro4j.version>2" );
104+ return actual ;
105+ })
81106 )
82107 );
83108 }
0 commit comments