-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
...on/src/main/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package team.comit.simtong.domain.user.usecase | ||
|
||
import team.comit.simtong.domain.auth.exception.UsedEmailException | ||
import team.comit.simtong.domain.user.spi.QueryUserPort | ||
import team.comit.simtong.global.annotation.ReadOnlyUseCase | ||
|
||
/** | ||
* | ||
* 중복된 이메일인지 검사를 담당하는 CheckEmailDuplicationUseCase | ||
* | ||
* @author Chokyunghyeon | ||
* @date 2022/10/14 | ||
* @version 1.0.0 | ||
**/ | ||
@ReadOnlyUseCase | ||
class CheckEmailDuplicationUseCase( | ||
private val queryUserPort: QueryUserPort | ||
) { | ||
|
||
fun execute(email: String) { | ||
if (queryUserPort.existsUserByEmail(email)) { | ||
throw UsedEmailException.EXCEPTION | ||
} | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...c/test/kotlin/team/comit/simtong/domain/user/usecase/CheckEmailDuplicationUseCaseTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package team.comit.simtong.domain.user.usecase | ||
|
||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.assertDoesNotThrow | ||
import org.junit.jupiter.api.assertThrows | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.mockito.BDDMockito.given | ||
import org.springframework.boot.test.mock.mockito.MockBean | ||
import org.springframework.test.context.junit.jupiter.SpringExtension | ||
import team.comit.simtong.domain.auth.exception.UsedEmailException | ||
import team.comit.simtong.domain.user.spi.QueryUserPort | ||
|
||
@ExtendWith(SpringExtension::class) | ||
class CheckEmailDuplicationUseCaseTests { | ||
|
||
@MockBean | ||
private lateinit var queryUserPort: QueryUserPort | ||
|
||
private lateinit var checkEmailDuplicationUseCase: CheckEmailDuplicationUseCase | ||
|
||
private val email = "[email protected]" | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
checkEmailDuplicationUseCase = CheckEmailDuplicationUseCase(queryUserPort) | ||
} | ||
|
||
@Test | ||
fun `중복 없음`() { | ||
// given | ||
given(queryUserPort.existsUserByEmail(email)) | ||
.willReturn(false) | ||
|
||
// when & then | ||
assertDoesNotThrow { | ||
checkEmailDuplicationUseCase.execute(email) | ||
} | ||
} | ||
|
||
@Test | ||
fun `중복 있음`() { | ||
// given | ||
given(queryUserPort.existsUserByEmail(email)) | ||
.willReturn(true) | ||
|
||
// when & then | ||
assertThrows<UsedEmailException> { | ||
checkEmailDuplicationUseCase.execute(email) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters