Skip to content

Commit

Permalink
test: (#286) 테스트 코드 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
softpeanut committed Jan 9, 2023
1 parent 14f933c commit 11c81ce
Showing 1 changed file with 8 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ class AppointAnnualUseCaseTests {
given(queryUserPort.queryUserById(id))
.willReturn(userStub)

given(queryHolidayPort.queryHolidayByDateAndUserId(date, id))
.willReturn(null)
given(queryHolidayPort.existsHolidayByDateAndUserIdAndType(date, userStub.id, HolidayType.ANNUAL))
.willReturn(false)

given(queryHolidayPort.countHolidayByYearAndUserIdAndType(date.year, id, HolidayType.ANNUAL))
.willReturn(0)
Expand All @@ -97,8 +97,8 @@ class AppointAnnualUseCaseTests {
given(queryUserPort.queryUserById(id))
.willReturn(userStub)

given(queryHolidayPort.queryHolidayByDateAndUserId(date, id))
.willReturn(null)
given(queryHolidayPort.existsHolidayByDateAndUserIdAndType(date, userStub.id, HolidayType.ANNUAL))
.willReturn(false)

given(queryHolidayPort.countHolidayByYearAndUserIdAndType(date.year, id, HolidayType.ANNUAL))
.willReturn(Holiday.ANNUAL_LEAVE_LIMIT)
Expand All @@ -112,22 +112,14 @@ class AppointAnnualUseCaseTests {
@Test
fun `작성중인 휴무일을 변경할 때`() {
// given
val holidayStub = Holiday(
date = date,
spotId = id,
type = HolidayType.HOLIDAY,
userId = id,
status = HolidayStatus.WRITTEN
)

given(securityPort.getCurrentUserId())
.willReturn(id)

given(queryUserPort.queryUserById(id))
.willReturn(userStub)

given(queryHolidayPort.queryHolidayByDateAndUserId(date, userStub.id))
.willReturn(holidayStub)
given(queryHolidayPort.existsHolidayByDateAndUserIdAndType(date, userStub.id, HolidayType.ANNUAL))
.willReturn(false)

given(queryHolidayPort.countHolidayByYearAndUserIdAndType(date.year, id, HolidayType.ANNUAL))
.willReturn(0)
Expand All @@ -138,32 +130,6 @@ class AppointAnnualUseCaseTests {
}
}

@Test
fun `확정된 휴무일을 변경할 때`() {
// given
val holidayStub = Holiday(
date = date,
spotId = id,
type = HolidayType.HOLIDAY,
userId = id,
status = HolidayStatus.COMPLETED
)

given(securityPort.getCurrentUserId())
.willReturn(id)

given(queryUserPort.queryUserById(id))
.willReturn(userStub)

given(queryHolidayPort.queryHolidayByDateAndUserId(date, userStub.id))
.willReturn(holidayStub)

// when & then
assertThrows<HolidayExceptions.AlreadyExists> {
appointAnnualUseCase.execute(date)
}
}

@Test
fun `이미 연차일때`() {
// given
Expand All @@ -181,8 +147,8 @@ class AppointAnnualUseCaseTests {
given(queryUserPort.queryUserById(id))
.willReturn(userStub)

given(queryHolidayPort.queryHolidayByDateAndUserId(date, userStub.id))
.willReturn(annualStub)
given(queryHolidayPort.existsHolidayByDateAndUserIdAndType(date, userStub.id, HolidayType.ANNUAL))
.willReturn(true)

// when & then
assertThrows<HolidayExceptions.AlreadyExists> {
Expand Down Expand Up @@ -212,5 +178,4 @@ class AppointAnnualUseCaseTests {
appointAnnualUseCase.execute(LocalDate.MIN)
}
}

}

0 comments on commit 11c81ce

Please sign in to comment.