Skip to content

Commit

Permalink
Fix Wro4j tests
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Aug 9, 2024
1 parent 144a96b commit d0375f6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/main/resources/META-INF/rewrite/java-version-11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ recipeList:
- org.openrewrite.java.migrate.javax.JavaxManagementMonitorAPIs
- org.openrewrite.java.migrate.javax.JavaxXmlStreamAPIs
- org.openrewrite.java.migrate.cobertura.RemoveCoberturaMavenPlugin
- org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion
- org.openrewrite.java.migrate.UpgradeBuildToJava11
# Disabled due to null safety issues in the current implementation
# https://github.com/openrewrite/rewrite-migrate-java/issues/250
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,29 @@

import org.junit.jupiter.api.Test;
import org.openrewrite.DocumentExample;
import org.openrewrite.config.Environment;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.openrewrite.maven.Assertions.pomXml;

class UpgradeWro4jMavenPluginVersionTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.wro4j")
.build()
.activateRecipes("org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion"));
}

@DocumentExample
@Test
void property() {
void v1OnJava11() {
rewriteRun(
spec -> spec.recipeFromResources("org.openrewrite.java.migrate.UpgradePluginsForJava11"),
// as taken from Spring PetClinic 1.5.x
//language=xml
pomXml(
"""
<project>
<properties>
<wro4j.version>1.8.0</wro4j.version>
</properties>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<properties>
<wro4j.version>1.8.0</wro4j.version>
</properties>
<build>
<plugins>
<plugin>
Expand All @@ -61,12 +53,41 @@ void property() {
""",
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<properties>
<wro4j.version>1.10.1</wro4j.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>${wro4j.version}</version>
</plugin>
</plugins>
</build>
</project>
"""
)
);
}

@Test
void v2OnJava17() {
rewriteRun(
spec -> spec.recipeFromResources("org.openrewrite.java.migrate.UpgradePluginsForJava17"),
pomXml(
//language=xml
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<properties>
<wro4j.version>1.8.0</wro4j.version>
</properties>
<build>
<plugins>
<plugin>
Expand All @@ -77,7 +98,11 @@ void property() {
</plugins>
</build>
</project>
"""
""",
spec -> spec.after(actual -> {
assertThat(actual).contains("<wro4j.version>2");
return actual;
})
)
);
}
Expand Down

0 comments on commit d0375f6

Please sign in to comment.