Developer 역할 Spring 골격 smoke #4

Showing only changes of commit 0f89883634 - Show all commits

View file

@ -0,0 +1,49 @@
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import static org.junit.jupiter.api.Assertions.*;
@SpringBootTest
class RoleServiceTest {
@Autowired
private RoleService roleService;
@Test
void getRoleName_returnsAdministratorForAdmin() {
assertEquals("Administrator", roleService.getRoleName("ADMIN"));
}
@Test
void getRoleName_returnsDeveloperForDeveloper() {
assertEquals("Developer", roleService.getRoleName("DEVELOPER"));
}
@Test
void getRoleName_returnsUnknownForNull() {
assertEquals("UNKNOWN", roleService.getRoleName(null));
}
@Test
void getRoleName_returnsUnknownForBlank() {
assertEquals("UNKNOWN", roleService.getRoleName(" "));
}
@Test
void isValidRole_returnsTrueForValidRoles() {
assertTrue(roleService.isValidRole("ADMIN"));
assertTrue(roleService.isValidRole("DEVELOPER"));
assertTrue(roleService.isValidRole("ROLE_VIEWER"));
}
@Test
void isValidRole_returnsFalseForInvalidRoles() {
assertFalse(roleService.isValidRole(null));
assertFalse(roleService.isValidRole(""));
assertFalse(roleService.isValidRole("admin"));
assertFalse(roleService.isValidRole("ADMIN123"));
}
}