-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Test] UserServiceTest 작성 #126
Open
packdev937
wants to merge
13
commits into
main
Choose a base branch
from
125-test-user-service-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aa93eea
feat : add UserTestREpository.java to avoid 과도한 의존성
packdev937 fd838c5
feat : UserRepository 내 추상 메소드 구현
packdev937 b37d6cf
feat : 주석 해제
packdev937 5a91cd1
fix : 간단한 오타 수정
packdev937 cdc4b1d
feat : Test 코드 작성을 위한 JwtTokenManager 내 setValue() 메소드 작성
packdev937 919c216
fIx : setValue() 수정
packdev937 ab4fe9d
feat : test를 위한 Builder 추가
packdev937 b411bf0
feat : 객체 생성 후 직접 생성자로 주입
packdev937 0c65c55
feat : 비밀번호 변경과 관련된 테스트 추가 및 encode 하지 않으면 테스트가 제대로 작동되지 않은 현상을 수정
packdev937 8f27a13
feat : 직접 주입한 JwtTokenManager가 잘 작동되는지 확인
packdev937 614f598
test : 회원가입이 정상적으로 이루어지는지 테스트 추가
packdev937 4da6e31
test : 데이터베이스에 설정한 유저 값이 제대로 들어가는지 확인
packdev937 cbbcff5
test : 마이페이지 조회 데이터가 동일한지 확인
packdev937 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
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
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
48 changes: 48 additions & 0 deletions
48
src/test/java/com/umc/yourweather/repository/test/UserTestRepository.java
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,48 @@ | ||
package com.umc.yourweather.repository.test; | ||
|
||
import com.umc.yourweather.domain.entity.User; | ||
import com.umc.yourweather.repository.UserRepository; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public class UserTestRepository implements UserRepository { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 생성자를 추가해야할 것 같네요. |
||
|
||
List<User> repository = new ArrayList<>(); | ||
|
||
@Override | ||
public Optional<User> findByEmail(String email) { | ||
for (User user : repository) { | ||
if (user.getEmail().equals(email)) { | ||
return Optional.of(user); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<User> findByRefreshToken(String refreshToken) { | ||
for (User user : repository) { | ||
if (user.getEmail().equals(refreshToken)) { | ||
return Optional.of(user); | ||
} | ||
} | ||
return Optional.empty(); | ||
} | ||
|
||
@Override | ||
public User save(User user) { | ||
repository.add(user); | ||
return user; | ||
} | ||
|
||
@Override | ||
public void deleteExpiredUser() { | ||
for (User user : repository) { | ||
if (!user.isActivate()) { | ||
repository.remove(user); | ||
} | ||
} | ||
return; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 secretKey, accessTokenExpiration, refreshTokenExpiration을 직접 필드로 넣지 말고 인터페이스와 객체를 추가해
@Value
어노테이션에 대한 JwtTokenManager의 의존성을 제거하면 하면 굳이 프로덕션 코드에 테스트 전용 메서드를 안 써도 될 것 같아요 자세한건 나중에 적어드릴게요..!