Skip to content

Commit

Permalink
No need to enable Lombok to rename a field
Browse files Browse the repository at this point in the history
  • Loading branch information
timtebeek committed Jan 6, 2025
1 parent 8c04880 commit e6d7904
Showing 1 changed file with 23 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
*/
package org.openrewrite.java.migrate.lombok.log;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
Expand Down Expand Up @@ -58,47 +55,33 @@ class A {
);
}

@Nested
class RenameField {

@BeforeAll
static void setUp() {
System.setProperty("rewrite.lombok", "true");
}

@AfterAll
static void tearDown() {
System.clearProperty("rewrite.lombok");
}

@Test
void replaceSlf4jAndRenameFieldUsages() {
rewriteRun(
// language=java
java(
"""
class A {
private static final org.slf4j.Logger renamed = org.slf4j.LoggerFactory.getLogger(A.class);
void test() {
renamed.info("test");
}
@Test
void replaceSlf4jAndRenameFieldUsages() {
rewriteRun(
// language=java
java(
"""
class A {
private static final org.slf4j.Logger renamed = org.slf4j.LoggerFactory.getLogger(A.class);
void test() {
renamed.info("test");
}
""",
"""
import lombok.extern.slf4j.Slf4j;
}
""",
"""
import lombok.extern.slf4j.Slf4j;
@Slf4j
class A {
@Slf4j
class A {
void test() {
log.info("test");
}
void test() {
log.info("test");
}
"""
)
);
}
}
"""
)
);
}

@Test
Expand Down

0 comments on commit e6d7904

Please sign in to comment.