-
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
테스트 코드 추가 및 리팩토링 #28
Open
gru3530
wants to merge
28
commits into
main
Choose a base branch
from
feature/enterTestCode
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
테스트 코드 추가 및 리팩토링 #28
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
94bf3e4
[WIP] FollowServiceTest 추가
cfb488e
FollowController Validate 어노테이션 추가
0732814
상수->변수로 이동
47a9a0f
FollowGroup Transactional 적용
c4ca026
[AUTH] token 변조 시 Exception 처리 추가
3f4a463
사용하지 않는 변수 정리
4551112
[UTIL] ParseUtil 최적화
5173c13
FollowPair 삭제 및 FollowDto 로 통합
27fa715
메인 폴더와 동일 구조로 테스트 dto 폴더 이동
bc3b0cb
[TEST] followServiceTest 작성
bf263b7
불필요한 ResponseEntity 삭제
f80aec2
[BUG] GetFollower 팔로워 불러오지 않는 버그 수정
b824978
잘못된 query 주석 수정
fba540b
[TEST] LoginDto test 작성
f0a478d
[TEST] SignupRequestDto 테스트 작성
2208aed
[Test] UserServiceTest 작성
a434685
[TEST] FollowService Test 코드 추가
21df289
[TEST] FollowGroupService 테스트 추가
9a18155
[DOMAIN] @Valid 적용
1320403
Valid 에러 발생 시 클라이언트로 파싱하여 반환하도록 추가
c5da0fd
[TEST] 도메인 누락된 테스트 추가
a38e1ce
[domain] 팔로워/팔로잉 불러오기 기능 및 테스트 코드 추가
2de0fb9
테스트코드 보완 적용
048223b
불필요한 입력값 없도록 오버로딩 함수 추가
1deb6a7
Update README.md
gru3530 cd409bf
회원가입 시 글자수 제한 추가
54b1608
Merge branch 'main' into feature/enterTestCode
gru3530 1eeb1c4
Github Action 적용
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
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
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
20 changes: 6 additions & 14 deletions
20
src/main/java/com/flab/stargram/entity/dto/FollowRequestDto.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 |
---|---|---|
@@ -1,21 +1,13 @@ | ||
package com.flab.stargram.entity.dto; | ||
|
||
import com.flab.stargram.entity.common.ApiResponseEnum; | ||
import com.flab.stargram.entity.common.BaseDto; | ||
import com.flab.stargram.entity.common.ValidationResult; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import jakarta.validation.constraints.Pattern; | ||
import jakarta.validation.constraints.Positive; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class FollowRequestDto extends BaseDto { | ||
public class FollowRequestDto { | ||
@NotNull(message = "팔로우할 사용자 ID는 필수 입니다.") | ||
@Positive(message = "사용자 ID는 양수로 입력해야 합니다.") | ||
private Long followingId; | ||
|
||
@Override | ||
public ValidationResult validateEmpty() { | ||
if (isFieldEmpty(followingId)) { | ||
validationResult.addError(ApiResponseEnum.EMPTY_FOLLOWING_ID); | ||
} | ||
|
||
return validationResult; | ||
} | ||
} |
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
61 changes: 61 additions & 0 deletions
61
src/test/java/com/flab/stargram/service/FollowServiceTest.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,61 @@ | ||
package com.flab.stargram.service; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import com.flab.stargram.entity.dto.FollowPair; | ||
import com.flab.stargram.entity.model.Follow; | ||
import com.flab.stargram.entity.model.FollowGroup; | ||
import com.flab.stargram.repository.FollowGroupRepository; | ||
import com.flab.stargram.repository.FollowRepository; | ||
|
||
class FollowServiceTest { | ||
@InjectMocks | ||
private FollowService followService; | ||
|
||
@Mock | ||
private UserService userService; | ||
@Mock | ||
private FollowGroupService followGroupService; | ||
@Mock | ||
private FollowRepository followRepository; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
MockitoAnnotations.openMocks(this); | ||
} | ||
|
||
@Test | ||
void followUser() { | ||
//given | ||
FollowPair followPair = FollowPair.builder() | ||
.followingId(1L) | ||
.followerId(2L) | ||
.build(); | ||
|
||
//when | ||
when(userService.hasUserId(followPair.getFollowerId())).thenReturn(true); | ||
when(userService.hasUserId(followPair.getFollowingId())).thenReturn(true); | ||
when(followGroupService.getOrCreateFollowGroup(followPair.getFollowingId())).thenReturn(mock(FollowGroup.class)); | ||
when(followRepository.existsByFollowerIdAndFollowingId(followPair.getFollowerId(), followPair.getFollowingId())).thenReturn(false); | ||
|
||
followService.followUser(followPair); | ||
|
||
//then | ||
verify(followRepository, times(1)).save(any(Follow.class)); | ||
} | ||
|
||
@Test | ||
void unfollowUser() { | ||
} | ||
|
||
@Test | ||
void getFollowers() { | ||
} | ||
} |
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.