feat(gift): 신청번호 채번 저장 기준을 분리한다
This commit is contained in:
+25
-6
@@ -35,8 +35,11 @@ class GiftEntityMappingTest @Autowired constructor(
|
||||
fun shouldSaveAndFindGiftWithDelivery() {
|
||||
val category = giftCategoryRepository.save(
|
||||
GiftCategory(
|
||||
classificationNumber = "100",
|
||||
categoryCode = "DOLL",
|
||||
name = "인형",
|
||||
receiptCode = "A",
|
||||
representativeItem = "피규어",
|
||||
requiresDamageWaiver = true
|
||||
)
|
||||
)
|
||||
@@ -89,9 +92,9 @@ class GiftEntityMappingTest @Autowired constructor(
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("신청번호와 카테고리 코드와 리뷰 선물 ID는 중복 저장할 수 없다")
|
||||
@DisplayName("신청번호와 카테고리 unique 값과 리뷰 선물 ID는 중복 저장할 수 없다")
|
||||
fun shouldRejectDuplicateUniqueValues() {
|
||||
val category = giftCategoryRepository.save(GiftCategory(categoryCode = "DOLL", name = "인형"))
|
||||
val category = giftCategoryRepository.save(giftCategory("100", "DOLL", "A"))
|
||||
val gift = giftRepository.save(gift(category.id!!, "G20260929000001"))
|
||||
giftRepository.saveAndFlush(gift(category.id!!, "G20260929000002"))
|
||||
giftReviewRepository.saveAndFlush(GiftReview(giftId = gift.id!!, senderMemberId = 1L, rating = 5))
|
||||
@@ -100,7 +103,13 @@ class GiftEntityMappingTest @Autowired constructor(
|
||||
giftRepository.saveAndFlush(gift(category.id!!, "G20260929000001"))
|
||||
}
|
||||
assertThrows(DataIntegrityViolationException::class.java) {
|
||||
giftCategoryRepository.saveAndFlush(GiftCategory(categoryCode = "DOLL", name = "중복"))
|
||||
giftCategoryRepository.saveAndFlush(giftCategory("101", "DOLL", "B"))
|
||||
}
|
||||
assertThrows(DataIntegrityViolationException::class.java) {
|
||||
giftCategoryRepository.saveAndFlush(giftCategory("100", "TOY", "B"))
|
||||
}
|
||||
assertThrows(DataIntegrityViolationException::class.java) {
|
||||
giftCategoryRepository.saveAndFlush(giftCategory("101", "TOY", "A"))
|
||||
}
|
||||
assertThrows(DataIntegrityViolationException::class.java) {
|
||||
giftReviewRepository.saveAndFlush(GiftReview(giftId = gift.id!!, senderMemberId = 1L, rating = 4))
|
||||
@@ -108,13 +117,15 @@ class GiftEntityMappingTest @Autowired constructor(
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("날짜별 신청번호 채번 sequence를 저장한다")
|
||||
@DisplayName("카테고리와 날짜별 신청번호 채번 sequence를 저장한다")
|
||||
fun shouldSaveApplicationNoSequence() {
|
||||
val category = giftCategoryRepository.save(giftCategory("100", "DOLL", "A"))
|
||||
val sequence = giftApplicationNoSequenceRepository.save(
|
||||
GiftApplicationNoSequence(sequenceDate = "20260929", lastSequence = 1)
|
||||
GiftApplicationNoSequence(categoryId = category.id!!, sequenceDate = "260929", lastSequence = 1)
|
||||
)
|
||||
|
||||
assertEquals("20260929", sequence.sequenceDate)
|
||||
assertEquals(category.id, sequence.categoryId)
|
||||
assertEquals("260929", sequence.sequenceDate)
|
||||
assertEquals(1, sequence.lastSequence)
|
||||
}
|
||||
|
||||
@@ -134,4 +145,12 @@ class GiftEntityMappingTest @Autowired constructor(
|
||||
senderPrivacyAgreedAt = LocalDateTime.of(2026, 9, 29, 12, 0),
|
||||
damageWaiverAgreed = true
|
||||
)
|
||||
|
||||
private fun giftCategory(classificationNumber: String, categoryCode: String, receiptCode: String) = GiftCategory(
|
||||
classificationNumber = classificationNumber,
|
||||
categoryCode = categoryCode,
|
||||
name = "인형",
|
||||
receiptCode = receiptCode,
|
||||
representativeItem = "피규어"
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user