Merge pull request 'Developer 역할 Spring 골격 smoke' (#4) from forge/runtime-role-matrix-live-20260714112301-v11-developer-001-attempt-1-run-9c63dd5c6aca into main

This commit is contained in:
forge-bot 2026-07-14 11:27:55 +00:00
commit bc884148ab
5 changed files with 131 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# runtime-role-matrix-live-20260714112301-v11-developer-001-attempt-1-run-9c63dd5c6aca
Forge 이슈 작업 브랜치 `forge/runtime-role-matrix-live-20260714112301-v11-developer-001-attempt-1-run-9c63dd5c6aca`.

43
pom.xml Normal file
View file

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/>
</parent>
<groupId>com.example</groupId>
<artifactId>runtime-role-matrix-live</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View file

@ -0,0 +1,12 @@
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

View file

@ -0,0 +1,24 @@
package com.example.demo;
import org.springframework.stereotype.Service;
@Service
public class RoleService {
public String getRoleName(String roleId) {
if (roleId == null || roleId.isBlank()) {
return "UNKNOWN";
}
return switch (roleId.toUpperCase()) {
case "ADMIN" -> "Administrator";
case "DEVELOPER" -> "Developer";
case "VIEWER" -> "Viewer";
default -> "Role: " + roleId;
};
}
public boolean isValidRole(String roleId) {
return roleId != null && !roleId.isBlank() &&
roleId.matches("^[A-Z_]+$");
}
}

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"));
}
}