Skip to content

Commit

Permalink
unit test for sealed interfaces (#2573)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullis authored Dec 29, 2022
1 parent 555e717 commit ae49485
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,42 @@ public sealed class Rectangle extends Shape {
);
}

@MinimumJava17
@Issue("https://github.com/openrewrite/rewrite/pull/2569")
@Test
void sealedInterfaces() {
rewriteRun(
java(
"""
public sealed interface Shape { }
""",
spec -> spec.afterRecipe(cu -> assertThat(cu.getClasses().get(0).getPermits()).isNull())
),
java(
"""
public sealed interface HasFourCorners extends Shape
permits Square, Rectangle {
}
""",
spec -> spec.afterRecipe(cu -> assertThat(cu.getClasses().get(0).getPermits()).hasSize(2))
),
java(
"""
public non-sealed class Square extends HasFourCorners {
public double side;
}
"""
),
java(
"""
public sealed class Rectangle extends HasFourCorners {
public double length, width;
}
"""
)
);
}

@Issue("https://github.com/openrewrite/rewrite/issues/70")
@Test
void singleLineCommentBeforeModifier() {
Expand Down

0 comments on commit ae49485

Please sign in to comment.