generated from pricelees/issue-pr-template
test: PaymentType enum 테스트 추가
This commit is contained in:
parent
51ad28ddca
commit
c9fa802cbc
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user