Reviewer 역할 검증 보고서 smoke (runtime-role-matrix-live-20260714101723-v7-reviewer-001)
Some checks failed
ci / test (pull_request) Failing after 1m46s
Some checks failed
ci / test (pull_request) Failing after 1m46s
This commit is contained in:
parent
c299563670
commit
7065ee0d34
1 changed files with 113 additions and 0 deletions
113
src/test/java/com/klaroworks/runtime/role/RoleValidatorTest.java
Normal file
113
src/test/java/com/klaroworks/runtime/role/RoleValidatorTest.java
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
package com.klaroworks.runtime.role;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
@DisplayName("RoleValidator 테스트")
|
||||
class RoleValidatorTest {
|
||||
|
||||
private RoleValidator validator;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
validator = new RoleValidator();
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("validateRole 메서드 테스트")
|
||||
class ValidateRoleTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"admin", "user", "moderator", "viewer"})
|
||||
@DisplayName("유효한 역할명 검증")
|
||||
void testValidateValidRoleNames(String roleName) {
|
||||
assertTrue(validator.validateRole(roleName),
|
||||
"유효한 역할명 '" + roleName + "'은 유효해야 함");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("null 역할명 검증 시 예외 발생")
|
||||
void testValidateNullRoleName() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> validator.validateRole(null),
|
||||
"null 역할명은 IllegalArgumentException을 발생시켜야 함");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("빈 역할명 검증 시 예외 발생")
|
||||
void testValidateEmptyRoleName() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> validator.validateRole(""),
|
||||
"빈 역할명은 IllegalArgumentException을 발생시켜야 함");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("잘못된 역할명 검증 시 예외 발생")
|
||||
void testValidateInvalidRoleName() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> validator.validateRole("invalid@role"),
|
||||
"잘못된 역할명은 IllegalArgumentException을 발생시켜야 함");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("validateContext 메서드 테스트")
|
||||
class ValidateContextTests {
|
||||
|
||||
@Test
|
||||
@DisplayName("유효한 컨텍스트 검증")
|
||||
void testValidateValidContext() {
|
||||
RoleContext context = new RoleContext();
|
||||
context.setUserId("user-001");
|
||||
context.setRoles(new String[]{"admin"});
|
||||
|
||||
assertTrue(validator.validateContext(context),
|
||||
"유효한 컨텍스트는 true를 반환해야 함");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("null 컨텍스트 검증 시 예외 발생")
|
||||
void testValidateNullContext() {
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> validator.validateContext(null),
|
||||
"null 컨텍스트는 IllegalArgumentException을 발생시켜야 함");
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("빈 사용자 ID 검증 시 예외 발생")
|
||||
void testValidateEmptyUserId() {
|
||||
RoleContext context = new RoleContext();
|
||||
context.setUserId("");
|
||||
|
||||
assertThrows(IllegalArgumentException.class,
|
||||
() -> validator.validateContext(context),
|
||||
"빈 사용자 ID는 IllegalArgumentException을 발생시켜야 함");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
@DisplayName("isValidRoleFormat 메서드 테스트")
|
||||
class IsValidRoleFormatTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"admin", "user", "role_123", "ROLE-NAME"})
|
||||
@DisplayName("유효한 역할 포맷 검증")
|
||||
void testValidRoleFormat(String role) {
|
||||
assertTrue(validator.isValidRoleFormat(role),
|
||||
"유효한 역할 포맷 '" + role + "'은 유효해야 함");
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"invalid@role", "role name", "role;name", ""})
|
||||
@DisplayName("유효하지 않은 역할 포맷 검증")
|
||||
void testInvalidRoleFormat(String role) {
|
||||
assertFalse(validator.isValidRoleFormat(role),
|
||||
"유효하지 않은 역할 포맷 '" + role + "'은 유효하지 않아야 함");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue