feat(gift): 선물 응답 시각을 UTC 문자열로 변환한다

This commit is contained in:
2026-09-30 17:38:51 +09:00
parent 2bda30e7e2
commit 22c6cd2d38
4 changed files with 103 additions and 44 deletions
@@ -10,6 +10,7 @@ import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftSizePrice
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftSizePriceRepository
import kr.co.vividnext.sodalive.v2.gift.domain.GiftSize
import kr.co.vividnext.sodalive.v2.gift.domain.GiftStatus
import org.hamcrest.Matchers.endsWith
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
@@ -62,13 +63,24 @@ class AdminGiftControllerTest @Autowired constructor(
.contentType(MediaType.APPLICATION_JSON)
.content(
"""
{"categoryCode":"DOLL","name":"인형","requiresDamageWaiver":true,"isActive":true}
{
"classificationNumber":"100",
"categoryCode":"DOLL",
"name":"인형",
"receiptCode":"A",
"representativeItem":"피규어",
"requiresDamageWaiver":true,
"isActive":true
}
""".trimIndent()
)
)
.andExpect(status().isOk)
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.classificationNumber").value("100"))
.andExpect(jsonPath("$.data.categoryCode").value("DOLL"))
.andExpect(jsonPath("$.data.receiptCode").value("A"))
.andExpect(jsonPath("$.data.representativeItem").value("피규어"))
val categoryId = categoryRepository.findByCategoryCode("DOLL")!!.id!!
@@ -78,12 +90,23 @@ class AdminGiftControllerTest @Autowired constructor(
.contentType(MediaType.APPLICATION_JSON)
.content(
"""
{"categoryCode":"DOLL","name":"큰 인형","requiresDamageWaiver":false,"isActive":true}
{
"classificationNumber":"101",
"categoryCode":"DOLL",
"name":"큰 인형",
"receiptCode":"B",
"representativeItem":"대형 피규어",
"requiresDamageWaiver":false,
"isActive":true
}
""".trimIndent()
)
)
.andExpect(status().isOk)
.andExpect(jsonPath("$.data.classificationNumber").value("101"))
.andExpect(jsonPath("$.data.name").value("큰 인형"))
.andExpect(jsonPath("$.data.receiptCode").value("B"))
.andExpect(jsonPath("$.data.representativeItem").value("대형 피규어"))
mockMvc.perform(get("/api/v2/admin/gift-categories").with(user("admin").roles("ADMIN")))
.andExpect(status().isOk)
@@ -132,11 +155,13 @@ class AdminGiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.applicationNo").value(APPLICATION_NO))
.andExpect(jsonPath("$.data.status").value("ARRIVED_AT_MAILBOX"))
.andExpect(jsonPath("$.data.occurredAt").value(endsWith("Z")))
mockMvc.perform(post("/api/v2/admin/gifts/$APPLICATION_NO/complete-inspection").with(user("admin").roles("ADMIN")))
.andExpect(status().isOk)
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.status").value("INSPECTION_COMPLETED"))
.andExpect(jsonPath("$.data.occurredAt").value(endsWith("Z")))
}
@Test
@@ -154,6 +179,7 @@ class AdminGiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.applicationNo").value(APPLICATION_NO))
.andExpect(jsonPath("$.data.status").value("UNDELIVERABLE"))
.andExpect(jsonPath("$.data.occurredAt").value(endsWith("Z")))
}
@Test
@@ -181,6 +207,7 @@ class AdminGiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.success").value(true))
.andExpect(jsonPath("$.data.applicationNo").value(APPLICATION_NO))
.andExpect(jsonPath("$.data.status").value("DELIVERED"))
.andExpect(jsonPath("$.data.occurredAt").value(endsWith("Z")))
}
private fun saveGift(status: GiftStatus) {
@@ -26,6 +26,7 @@ import kr.co.vividnext.sodalive.v2.gift.application.GiftReviewResult
import kr.co.vividnext.sodalive.v2.gift.application.GiftTrackingRegistrationResult
import kr.co.vividnext.sodalive.v2.gift.domain.GiftSize
import kr.co.vividnext.sodalive.v2.gift.domain.GiftStatus
import org.hamcrest.Matchers.endsWith
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.mockito.Mockito
@@ -64,8 +65,8 @@ class GiftControllerTest @Autowired constructor(
@Test
fun `팬은 활성 폼 옵션을 조회하고 categoryCode를 받지 않는다`() {
categoryRepository.save(GiftCategory("DOLL", "인형", true, true))
categoryRepository.save(GiftCategory("FOOD", "간식", false, false))
categoryRepository.save(giftCategory("100", "DOLL", "A", "인형", "피규어", true, true))
categoryRepository.save(giftCategory("200", "FOOD", "B", "간식", "쿠키", false, false))
sizePriceRepository.save(GiftSizePrice(GiftSize.SMALL, 100, 80, true))
mockMvc.perform(get("/api/v2/gifts/form-options").with(user("fan").roles("USER")))
@@ -75,8 +76,11 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.sizes[0].name").value("소형"))
.andExpect(jsonPath("$.data.sizes[0].basePriceCan").value(100))
.andExpect(jsonPath("$.data.sizes[0].salePriceCan").value(80))
.andExpect(jsonPath("$.data.categories[0].name").value("인형"))
.andExpect(jsonPath("$.data.categories[0].name").value("인형/피규어"))
.andExpect(jsonPath("$.data.categories[0].categoryCode").doesNotExist())
.andExpect(jsonPath("$.data.categories[0].classificationNumber").doesNotExist())
.andExpect(jsonPath("$.data.categories[0].receiptCode").doesNotExist())
.andExpect(jsonPath("$.data.categories[0].representativeItem").doesNotExist())
}
@Test
@@ -113,7 +117,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.items[0].priceCan").value(80))
.andExpect(jsonPath("$.data.items[0].categoryName").value("인형"))
.andExpect(jsonPath("$.data.items[0].sizeName").value("소형"))
.andExpect(jsonPath("$.data.items[0].createdAt").exists())
.andExpect(jsonPath("$.data.items[0].createdAt").value(endsWith("Z")))
}
@Test
@@ -161,7 +165,11 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.recipientAddress").isEmpty)
.andExpect(jsonPath("$.data.trackingRequired").value(false))
.andExpect(jsonPath("$.data.statusTimeline[0].status").value("RECEIVED"))
.andExpect(jsonPath("$.data.statusTimeline[1].occurredAt").value("2026-09-30T12:00:00"))
.andExpect(jsonPath("$.data.recipientAddressDeadlineAt").isEmpty)
.andExpect(jsonPath("$.data.giftInfo.shippingRequestedAt").isEmpty)
.andExpect(jsonPath("$.data.delivery.canceledAt").isEmpty)
.andExpect(jsonPath("$.data.delivery.undeliverableAt").isEmpty)
.andExpect(jsonPath("$.data.statusTimeline[1].occurredAt").value("2026-09-30T12:00:00Z"))
}
@Test
@@ -209,7 +217,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.status").value("RECEIVED"))
.andExpect(jsonPath("$.data.statusName").value("접수 완료"))
.andExpect(jsonPath("$.data.priceCan").value(80))
.andExpect(jsonPath("$.data.trackingDeadlineAt").value("2026-10-02T12:00:00"))
.andExpect(jsonPath("$.data.trackingDeadlineAt").value("2026-10-02T12:00:00Z"))
}
@Test
@@ -240,7 +248,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.status").value("CANCELED"))
.andExpect(jsonPath("$.data.statusName").value("신청 취소"))
.andExpect(jsonPath("$.data.priceCan").value(80))
.andExpect(jsonPath("$.data.canceledAt").value("2026-09-29T12:00:00"))
.andExpect(jsonPath("$.data.canceledAt").value("2026-09-29T12:00:00Z"))
}
@Test
@@ -281,8 +289,8 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.statusName").value("발송 확인"))
.andExpect(jsonPath("$.data.courierCompanyName").value("CJ대한통운"))
.andExpect(jsonPath("$.data.trackingNumber").value("1234567890"))
.andExpect(jsonPath("$.data.trackingRegisteredAt").value("2026-09-29T12:00:00"))
.andExpect(jsonPath("$.data.recipientAddressDeadlineAt").value("2026-10-06T12:00:00"))
.andExpect(jsonPath("$.data.trackingRegisteredAt").value("2026-09-29T12:00:00Z"))
.andExpect(jsonPath("$.data.recipientAddressDeadlineAt").value("2026-10-06T12:00:00Z"))
}
@Test
@@ -324,7 +332,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.applicationNo").value(APPLICATION_NO))
.andExpect(jsonPath("$.data.status").value("TRACKING_REGISTERED"))
.andExpect(jsonPath("$.data.statusName").value("발송 확인"))
.andExpect(jsonPath("$.data.recipientAddressRegisteredAt").value("2026-09-29T12:00:00"))
.andExpect(jsonPath("$.data.recipientAddressRegisteredAt").value("2026-09-29T12:00:00Z"))
}
@Test
@@ -350,7 +358,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.applicationNo").value(APPLICATION_NO))
.andExpect(jsonPath("$.data.status").value("DELIVERED"))
.andExpect(jsonPath("$.data.statusName").value("전달완료"))
.andExpect(jsonPath("$.data.deliveredAt").value("2026-09-29T12:00:00"))
.andExpect(jsonPath("$.data.deliveredAt").value("2026-09-29T12:00:00Z"))
Mockito.verify(commandService).confirmDelivery(member, APPLICATION_NO)
}
@@ -391,7 +399,7 @@ class GiftControllerTest @Autowired constructor(
.andExpect(jsonPath("$.data.keywords[1]").value("안내가 친절해요"))
.andExpect(jsonPath("$.data.keyword").doesNotExist())
.andExpect(jsonPath("$.data.comment").value("선물 전달 과정이 만족스러웠습니다."))
.andExpect(jsonPath("$.data.createdAt").value("2026-10-11T12:00:00"))
.andExpect(jsonPath("$.data.createdAt").value("2026-10-11T12:00:00Z"))
Mockito.verify(commandService).writeReview(member, APPLICATION_NO, request.toCommand())
}
@@ -419,6 +427,24 @@ class GiftControllerTest @Autowired constructor(
)
)
private fun giftCategory(
classificationNumber: String,
categoryCode: String,
receiptCode: String,
name: String,
representativeItem: String,
requiresDamageWaiver: Boolean,
isActive: Boolean
) = GiftCategory(
classificationNumber = classificationNumber,
categoryCode = categoryCode,
name = name,
receiptCode = receiptCode,
representativeItem = representativeItem,
requiresDamageWaiver = requiresDamageWaiver,
isActive = isActive
)
private companion object {
const val SENDER_ID = 1L
const val RECIPIENT_ID = 2L