Developer 역할 Spring 골격 smoke #4
1 changed files with 49 additions and 0 deletions
49
src/test/java/com/example/demo/RoleServiceTest.java
Normal file
49
src/test/java/com/example/demo/RoleServiceTest.java
Normal 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"));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue