Skip to content

Commit

Permalink
#3156 = add some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
coiouhkc committed Jun 9, 2023
1 parent f23f730 commit ce62e60
Showing 1 changed file with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static int add(final int x, final int y) {
""",
"""
import lombok.experimental.UtilityClass;
@UtilityClass
public class A {
public int add(final int x, final int y) {
Expand All @@ -39,6 +39,64 @@ public int add(final int x, final int y) {
);
}


@Test
void doNotUpgradeToUtilityClassIfNonStaticVariables() {
rewriteRun(
recipeSpec -> recipeSpec
.recipes(
new LombokUtilityClass()
),
java(
"""
public class A {
private final int x = 0;
public static int add(final int x, final int y) {
return x + y;
}
}
""",
"""
public class A {
private final int x = 0;
public static int add(final int x, final int y) {
return x + y;
}
}
"""
)
);
}


@Test
void doNotUpgradeToUtilityClassIfNonStaticMethods() {
rewriteRun(
recipeSpec -> recipeSpec
.recipes(
addDependency("org.projectlombok:lombok:1.18.28", "false"),
new LombokUtilityClass()
),
java(
"""
public class A {
public int add(final int x, final int y) {
return x + y;
}
}
""",
"""
public class A {
public int add(final int x, final int y) {
return x + y;
}
}
"""
)
);
}


private AddDependency addDependency(String gav, String onlyIfUsing) {
return addDependency(gav, onlyIfUsing, null, null);
}
Expand Down

0 comments on commit ce62e60

Please sign in to comment.