[#48] Tosspay mocking 서버 구현을 위한 멀티모듈 전환 #49

Merged
pricelees merged 39 commits from feat/#48 into main 2025-09-30 00:39:14 +00:00
Showing only changes of commit c9fa802cbc - Show all commits

View File

@ -0,0 +1,148 @@
package com.sangdol.roomescape.payment
import com.sangdol.roomescape.payment.exception.PaymentErrorCode
import com.sangdol.roomescape.payment.exception.PaymentException
import com.sangdol.roomescape.payment.infrastructure.common.BankCode
import com.sangdol.roomescape.payment.infrastructure.common.CardIssuerCode
import com.sangdol.roomescape.payment.infrastructure.common.CardOwnerType
import com.sangdol.roomescape.payment.infrastructure.common.CardType
import com.sangdol.roomescape.payment.infrastructure.common.EasyPayCompanyCode
import com.sangdol.roomescape.payment.infrastructure.common.PaymentMethod
import com.sangdol.roomescape.payment.infrastructure.common.PaymentStatus
import com.sangdol.roomescape.payment.infrastructure.common.PaymentType
import io.kotest.assertions.assertSoftly
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.string.shouldHaveLength
import org.junit.jupiter.api.assertThrows
class PaymentTypeTest : FunSpec({
context("PaymentType") {
test("한글 이름으로 가져온다.") {
PaymentType.entries.forEach {
PaymentType.Companion.get(it.name) shouldBe it
}
}
test("없는 이름이면 실패한다.") {
assertThrows<PaymentException> {
PaymentType.Companion.get("NORMAR")
}.also {
it.errorCode shouldBe PaymentErrorCode.TYPE_NOT_FOUND
}
}
}
context("PaymentMethod") {
test("결제수단 한글명으로 가져온다.") {
PaymentMethod.entries.forEach {
PaymentMethod.Companion.get(it.koreanName) shouldBe it
}
}
test("없는 이름이면 실패한다.") {
assertThrows<PaymentException> {
PaymentMethod.Companion.get("카드12")
}.also {
it.errorCode shouldBe PaymentErrorCode.TYPE_NOT_FOUND
}
}
}
context("PaymentStatus") {
test("상수 이름으로 가져온다.") {
PaymentStatus.entries.forEach {
PaymentStatus.Companion.get(it.name) shouldBe it
}
}
test("없는 이름이면 실패한다.") {
assertThrows<PaymentException> {
PaymentStatus.Companion.get("DONEE")
}.also {
it.errorCode shouldBe PaymentErrorCode.TYPE_NOT_FOUND
}
}
}
context("CardType") {
test("한글 이름으로 가져온다.") {
CardType.entries.forEach {
CardType.Companion.get(it.koreanName) shouldBe it
}
}
test("없는 이름을 입력하면 UNKNOWN을 반환한다.") {
CardType.Companion.get("신용카드") shouldBe CardType.UNKNOWN
}
}
context("CardOwnerType") {
test("한글 이름으로 가져온다.") {
CardOwnerType.entries.forEach {
CardOwnerType.Companion.get(it.koreanName) shouldBe it
}
}
test("없는 이름을 입력하면 UNKNOWN을 반환한다.") {
CardOwnerType.Companion.get("개인카드") shouldBe CardOwnerType.UNKNOWN
}
}
context("BankCode") {
test("숫자 코드로 가져온다.") {
BankCode.entries.forEach {
BankCode.Companion.get(it.code) shouldBe it
}
}
test("숫자가 두글자이면 앞에 0을 붙인다.") {
assertSoftly(BankCode.SHINHAN.code) {
this shouldHaveLength 3
BankCode.Companion.get(this.substring(1)) shouldBe BankCode.Companion.get(this)
}
}
test("없는 코드이면 실패한다") {
assertThrows<PaymentException> {
BankCode.Companion.get("9999")
}.also {
it.errorCode shouldBe PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND
}
}
}
context("CardIssuerCode") {
test("숫자 코드로 가져온다.") {
CardIssuerCode.entries.forEach {
CardIssuerCode.Companion.get(it.code) shouldBe it
}
}
test("없는 코드이면 실패한다") {
assertThrows<PaymentException> {
CardIssuerCode.Companion.get("9999")
}.also {
it.errorCode shouldBe PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND
}
}
}
context("EasyPayCompanyCode") {
test("한글 이름으로 가져온다.") {
EasyPayCompanyCode.entries.forEach {
EasyPayCompanyCode.Companion.get(it.koreanName) shouldBe it
}
}
test("없는 이름이면 실패한다") {
assertThrows<PaymentException> {
EasyPayCompanyCode.Companion.get("상돌페이")
}.also {
it.errorCode shouldBe PaymentErrorCode.ORGANIZATION_CODE_NOT_FOUND
}
}
}
})