
org.openrewrite.xml.XmlRecipeTest.kt Maven / Gradle / Ivy
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.openrewrite.xml
import org.intellij.lang.annotations.Language
import org.openrewrite.Recipe
import org.openrewrite.RecipeTest
import org.openrewrite.java.tree.J
import org.openrewrite.xml.tree.Xml
import java.io.File
import java.nio.file.Path
@Suppress("unused")
interface XmlRecipeTest : RecipeTest {
override val parser: XmlParser
get() = XmlParser()
fun assertChanged(
recipe: Recipe = this.recipe!!,
moderneAstLink: String,
moderneApiBearerToken: String = apiTokenFromUserHome(),
@Language("xml") after: String,
cycles: Int = 2,
expectedCyclesThatMakeChanges: Int = cycles - 1,
afterConditions: (Xml.Document) -> Unit = { }
) {
super.assertChangedBase(recipe, moderneAstLink, moderneApiBearerToken, after, cycles, expectedCyclesThatMakeChanges, afterConditions)
}
fun assertChanged(
parser: XmlParser = this.parser,
recipe: Recipe = this.recipe!!,
@Language("xml") before: String,
@Language("xml") dependsOn: Array = emptyArray(),
@Language("xml") after: String,
cycles: Int = 2,
expectedCyclesThatMakeChanges: Int = cycles - 1,
afterConditions: (Xml.Document) -> Unit = { }
) {
super.assertChangedBase(parser, recipe, before, dependsOn, after, cycles, expectedCyclesThatMakeChanges, afterConditions)
}
fun assertChanged(
parser: XmlParser = this.parser,
recipe: Recipe = this.recipe!!,
@Language("xml") before: File,
relativeTo: Path? = null,
@Language("xml") dependsOn: Array = emptyArray(),
@Language("xml") after: String,
cycles: Int = 2,
expectedCyclesThatMakeChanges: Int = cycles - 1,
afterConditions: (Xml.Document) -> Unit = { }
) {
super.assertChangedBase(parser, recipe, before, relativeTo, dependsOn, after, cycles, expectedCyclesThatMakeChanges, afterConditions)
}
fun assertUnchanged(
parser: XmlParser = this.parser,
recipe: Recipe = this.recipe!!,
@Language("xml") before: String,
@Language("xml") dependsOn: Array = emptyArray()
) {
super.assertUnchangedBase(parser, recipe, before, dependsOn)
}
fun assertUnchanged(
parser:XmlParser = this.parser,
recipe: Recipe = this.recipe!!,
@Language("xml") before: File,
relativeTo: Path? = null,
@Language("xml") dependsOn: Array = emptyArray()
) {
super.assertUnchangedBase(parser, recipe, before, relativeTo, dependsOn)
}
}