Skip to content

Commit

Permalink
Merge pull request #207 from gsmet/quarkus-3.13
Browse files Browse the repository at this point in the history
Adjust Quarkus 3.13 recipes
  • Loading branch information
gsmet authored Aug 27, 2024
2 parents 56bcad6 + 9f3f850 commit 84e3c2c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 93 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package io.quarkus.updates.core;

import static org.openrewrite.java.Assertions.java;
import static org.openrewrite.properties.Assertions.properties;

import java.nio.file.Path;

import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
Expand All @@ -22,89 +24,31 @@ public void defaults(RecipeSpec spec) {
}

@Test
void testWithTestResource() {
//language=java
rewriteRun(java(
"""
package io.quarkiverse.githubapp.test;
void testUpdateTestOIDCAuthServerUrl() {
@Language("properties")
String originalProperties = """
%test.quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/
""";

import io.quarkus.test.common.QuarkusTestResource;
@Language("properties")
String afterProperties = """
%test.quarkus.oidc.auth-server-url=${keycloak.url:replaced-by-test-resource}/realms/quarkus/
""";

@QuarkusTestResource
public class GitHubAppTest {
}
""",
"""
package io.quarkiverse.githubapp.test;
rewriteRun(properties(originalProperties, afterProperties, spec -> spec.path("src/main/resources/application.properties")));

import io.quarkus.test.common.WithTestResource;
@Language("properties")
String unchangedWrongProfileOriginalProperties = """
quarkus.oidc.auth-server-url=${keycloak.url}/realms/quarkus/
""";

@WithTestResource(restrictToAnnotatedClass = false)
public class GitHubAppTest {
}
"""));
rewriteRun(properties(unchangedWrongProfileOriginalProperties, spec -> spec.path("src/main/resources/application.properties")));

//language=java
rewriteRun(java(
"""
package io.quarkiverse.githubapp.test;
@Language("properties")
String unchangedWrongValueOriginalProperties = """
%test.quarkus.oidc.auth-server-url=another-value
""";

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 {
}
"""));
rewriteRun(properties(unchangedWrongValueOriginalProperties, spec -> spec.path("src/main/resources/application.properties")));
}
}
23 changes: 8 additions & 15 deletions recipes/src/main/resources/quarkus-updates/core/3.13.alpha1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,15 @@ recipeList:
groupId: org.hibernate.orm
artifactId: hibernate-jpamodelgen
#####
# Replace @QuarkusTestResource with @WithTestResource while keeping the original behavior
# Adjust package properties in config files - native sources
#####
---
type: specs.openrewrite.org/v1beta/recipe
name: io.quarkus.updates.core.quarkus313.WithTestResource
name: io.quarkus.updates.core.quarkus313.UpdateTestOIDCAuthServerUrl
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
- org.openrewrite.properties.ChangePropertyValue:
propertyKey: '%test.quarkus.oidc.auth-server-url'
# this is a horrible hack to work around https://github.com/openrewrite/rewrite/discussions/4428
oldValue: '(\$)\{keycloak.url}\/realms\/quarkus\/'
newValue: '$1{keycloak.url:replaced-by-test-resource}/realms/quarkus/'
regex: true

0 comments on commit 84e3c2c

Please sign in to comment.