From 646fafedf024d416461afbaba7ff205d90516a3d Mon Sep 17 00:00:00 2001 From: devxb Date: Sun, 20 Oct 2024 13:17:37 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=B3=B4=EB=84=88=EC=8A=A4=20=ED=8E=AB?= =?UTF-8?q?=20=EC=A7=80=EA=B8=89=20=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/kotlin/org/gitanimals/render/domain/User.kt | 8 +------- .../kotlin/org/gitanimals/render/domain/UserService.kt | 2 +- src/test/kotlin/org/gitanimals/render/domain/UserTest.kt | 8 ++++---- 3 files changed, 6 insertions(+), 12 deletions(-) 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) } } }