diff --git a/src/main/kotlin/org/gitanimals/render/domain/User.kt b/src/main/kotlin/org/gitanimals/render/domain/User.kt index 18211f2..bedacb6 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/User.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/User.kt @@ -141,13 +141,7 @@ class User( personas.add(newPersona) } - fun giveBonusPersona(persona: String) { - val personaType = PersonaType.valueOf(persona.uppercase()) - - require(bonusPersonas.contains(personaType)) { - "Cannot select as a bonus persona." - } - + fun giveNewPersonaByType(personaType: PersonaType) { personas.add(getPersona(personaType)) } diff --git a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt index 1da9114..f2d1626 100644 --- a/src/main/kotlin/org/gitanimals/render/domain/UserService.kt +++ b/src/main/kotlin/org/gitanimals/render/domain/UserService.kt @@ -58,7 +58,7 @@ class UserService( val user = getUserByName(name) - user.giveBonusPersona(persona) + user.giveNewPersonaByType(PersonaType.valueOf(persona.uppercase())) } @Retryable(retryFor = [ObjectOptimisticLockingFailureException::class], maxAttempts = 100) diff --git a/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt b/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt index 0259184..a716253 100644 --- a/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt +++ b/src/test/kotlin/org/gitanimals/render/domain/UserTest.kt @@ -83,10 +83,10 @@ internal class UserTest : DescribeSpec({ describe("giveBonusPersona 메소드는") { context("Bonus pet 목록에 등록된 pet의 이름이 주어질 경우,") { val user = User.newUser("new-user", mutableMapOf()) - val persona = "PENGUIN" + val persona = PersonaType.PENGUIN it("새로운 펫을 지급한다.") { - user.giveBonusPersona(persona) + user.giveNewPersonaByType(persona) user.personas.find { it.type == PersonaType.PENGUIN }.shouldNotBeNull() } @@ -94,11 +94,11 @@ internal class UserTest : DescribeSpec({ context("Bonus pet 목록에 등록되지 않은 pet의 이름이 주어질 경우,") { val user = User.newUser("new-user", mutableMapOf()) - val persona = "GOBLIN_BAG" + val persona = PersonaType.GOBLIN_BAG it("예외를 던진다.") { shouldThrowWithMessage("Cannot select as a bonus persona.") { - user.giveBonusPersona(persona) + user.giveNewPersonaByType(persona) } } }