fix(gift): 관리자 취소 시각을 초 단위로 정규화한다
This commit is contained in:
+21
-1
@@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest
|
||||
import org.springframework.context.annotation.Import
|
||||
import java.time.LocalDateTime
|
||||
import javax.persistence.EntityManager
|
||||
|
||||
@DataJpaTest(
|
||||
properties = [
|
||||
@@ -39,7 +40,8 @@ class GiftAdminServiceTest @Autowired constructor(
|
||||
private val sizePriceRepository: GiftSizePriceRepository,
|
||||
private val giftRepository: GiftRepository,
|
||||
private val giftDeliveryRepository: GiftDeliveryRepository,
|
||||
private val giftMailboxRepository: GiftMailboxRepository
|
||||
private val giftMailboxRepository: GiftMailboxRepository,
|
||||
private val entityManager: EntityManager
|
||||
) {
|
||||
private val giftPushService = Mockito.mock(GiftPushService::class.java)
|
||||
private val canPaymentService = Mockito.mock(CanPaymentService::class.java)
|
||||
@@ -332,6 +334,24 @@ class GiftAdminServiceTest @Autowired constructor(
|
||||
Mockito.verifyNoInteractions(giftPushService)
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(ints = [0, 123456789, 999999999])
|
||||
@DisplayName("관리자 취소 시각은 나노초 입력에도 초 단위 저장값과 응답이 일치한다")
|
||||
fun shouldPersistAndReturnSameSecondPrecisionCancellationTime(nanos: Int) {
|
||||
val (gift, _) = saveGift(GiftStatus.RECEIVED)
|
||||
val giftId = requireNotNull(gift.id)
|
||||
val now = LocalDateTime.of(2026, 10, 22, 23, 59, 59, nanos)
|
||||
|
||||
val result = service.cancelGift(APPLICATION_NO, now)
|
||||
entityManager.flush()
|
||||
entityManager.clear()
|
||||
|
||||
val persisted = requireNotNull(giftDeliveryRepository.findByGiftId(giftId)?.canceledAt)
|
||||
assertEquals(persisted, result.occurredAt)
|
||||
assertEquals(LocalDateTime.of(2026, 10, 22, 23, 59, 59), persisted)
|
||||
assertEquals(GiftStatus.CANCELED, giftRepository.findById(giftId).orElseThrow().status)
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@EnumSource(value = GiftStatus::class, names = ["RECEIVED"], mode = EnumSource.Mode.EXCLUDE)
|
||||
@DisplayName("운영자는 접수가 아닌 모든 상태의 선물을 취소할 수 없다")
|
||||
|
||||
Reference in New Issue
Block a user