Skip to content

Commit

Permalink
merge: (#747) 외출 제약 조건 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
4mjeo authored Sep 19, 2024
2 parents 4c4a2d7 + 8e3b9ac commit e7100f4
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ data class OutingAvailableTime(
) : SchoolIdDomain {

fun checkAvailable(
dayOfWeek: DayOfWeek,
outingTime: LocalTime,
arrivalTime: LocalTime,
) {
if (this.dayOfWeek != dayOfWeek ||
if (
this.outingTime.isAfter(outingTime) ||
this.arrivalTime.isBefore(arrivalTime)
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class CheckOutingServiceImpl(
arrivalTime: LocalTime
) {
queryOutingAvailableTimePort.queryOutingAvailableTimeByDayOfWeek(outingDate.dayOfWeek)
?.checkAvailable(outingDate.dayOfWeek, outingTime, arrivalTime)
?: throw OutingAvailableTimeMismatchException
?.checkAvailable(outingTime, arrivalTime)
?:throw OutingAvailableTimeMismatchException
}

override fun checkOutingTypeExists(outingType: OutingType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,17 @@ class OutingAvailableTimeTest : DescribeSpec({
it("외출 신청이 가능하다") {
shouldNotThrowAny {
outingAvailableTime.checkAvailable(
dayOfWeek = DayOfWeek.SUNDAY,
outingTime = LocalTime.of(12, 0, 0),
arrivalTime = LocalTime.of(20, 30, 0)
)
}
}
}

context("외출하는 날이 아닐 때 외출 신청을 하면") {
it("예외가 발생한다") {
shouldThrow<OutingAvailableTimeMismatchException> {
outingAvailableTime.checkAvailable(
dayOfWeek = DayOfWeek.SATURDAY,
outingTime = LocalTime.of(14, 0, 0),
arrivalTime = LocalTime.of(20, 0, 0)
)
}
}
}

context("외출 가능 시간 전에 외출 신청을 하면") {
it("예외가 발생한다") {
shouldThrow<OutingAvailableTimeMismatchException> {
outingAvailableTime.checkAvailable(
dayOfWeek = DayOfWeek.SATURDAY,
outingTime = LocalTime.of(11, 59, 59),
arrivalTime = LocalTime.of(20, 0, 0)
)
Expand All @@ -57,7 +43,6 @@ class OutingAvailableTimeTest : DescribeSpec({
it("예외가 발생한다") {
shouldThrow<OutingAvailableTimeMismatchException> {
outingAvailableTime.checkAvailable(
dayOfWeek = DayOfWeek.SATURDAY,
outingTime = LocalTime.of(14, 0, 0),
arrivalTime = LocalTime.of(20, 30, 1)
)
Expand Down

0 comments on commit e7100f4

Please sign in to comment.