Skip to content

Commit

Permalink
Fix formatting issues in UserService and UserServiceTest
Browse files Browse the repository at this point in the history
Corrected the indentation and line breaks in UserService.java and UserServiceTest.java for enhanced readability and consistency. Added a comment in UserService to clarify the use of the exhaustive switch expression for sealed classes.
  • Loading branch information
kousen committed Aug 2, 2024
1 parent 44333a1 commit f889f83
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

public class UserService {
public static String getPersonInfo(Person person) {
// Exhaustive switch expression because Person is sealed
return switch (person) {
case User user -> "User: %s (%s)".formatted(user.name(), user.email());
case Admin admin ->
"Admin: %s (%s) with permissions: %s"
case Admin admin -> "Admin: %s (%s) with permissions: %s"
.formatted(admin.name(), admin.email(), admin.permissions());
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class UserServiceTest {
@Test
void testGetPersonInfo() {
Person user = new User(1, "John Doe", "[email protected]");
Person admin = new Admin(2, "Jane Smith",
"[email protected]", "ALL");
Person admin = new Admin(2, "Jane Smith", "[email protected]", "ALL");

assertAll(
() -> assertThat(UserService.getPersonInfo(user))
Expand Down

0 comments on commit f889f83

Please sign in to comment.