feat(gift): 선물 받을 주소 관리자 서비스를 추가한다

This commit is contained in:
2026-10-01 22:57:07 +09:00
parent f66c89fb7f
commit 33b6662cb4
2 changed files with 113 additions and 1 deletions
@@ -6,6 +6,7 @@ import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.Gift
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftCategoryRepository
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftDelivery
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftDeliveryRepository
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftMailboxRepository
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftRepository
import kr.co.vividnext.sodalive.v2.gift.adapter.out.persistence.GiftSizePriceRepository
import kr.co.vividnext.sodalive.v2.gift.domain.GiftSize
@@ -33,7 +34,8 @@ class GiftAdminServiceTest @Autowired constructor(
private val categoryRepository: GiftCategoryRepository,
private val sizePriceRepository: GiftSizePriceRepository,
private val giftRepository: GiftRepository,
private val giftDeliveryRepository: GiftDeliveryRepository
private val giftDeliveryRepository: GiftDeliveryRepository,
private val giftMailboxRepository: GiftMailboxRepository
) {
private val giftPushService = Mockito.mock(GiftPushService::class.java)
private val service = GiftAdminService(
@@ -41,9 +43,61 @@ class GiftAdminServiceTest @Autowired constructor(
sizePriceRepository,
giftRepository,
giftDeliveryRepository,
giftMailboxRepository,
giftPushService
)
@Test
@DisplayName("받을 주소는 미등록이면 null이고 저장 후 단일 설정으로 갱신된다")
fun shouldUpsertGiftMailbox() {
assertEquals(null, service.getMailbox())
val created = service.updateMailbox(
GiftMailboxCommand(
name = "소다라이브 선물 담당자",
phoneNumber = "01012345678",
zipCode = "06234",
address = "서울시 강남구",
addressDetail = "3층 선물 접수처"
)
)
val updated = service.updateMailbox(
GiftMailboxCommand(
name = "소다라이브 운영팀",
phoneNumber = "01087654321",
zipCode = "04524",
address = "서울시 중구",
addressDetail = null
)
)
assertEquals("소다라이브 선물 담당자", created.name)
assertEquals("(06234) 서울시 강남구, 3층 선물 접수처", created.address)
assertEquals("01012345678", created.phoneNumber)
assertEquals("소다라이브 운영팀", updated.name)
assertEquals("(04524) 서울시 중구", updated.address)
assertEquals(1, giftMailboxRepository.count())
}
@Test
@DisplayName("받을 주소 필수값이 공백이면 저장할 수 없다")
fun shouldRejectInvalidGiftMailbox() {
val exception = assertThrows(SodaException::class.java) {
service.updateMailbox(
GiftMailboxCommand(
name = " ",
phoneNumber = "01012345678",
zipCode = "06234",
address = "서울시 강남구",
addressDetail = null
)
)
}
assertEquals("common.error.invalid_request", exception.messageKey)
assertEquals(0, giftMailboxRepository.count())
}
@Test
@DisplayName("카테고리를 등록, 수정, 논리삭제한다")
fun shouldCreateUpdateAndDeactivateCategory() {