Skip to content

Commit

Permalink
test: (#281) 변경 적용 Test
Browse files Browse the repository at this point in the history
  • Loading branch information
khcho0125 committed Jan 18, 2023
1 parent 0b92d13 commit 8136be9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import org.junit.jupiter.api.assertDoesNotThrow
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.given
import org.springframework.boot.test.mock.mockito.MockBean
import team.comit.simtong.domain.user.dto.request.CheckMatchedAccountData
import team.comit.simtong.domain.user.exception.UserExceptions
import team.comit.simtong.domain.user.spi.QueryUserPort
import team.comit.simtong.global.annotation.SimtongTest
Expand All @@ -19,12 +18,9 @@ class CheckMatchedAccountUseCaseTests {

private lateinit var checkMatchedAccountUseCase: CheckMatchedAccountUseCase

private val requestStub: CheckMatchedAccountData by lazy {
CheckMatchedAccountData(
employeeNumber = 1234567890,
email = "[email protected]"
)
}
private val employeeNumber = 1234567890

private val email = "[email protected]"

@BeforeEach
fun setUp() {
Expand All @@ -34,24 +30,24 @@ class CheckMatchedAccountUseCaseTests {
@Test
fun `계정 확인 성공`() {
// given
given(queryUserPort.existsUserByEmployeeNumberAndEmail(requestStub.employeeNumber, requestStub.email))
given(queryUserPort.existsUserByEmployeeNumberAndEmail(employeeNumber, email))
.willReturn(true)

// when & then
assertDoesNotThrow {
checkMatchedAccountUseCase.execute(requestStub)
checkMatchedAccountUseCase.execute(employeeNumber, email)
}
}

@Test
fun `계정 확인 실패`() {
// given
given(queryUserPort.existsUserByEmployeeNumberAndEmail(requestStub.employeeNumber, requestStub.email))
given(queryUserPort.existsUserByEmployeeNumberAndEmail(employeeNumber, email))
.willReturn(false)

// when & then
assertThrows<UserExceptions.NotFound> {
checkMatchedAccountUseCase.execute(requestStub)
checkMatchedAccountUseCase.execute(employeeNumber, email)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ class FindEmployeeNumberUseCaseTests {
given(queryUserPort.queryUserByNameAndSpotAndEmail(name, spotId, email))
.willReturn(userStub)

// when
val response = findEmployeeNumberUseCase.execute(requestStub)

// when & then
assertEquals(findEmployeeNumberUseCase.execute(requestStub), employeeNumber)
assertEquals(response.employeeNumber, employeeNumber)
}

@Test
Expand Down

0 comments on commit 8136be9

Please sign in to comment.