[#20] 도메인별 예외 분리 #21

Merged
pricelees merged 37 commits from refactor/#20 into main 2025-07-24 02:48:53 +00:00
Showing only changes of commit 42780f1eed - Show all commits

View File

@ -12,6 +12,7 @@ import roomescape.theme.exception.ThemeException
import roomescape.theme.infrastructure.persistence.ThemeEntity
import roomescape.theme.infrastructure.persistence.ThemeRepository
import roomescape.theme.web.ThemeCreateRequest
import roomescape.theme.web.ThemeRetrieveResponse
import roomescape.util.ThemeFixture
class ThemeServiceTest : FunSpec({
@ -59,19 +60,43 @@ class ThemeServiceTest : FunSpec({
}
context("save") {
test("테마 이름이 중복되면 409 예외를 던진다.") {
val name = "Duplicate Theme"
val request = ThemeCreateRequest(
name = "New Theme",
description = "Description",
thumbnail = "http://example.com/thumbnail.jpg"
)
test("저장 성공") {
every {
themeRepository.existsByName(request.name)
} returns false
every {
themeRepository.existsByName(name)
themeRepository.save(any())
} returns ThemeFixture.create(
id = 1L,
name = request.name,
description = request.description,
thumbnail = request.thumbnail
)
val response: ThemeRetrieveResponse = themeService.createTheme(request)
assertSoftly(response) {
this.id shouldBe 1L
this.name shouldBe request.name
this.description shouldBe request.description
this.thumbnail shouldBe request.thumbnail
}
}
test("테마 이름이 중복되면 409 예외를 던진다.") {
every {
themeRepository.existsByName(request.name)
} returns true
val exception = shouldThrow<ThemeException> {
themeService.createTheme(ThemeCreateRequest(
name = name,
description = "Description",
thumbnail = "http://example.com/thumbnail.jpg"
))
themeService.createTheme(request)
}
exception.errorCode shouldBe ThemeErrorCode.THEME_NAME_DUPLICATED