Skip to content
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

Remove wrong namespace-change of package javax.transaction.xa #554

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/rewrite/jakarta-ee-9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ recipeList:
- org.openrewrite.java.ChangePackage:
oldPackageName: javax.transaction
newPackageName: jakarta.transaction
recursive: true
recursive: false
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.jakarta.JavaxWebsocketToJakartaWebsocket
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.openrewrite.java.migrate.jakarta;

Xaeras marked this conversation as resolved.
Show resolved Hide resolved
import org.intellij.lang.annotations.Language;
import org.junit.jupiter.api.Test;
import org.openrewrite.config.Environment;
Xaeras marked this conversation as resolved.
Show resolved Hide resolved
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

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

public class JavaxTransactionMigrationToJakartaTransactionTest implements RewriteTest {
@Language("java")
private static final String javax_transaction =
"""
package javax.transaction;
public @interface Transactional {}
""";

@Language("java")
private static final String javax_transaction_xa =
"""
package javax.transaction.xa;
public class XAResource {
public static void stat() {}
public void foo() {}
}
""";

@Language("java")
private static final String jakarta_transaction =
"""
package jakarta.transaction;
public @interface Transactional {}
""";

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(
Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta")
.build()
.activateRecipes("org.openrewrite.java.migrate.jakarta.JavaxTransactionMigrationToJakartaTransaction")
);
}

@Test
void doNotChangeImportWhenPackageFromJavaSE() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().dependsOn(javax_transaction_xa)),
//language=java
java("""
Xaeras marked this conversation as resolved.
Show resolved Hide resolved
import javax.transaction.xa.*;
public class A {
XAResource xa;
}
""")
);
}

@Test
Xaeras marked this conversation as resolved.
Show resolved Hide resolved
void changeImportWhenPackageFromJakartaTransaction() {
rewriteRun(
spec -> spec.parser(JavaParser.fromJavaVersion().dependsOn(javax_transaction, jakarta_transaction)),
//language=java
java("""
Xaeras marked this conversation as resolved.
Show resolved Hide resolved
import javax.transaction.Transactional;
@Transactional
public class A {
public void foo() {}
}
""",
"""
import jakarta.transaction.Transactional;
@Transactional
public class A {
public void foo() {}
}
""")
);
}
}
Loading