package roomescape.payment.infrastructure.client import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.databind.module.SimpleModule import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import io.kotest.assertions.assertSoftly import io.kotest.core.spec.style.StringSpec import io.kotest.matchers.shouldBe import roomescape.payment.web.PaymentCancelResponse class PaymentCancelResponseDeserializerTest : StringSpec({ val objectMapper: ObjectMapper = jacksonObjectMapper().registerModule( SimpleModule().addDeserializer( PaymentCancelResponse::class.java, PaymentCancelResponseDeserializer() ) ) "결제 취소 응답을 역직렬화하여 PaymentCancelResponse 객체를 생성한다" { val cancelResponseJson: String = SampleTossPaymentConst.cancelJson val cancelResponse: PaymentCancelResponse = objectMapper.readValue( cancelResponseJson, PaymentCancelResponse::class.java ) assertSoftly(cancelResponse) { cancelResponse.cancelStatus shouldBe "DONE" cancelResponse.cancelReason shouldBe SampleTossPaymentConst.cancelReason cancelResponse.cancelAmount shouldBe SampleTossPaymentConst.amount cancelResponse.canceledAt.toString() shouldBe "2024-02-13T12:20:23+09:00" } } })