Skip to content

Commit

Permalink
test: (#231) 남은 연차 개수 testcase 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Dec 20, 2022
1 parent 28d5cdf commit e2dde27
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package team.comit.simtong.domain.holiday.usecase

import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
import org.mockito.kotlin.given
import org.springframework.boot.test.mock.mockito.MockBean
import team.comit.simtong.domain.holiday.model.Holiday
import team.comit.simtong.domain.holiday.model.HolidayType
import team.comit.simtong.domain.holiday.spi.HolidaySecurityPort
import team.comit.simtong.domain.holiday.spi.QueryHolidayPort
import team.comit.simtong.global.annotation.SimtongTest
import java.util.UUID

@SimtongTest
class RemainAnnualUseCaseTests {

@MockBean
private lateinit var queryHolidayPort: QueryHolidayPort

@MockBean
private lateinit var securityPort: HolidaySecurityPort

private lateinit var remainAnnualUseCase: RemainAnnualUseCase

private val id: UUID = UUID.randomUUID()

private val year: Int = 2023

@BeforeEach
fun setUp() {
remainAnnualUseCase = RemainAnnualUseCase(queryHolidayPort, securityPort)
}

@Test
fun `남은 연차 개수`() {
// given
val count: Long = 0

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

given(queryHolidayPort.countHolidayByYearAndUserIdAndType(year, id, HolidayType.ANNUAL))
.willReturn(count)

// when
val result = remainAnnualUseCase.execute(year)

// then
assertEquals(result, Holiday.ANNUAL_LEAVE_LIMIT - count)
}
}

0 comments on commit e2dde27

Please sign in to comment.