-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a recipe to rewrite @QuarkusTestResource to @WithTestResource #187
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case where
@QuarkusTestResource(restrictToAnnotatedClass = true)
, it would be nicer I think if we just eliminated the attribute, since the default in@WithTestResource
istrue
.I'm not sure if thats possible though. I don't know much about Open Rewrite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably could but I thought about it when doing it and I decided it was not worth the hassle, given the size of my TODO list :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it was one of those "this would be nice if it was easy to do" things.