Skip to content

Commit

Permalink
fix: 보너스 펫 지급 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
devxb committed Oct 20, 2024
1 parent 5f5b9d2 commit 646fafe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/main/kotlin/org/gitanimals/render/domain/User.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions src/test/kotlin/org/gitanimals/render/domain/UserTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ 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()
}
}

context("Bonus pet 목록에 등록되지 않은 pet의 이름이 주어질 경우,") {
val user = User.newUser("new-user", mutableMapOf())
val persona = "GOBLIN_BAG"
val persona = PersonaType.GOBLIN_BAG

it("예외를 던진다.") {
shouldThrowWithMessage<IllegalArgumentException>("Cannot select as a bonus persona.") {
user.giveBonusPersona(persona)
user.giveNewPersonaByType(persona)
}
}
}
Expand Down

0 comments on commit 646fafe

Please sign in to comment.