-
Notifications
You must be signed in to change notification settings - Fork 3
User 테스트코드 추가 및 토큰 조회 API 추가 #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f995ea0
test : userDomainService test 추가
minjee2758 0b42884
test : userDomainService 필요없는 변수 삭제
minjee2758 65a132f
feature : 회원 AI 리뷰 토큰 조회
minjee2758 b31e799
refactor: Timeout 시간 조정
thezz9 c10d36e
feat: 잔디 심기용 데이터 쿼리 메서드 추가
thezz9 0c141f4
Merge branch 'feat/daily-solved-count' of https://github.com/ezcode-m…
minjee2758 3a622cb
feature : 날짜별 문제 성공 횟수 반환 api 추가(마이페이지 잔디만들기용)
minjee2758 4e6f979
transaction 추가
minjee2758 978e511
test 주석
minjee2758 6e5d751
test 삭제
minjee2758 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...ezcode/codetest/application/usermanagement/user/dto/response/UserReviewTokenResponse.java
This file contains hidden or 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,10 @@ | ||
| package org.ezcode.codetest.application.usermanagement.user.dto.response; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
|
|
||
| @Getter | ||
| @AllArgsConstructor | ||
| public class UserReviewTokenResponse { | ||
| private final int reviewToken; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -13,7 +13,6 @@ | |
| import org.ezcode.codetest.domain.user.repository.UserAuthTypeRepository; | ||
| import org.ezcode.codetest.domain.user.repository.UserRepository; | ||
| import org.ezcode.codetest.domain.user.service.UserDomainService; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.extension.ExtendWith; | ||
| import org.mockito.InjectMocks; | ||
|
|
@@ -58,7 +57,6 @@ public class UserDomainServiceTest { | |
| ) { | ||
| public Long getId() { return 1L; } | ||
| public int getReviewToken() { return 5; } | ||
| public int getZeroReviewToken() { return 0; } | ||
| }; | ||
| private final UserAuthType testAuthType = new UserAuthType(testUser, AuthType.EMAIL); | ||
|
|
||
|
|
@@ -173,4 +171,51 @@ void isDeletedUser_shouldPassWhenActive() { | |
| assertDoesNotThrow(() -> userDomainService.isDeletedUser(testUser)); | ||
| } | ||
|
|
||
| // 9. 닉네임 자동 생성 테스트 | ||
| @Test | ||
| void generateUniqueNickname_shouldReturnNonExistingNickname() { | ||
| when(userRepository.existsByNickname(any())).thenReturn(false); | ||
| String nickname = userDomainService.generateUniqueNickname(); | ||
| assertNotNull(nickname); | ||
| } | ||
|
|
||
| @Test | ||
| void generateUniqueNickname_shouldThrowWhenMaxAttempts() { | ||
| when(userRepository.existsByNickname(any())).thenReturn(true); | ||
| assertThrows(IllegalStateException.class, () -> userDomainService.generateUniqueNickname()); | ||
| } | ||
|
|
||
| // 10. 리뷰 토큰 테스트 | ||
| @Test | ||
| void decreaseReviewToken_shouldUpdateWhenTokensAvailable() { | ||
| testUser.setReviewToken(5); | ||
| assertDoesNotThrow(() -> userDomainService.decreaseReviewToken(testUser)); | ||
| verify(userRepository).decreaseReviewToken(testUser); | ||
| } | ||
|
|
||
| @Test | ||
| void decreaseReviewToken_shouldThrowWhenNoTokens() { | ||
| User zeroTokenUser = new User( | ||
| "[email protected]", "pwd", "user", "nick", | ||
| 28, Tier.NEWBIE, UserRole.USER, | ||
| false, true, "https://github.com", false | ||
| ) { | ||
| public int getReviewToken() { | ||
| return 0; | ||
| } | ||
| }; | ||
|
|
||
| UserException exception = assertThrows(UserException.class, | ||
| () -> userDomainService.decreaseReviewToken(zeroTokenUser)); | ||
|
|
||
| assertEquals(UserExceptionCode.NOT_ENOUGH_TOKEN, exception.getResponseCode()); | ||
| } | ||
|
|
||
|
|
||
| // 12. 이메일로 유저 찾기 | ||
| @Test | ||
| void getUserByEmail_shouldReturnUser() { | ||
| when(userRepository.getUserByEmail("[email protected]")).thenReturn(testUser); | ||
| assertEquals(testUser, userDomainService.getUserByEmail("[email protected]")); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.