-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #187 from gsmet/recipes-3.13
Add a recipe to rewrite @QuarkusTestResource to @WithTestResource
- Loading branch information
Showing
5 changed files
with
163 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
recipes-tests/src/test/java/io/quarkus/updates/core/CoreUpdate313Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
package io.quarkus.updates.core; | ||
|
||
import static org.openrewrite.java.Assertions.java; | ||
|
||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.openrewrite.java.JavaParser; | ||
import org.openrewrite.test.RecipeSpec; | ||
import org.openrewrite.test.RewriteTest; | ||
import org.openrewrite.test.TypeValidation; | ||
|
||
public class CoreUpdate313Test implements RewriteTest { | ||
|
||
@Override | ||
public void defaults(RecipeSpec spec) { | ||
CoreTestUtil.recipe(spec, Path.of("quarkus-updates", "core", "3.13.alpha1.yaml")) | ||
.parser(JavaParser.fromJavaVersion() | ||
.classpath("quarkus-test-common") | ||
.logCompilationWarningsAndErrors(true)) | ||
.typeValidationOptions(TypeValidation.all()); | ||
} | ||
|
||
@Test | ||
void testWithTestResource() { | ||
//language=java | ||
rewriteRun(java( | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
@QuarkusTestResource | ||
public class GitHubAppTest { | ||
} | ||
""", | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.WithTestResource; | ||
@WithTestResource(restrictToAnnotatedClass = false) | ||
public class GitHubAppTest { | ||
} | ||
""")); | ||
|
||
//language=java | ||
rewriteRun(java( | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
@QuarkusTestResource(restrictToAnnotatedClass = false) | ||
public class GitHubAppTest { | ||
} | ||
""", | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.WithTestResource; | ||
@WithTestResource(restrictToAnnotatedClass = false) | ||
public class GitHubAppTest { | ||
} | ||
""")); | ||
|
||
//language=java | ||
rewriteRun(java( | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
@QuarkusTestResource(restrictToAnnotatedClass = true) | ||
class GitHubAppTest { | ||
} | ||
""", | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.WithTestResource; | ||
@WithTestResource(restrictToAnnotatedClass = true) | ||
class GitHubAppTest { | ||
} | ||
""")); | ||
|
||
//language=java | ||
rewriteRun(java( | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.QuarkusTestResource; | ||
@QuarkusTestResource(parallel = true) | ||
class GitHubAppTest { | ||
} | ||
""", | ||
""" | ||
package io.quarkiverse.githubapp.test; | ||
import io.quarkus.test.common.WithTestResource; | ||
@WithTestResource(restrictToAnnotatedClass = false, parallel = true) | ||
class GitHubAppTest { | ||
} | ||
""")); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
recipes/src/main/resources/quarkus-updates/core/3.13.alpha1.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
##### | ||
# Sync JPA model gen version with the one from the BOM | ||
##### | ||
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: io.quarkus.updates.core.quarkus313.SyncHibernateJpaModelgenVersionWithBOM | ||
recipeList: | ||
- io.quarkus.updates.core.quarkus37.SyncMavenCompilerAnnotationProcessorVersion: | ||
groupId: org.hibernate.orm | ||
artifactId: hibernate-jpamodelgen | ||
##### | ||
# Replace @QuarkusTestResource with @WithTestResource while keeping the original behavior | ||
##### | ||
--- | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: io.quarkus.updates.core.quarkus313.WithTestResource | ||
recipeList: | ||
- org.openrewrite.java.ChangeType: | ||
oldFullyQualifiedTypeName: io.quarkus.test.common.QuarkusTestResource | ||
newFullyQualifiedTypeName: io.quarkus.test.common.WithTestResource | ||
--- | ||
# The default for WithTestResource is different so if using the default value, let's enforce it | ||
type: specs.openrewrite.org/v1beta/recipe | ||
name: io.quarkus.updates.core.quarkus313.WithTestResourceRestrictToAnnotatedClassValue | ||
recipeList: | ||
- org.openrewrite.java.AddOrUpdateAnnotationAttribute: | ||
annotationType: io.quarkus.test.common.WithTestResource | ||
attributeName: restrictToAnnotatedClass | ||
attributeValue: false | ||
addOnly: true |
This file was deleted.
Oops, something went wrong.