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

Do not change package when non-recursive #4447

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

timtebeek
Copy link
Contributor

Add unit test as reported via Slack by @BhavanaPidapa; update precondition to evaluate recursive boolean for package declaration too.

@timtebeek timtebeek added the bug Something isn't working label Aug 26, 2024
@timtebeek timtebeek self-assigned this Aug 26, 2024
Copy link

@anandfresh anandfresh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BhavanaPidapa
Copy link

BhavanaPidapa commented Aug 27, 2024

Hey Tim,

Below is the test case where changes to com.sun.net.ssl.internal.* are not expected. Please refer to the attached screenshot.

@Test
void excludePackageTest() {
    //language=java
    rewriteRun(
      spec -> spec.recipe(new ChangePackage(
        "com.sun.net.ssl",
        "javax.net.ssl",
        false
      )),
      java(
        """
          package com.test;
          import com.sun.net.ssl.internal.*;
          import com.sun.net.ssl.HostnameVerifier;
          class Test {
           public com.sun.net.ssl.HostnameVerifier hv;
              void exampleMethod() {
              }
          }
          """,
        """
          package com.test;
          import com.sun.net.ssl.internal.*;
          import javax.net.ssl.HostnameVerifier;
          class Test {
           public javax.net.ssl.HostnameVerifier hv;
              void exampleMethod() {
              }
          }
          """
      )
    );
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants