generated from pricelees/issue-pr-template
[#56] 예약 & 결제 프로세스 및 패키지 구조 재정의 #57
@ -140,7 +140,7 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
|||||||
AND NOT EXISTS (
|
AND NOT EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM ReservationEntity r
|
FROM ReservationEntity r
|
||||||
WHERE r.scheduleId = s._id
|
WHERE r.scheduleId = s._id AND r.status = com.sangdol.roomescape.reservation.infrastructure.persistence.ReservationStatus.PENDING
|
||||||
)
|
)
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleEntity
|
|||||||
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleRepository
|
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleRepository
|
||||||
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleStatus
|
import com.sangdol.roomescape.schedule.infrastructure.persistence.ScheduleStatus
|
||||||
import com.sangdol.roomescape.supports.FunSpecSpringbootTest
|
import com.sangdol.roomescape.supports.FunSpecSpringbootTest
|
||||||
|
import com.sangdol.roomescape.supports.initialize
|
||||||
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
||||||
import io.kotest.assertions.assertSoftly
|
import io.kotest.assertions.assertSoftly
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
@ -47,6 +48,32 @@ class IncompletedReservationSchedulerTest(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test("예약이 있어도, 해당 예약이 ${ReservationStatus.PENDING}이 상태가 아니면 hold_expired_at 시간이 지난 ${ScheduleStatus.HOLD} 일정을 ${ScheduleStatus.AVAILABLE} 상태로 바꾼다.") {
|
||||||
|
val schedule = initialize("취소된 예약 추가") {
|
||||||
|
val reservation = dummyInitializer.createConfirmReservation(
|
||||||
|
user = testAuthUtil.defaultUserLogin().first,
|
||||||
|
).also {
|
||||||
|
it.status = ReservationStatus.CANCELED
|
||||||
|
reservationRepository.saveAndFlush(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
scheduleRepository.findByIdOrNull(reservation.scheduleId)!!.apply {
|
||||||
|
this.status = ScheduleStatus.HOLD
|
||||||
|
this.holdExpiredAt = Instant.now().minusSeconds(1)
|
||||||
|
scheduleRepository.saveAndFlush(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transactionExecutionUtil.withNewTransaction(isReadOnly = false) {
|
||||||
|
incompletedReservationScheduler.processExpiredHoldSchedule()
|
||||||
|
}
|
||||||
|
|
||||||
|
assertSoftly(scheduleRepository.findByIdOrNull(schedule.id)!!) {
|
||||||
|
this.status shouldBe ScheduleStatus.AVAILABLE
|
||||||
|
this.holdExpiredAt shouldBe null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test("${ReservationStatus.PENDING} 상태로 일정 시간 완료되지 않은 예약을 ${ReservationStatus.EXPIRED} 상태로 바꾼다.") {
|
test("${ReservationStatus.PENDING} 상태로 일정 시간 완료되지 않은 예약을 ${ReservationStatus.EXPIRED} 상태로 바꾼다.") {
|
||||||
val user: UserEntity = testAuthUtil.defaultUserLogin().first
|
val user: UserEntity = testAuthUtil.defaultUserLogin().first
|
||||||
val reservation = dummyInitializer.createPendingReservation(user = user).also {
|
val reservation = dummyInitializer.createPendingReservation(user = user).also {
|
||||||
|
|||||||
@ -147,6 +147,7 @@ class DummyInitializer(
|
|||||||
|
|
||||||
scheduleRepository.findByIdOrNull(it.scheduleId)?.let { schedule ->
|
scheduleRepository.findByIdOrNull(it.scheduleId)?.let { schedule ->
|
||||||
schedule.status = ScheduleStatus.RESERVED
|
schedule.status = ScheduleStatus.RESERVED
|
||||||
|
schedule.holdExpiredAt = null
|
||||||
scheduleRepository.save(schedule)
|
scheduleRepository.save(schedule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user