generated from pricelees/issue-pr-template
refactor: 일정 재활성화 스케쥴링 작업에서 예약이 없는 일정 -> PENDING 예약이 없는 일정으로 수정 및 테스트 추가
This commit is contained in:
parent
8378e10192
commit
022742d1fa
@ -140,7 +140,7 @@ interface ScheduleRepository : JpaRepository<ScheduleEntity, Long> {
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
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.ScheduleStatus
|
||||
import com.sangdol.roomescape.supports.FunSpecSpringbootTest
|
||||
import com.sangdol.roomescape.supports.initialize
|
||||
import com.sangdol.roomescape.user.infrastructure.persistence.UserEntity
|
||||
import io.kotest.assertions.assertSoftly
|
||||
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} 상태로 바꾼다.") {
|
||||
val user: UserEntity = testAuthUtil.defaultUserLogin().first
|
||||
val reservation = dummyInitializer.createPendingReservation(user = user).also {
|
||||
|
||||
@ -147,6 +147,7 @@ class DummyInitializer(
|
||||
|
||||
scheduleRepository.findByIdOrNull(it.scheduleId)?.let { schedule ->
|
||||
schedule.status = ScheduleStatus.RESERVED
|
||||
schedule.holdExpiredAt = null
|
||||
scheduleRepository.save(schedule)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user