I have the following test...
import org.junit.jupiter.api.Test
import org.openrewrite.test.RecipeSpec
import org.openrewrite.test.RewriteTest
import org.openrewrite.yaml.Assertions
class ChangeFilterExpressionPropertiesTest : RewriteTest {
private val recipeFile = "/META-INF/rewrite/test.yml"
override fun defaults(spec: RecipeSpec) {
spec
.recipeFromResource(recipeFile,"me.ChangeFilterExpressionProperties")
.cycles(3)
}
@Test
fun `Changes the package`() = rewriteRun(Assertions.yaml(
"""
spring:
kafka:
producer:
store-and-forward:
filter-expression: '@monitoredTopics.contains(#this.topic())?T(me.Decision).FULL:T(me.Decision).SKIP'
""".trimIndent(),
"""
spring:
kafka:
producer:
store-and-forward:
filter-expression: '@monitoredTopics.contains(#this.topic())?T(they.Decision).FULL:T(they.Decision).SKIP'
""".trimIndent()
) { spec -> spec.path("src/main/resources/application.yml") }
)
@Test
fun `Control test`() = rewriteRun(Assertions.yaml(
"""
spring:
kafka:
producer:
store-and-forward:
filter-expression: 'test'
""".trimIndent(),
"""
spring:
kafka:
producer:
store-and-forward:
filter-expression: 'test'
""".trimIndent()
) { spec -> spec.path("src/main/resources/application.yml") }
)
}
The first test passes as expected, however, I can't get my control test working. It fails with
java.lang.AssertionError: Recipe was expected to make a change but made no changes.
at org.openrewrite.test.LargeSourceSetCheckingExpectedCycles.afterCycle(LargeSourceSetCheckingExpectedCycles.java:118)
at org.openrewrite.RecipeScheduler.runRecipeCycles(RecipeScheduler.java:97)
at org.openrewrite.RecipeScheduler.scheduleRun(RecipeScheduler.java:41)
How do I test that no changes were made in the control example?
Remove the second text block to assert that a recipe makes no changes at all.
That's all really; but know that you're also always welcome in our Slack for any such questions; the link is at the top of our docs.