Skip to content

Commit

Permalink
Improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Sep 20, 2024
1 parent be3e43b commit 456be8c
Showing 1 changed file with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ void yamlPrecondition() {
@Test
void yamlDeclarativeRecipeAsPrecondition() {
rewriteRun(
spec -> spec.recipeFromYaml("""
---
spec -> spec.recipeFromYaml(
"""
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.PreconditionTest
description: Test.
Expand All @@ -193,36 +193,41 @@ void yamlDeclarativeRecipeAsPrecondition() {
recipeList:
- org.openrewrite.text.Find:
find: 1
""", "org.openrewrite.PreconditionTest"),
""",
"org.openrewrite.PreconditionTest"
),
text("1", "3"),
text("2")
);
}

@Test
void orPreconditions() {
// example from https://docs.openrewrite.org/reference/yaml-format-reference#creating-or-preconditions-instead-of-and
// As documented https://docs.openrewrite.org/reference/yaml-format-reference#creating-or-preconditions-instead-of-and
rewriteRun(
spec -> spec.recipeFromYaml("""
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.DoSomething
description: Test.
preconditions:
- org.sample.FindAnyJson
recipeList:
- org.openrewrite.text.ChangeText:
toText: 2
---
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.FindAnyJson
recipeList:
- org.openrewrite.FindSourceFiles:
filePattern: "**/my.json"
- org.openrewrite.FindSourceFiles:
filePattern: "**/your.json"
- org.openrewrite.FindSourceFiles:
filePattern: "**/our.json"
""", "org.sample.DoSomething"),
spec -> spec.recipeFromYaml(
"""
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.DoSomething
description: Test.
preconditions:
- org.sample.FindAnyJson
recipeList:
- org.openrewrite.text.ChangeText:
toText: 2
---
type: specs.openrewrite.org/v1beta/recipe
name: org.sample.FindAnyJson
recipeList:
- org.openrewrite.FindSourceFiles:
filePattern: "**/my.json"
- org.openrewrite.FindSourceFiles:
filePattern: "**/your.json"
- org.openrewrite.FindSourceFiles:
filePattern: "**/our.json"
""",
"org.sample.DoSomething"
),
text("1", "2", spec -> spec.path("a/my.json")),
text("a", spec -> spec.path("a/not-my.json"))
);
Expand Down

0 comments on commit 456be8c

Please sign in to comment.