Skip to content

Commit

Permalink
#3156 = add/refine tests related to non-public, inner and nested classes
Browse files Browse the repository at this point in the history
  • Loading branch information
coiouhkc committed Jun 10, 2023
1 parent c73542c commit 1e9539e
Showing 1 changed file with 117 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class LombokUtilityClassTest implements RewriteTest {

@Test
void happyPath1() {
void happyPathSimple() {
rewriteRun(
recipeSpec -> recipeSpec
.recipe(new LombokUtilityClass()
Expand Down Expand Up @@ -141,4 +141,120 @@ public int add(final int x, final int y) {
)
);
}

@Test
void happyPathInner() {
rewriteRun(
recipeSpec -> recipeSpec
.recipe(new LombokUtilityClass()),
java(
"""
public class A {
public int add(final int x, final int y) {
return x + y;
}
private class B {
private static int substract(final int x, final int y) {
return x - y;
}
}
}
""",
"""
import lombok.experimental.UtilityClass;
public class A {
public int add(final int x, final int y) {
return x + y;
}
@UtilityClass
private class B {
private int substract(final int x, final int y) {
return x - y;
}
}
}
"""
)
);
}

/**
* Nested ~ inner static
*/
@Test
void happyPathNested() {
rewriteRun(
recipeSpec -> recipeSpec
.recipe(new LombokUtilityClass()),
java(
"""
public class A {
public int add(final int x, final int y) {
return x + y;
}
private static class B {
private static int substract(final int x, final int y) {
return x - y;
}
}
}
""",
"""
import lombok.experimental.UtilityClass;
public class A {
public int add(final int x, final int y) {
return x + y;
}
@UtilityClass
private static class B {
private int substract(final int x, final int y) {
return x - y;
}
}
}
"""
)
);
}

@Test
void happyPathNonPublic() {
rewriteRun(
recipeSpec -> recipeSpec
.recipe(new LombokUtilityClass()),
java(
"""
public class A {
public int add(final int x, final int y) {
return x + y;
}
}
class B {
public static int substract(final int x, final int y) {
return x - y;
}
}
""",
"""
import lombok.experimental.UtilityClass;
public class A {
public int add(final int x, final int y) {
return x + y;
}
}
@UtilityClass
class B {
public int substract(final int x, final int y) {
return x - y;
}
}
"""
)
);
}
}

0 comments on commit 1e9539e

Please sign in to comment.