Skip to content

Commit

Permalink
MavenRecipeTest to RewriteTest conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
pway99 committed Oct 10, 2022
1 parent 8b2ed72 commit 84790ed
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
33 changes: 17 additions & 16 deletions src/test/kotlin/org/openrewrite/java/migrate/JavaVersion11Test.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
*/
package org.openrewrite.java.migrate

import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
import org.openrewrite.Recipe
import org.openrewrite.config.Environment
import org.openrewrite.maven.MavenRecipeTest
import org.openrewrite.maven.Assertions.pomXml
import org.openrewrite.test.RecipeSpec
import org.openrewrite.test.RewriteTest

class JavaVersion11Test : MavenRecipeTest {
override val recipe: Recipe = Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate")
.build()
.activateRecipes("org.openrewrite.java.migrate.JavaVersion11")
class JavaVersion11Test : RewriteTest {
override fun defaults(spec: RecipeSpec) {
spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate")
.build().activateRecipes("org.openrewrite.java.migrate.JavaVersion11"))
}

@Test
fun changeJavaVersion() = assertChanged(
before = """
fun changeJavaVersion() = rewriteRun (
pomXml("""
<project>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -41,8 +42,7 @@ class JavaVersion11Test : MavenRecipeTest {
<artifactId>my-app</artifactId>
<version>1</version>
</project>
""",
after = """
""", """
<project>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -55,11 +55,12 @@ class JavaVersion11Test : MavenRecipeTest {
<version>1</version>
</project>
"""
)
)

@Test
fun changeMavenCompiler() = assertChanged(
before = """
fun changeMavenCompiler() = rewriteRun (
pomXml("""
<project>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -73,7 +74,7 @@ class JavaVersion11Test : MavenRecipeTest {
<version>1</version>
</project>
""",
after = """
"""
<project>
<modelVersion>4.0.0</modelVersion>
Expand All @@ -86,6 +87,6 @@ class JavaVersion11Test : MavenRecipeTest {
<artifactId>my-app</artifactId>
<version>1</version>
</project>
"""
""")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@
package org.openrewrite.java.migrate.jacoco

import org.junit.jupiter.api.Test
import org.openrewrite.Recipe
import org.openrewrite.config.Environment
import org.openrewrite.maven.MavenRecipeTest

class UpgradeJaCoCoMavenPluginVersionTest : MavenRecipeTest {
override val recipe: Recipe = Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.jacoco")
.build()
.activateRecipes("org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion")
import org.openrewrite.maven.Assertions.pomXml
import org.openrewrite.test.RecipeSpec
import org.openrewrite.test.RewriteTest

class UpgradeJaCoCoMavenPluginVersionTest : RewriteTest {
override fun defaults(spec: RecipeSpec) {
spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.jacoco")
.build()
.activateRecipes("org.openrewrite.java.migrate.jacoco.UpgradeJaCoCoMavenPluginVersion"))
}
@Test
fun property() = assertChanged(
before = """
fun property() = rewriteRun(
pomXml("""
<project>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -64,7 +66,7 @@ class UpgradeJaCoCoMavenPluginVersionTest : MavenRecipeTest {
</build>
</project>
""",
after = """
"""
<project>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -99,6 +101,6 @@ class UpgradeJaCoCoMavenPluginVersionTest : MavenRecipeTest {
</plugins>
</build>
</project>
"""
""")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,23 @@
package org.openrewrite.java.migrate.wro4j

import org.junit.jupiter.api.Test
import org.openrewrite.Recipe
import org.openrewrite.config.Environment
import org.openrewrite.maven.MavenRecipeTest
import org.openrewrite.maven.Assertions.pomXml
import org.openrewrite.test.RecipeSpec
import org.openrewrite.test.RewriteTest

class UpgradeWro4jMavenPluginVersionTest : MavenRecipeTest {
override val recipe: Recipe = Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.wro4j")
.build()
.activateRecipes("org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion")
class UpgradeWro4jMavenPluginVersionTest : RewriteTest {
override fun defaults(spec: RecipeSpec) {
spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.wro4j")
.build()
.activateRecipes("org.openrewrite.java.migrate.wro4j.UpgradeWro4jMavenPluginVersion"))
}

@Test
fun property() = assertChanged(
fun property() = rewriteRun(
// As taken from Spring PetClinic 1.5.x
before = """
pomXml("""
<project>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -74,7 +77,7 @@ class UpgradeWro4jMavenPluginVersionTest : MavenRecipeTest {
</build>
</project>
""",
after = """
"""
<project>
<modelVersion>4.0.0</modelVersion>
Expand Down Expand Up @@ -118,6 +121,6 @@ class UpgradeWro4jMavenPluginVersionTest : MavenRecipeTest {
</plugins>
</build>
</project>
"""
""")
)
}

0 comments on commit 84790ed

Please sign in to comment.