-
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
[리팩토링] Post, Service 코드 개선 및 테스트 코드 추가 #129
Open
tape22
wants to merge
9
commits into
develop
Choose a base branch
from
feature/test2
base: develop
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 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
27d1153
Test : 댓글 Service 테스트 코드 작성중
ybell1028 899be5d
Test : 댓글 Service 테스트 코드 작성완료
ybell1028 b92fe48
Add : DBUnit 설정 추가
ybell1028 24772fd
Test : UserRepositoryTest 코드 추가
ybell1028 d9c0211
Fix : userIdx Sequence 초기화 메소드 추가, 테스트 실패 이슈 해결
ybell1028 ad4d613
Test : CommentRepositoryTest 작성
ybell1028 7cb411b
Test : LikeRepositoryTest 작성
ybell1028 08b55ac
Chore: 회고글 목록 조회 시 예외처리 추가
tape22 6cb3aba
Refactor: PostController @CurrentUser로 변경, ResponseEntity 빌더 타입 리팩토링
tape22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
secret: | ||
access: accessTokenSecret |
4 changes: 4 additions & 0 deletions
4
src/test/java/com/yapp18/retrospect/post/PostControllerTest.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,4 @@ | ||
package com.yapp18.retrospect.post; | ||
|
||
public class PostControllerTest { | ||
} |
66 changes: 0 additions & 66 deletions
66
src/test/java/com/yapp18/retrospect/post/PostCrudTest.java
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/test/java/com/yapp18/retrospect/post/PostServiceTest.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,71 @@ | ||
package com.yapp18.retrospect.post; | ||
|
||
import com.yapp18.retrospect.common.EntityCreator; | ||
import com.yapp18.retrospect.domain.post.Post; | ||
import com.yapp18.retrospect.domain.post.PostQueryRepository; | ||
import com.yapp18.retrospect.domain.post.PostRepository; | ||
import com.yapp18.retrospect.domain.template.Template; | ||
import com.yapp18.retrospect.domain.template.TemplateRepository; | ||
import com.yapp18.retrospect.domain.user.Role; | ||
import com.yapp18.retrospect.domain.user.User; | ||
import com.yapp18.retrospect.domain.user.UserRepository; | ||
import com.yapp18.retrospect.security.oauth2.AuthProvider; | ||
import com.yapp18.retrospect.service.PostService; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.data.domain.PageRequest; | ||
|
||
import java.awt.font.OpenType; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
//@DataJpaTest | ||
@ExtendWith(MockitoExtension.class) | ||
public class PostServiceTest { | ||
|
||
@InjectMocks | ||
private PostService postService; | ||
|
||
@Mock | ||
private PostRepository postRepository; | ||
@Mock | ||
private UserRepository userRepository; | ||
@Mock | ||
private TemplateRepository templateRepository; | ||
|
||
@BeforeEach | ||
void setUp(){ | ||
// // user 설정 | ||
// User user1 = User.builder() | ||
// .name("허정민").nickname("tape22").intro("자기소개.").job("백수") | ||
// .email("[email protected]").profile("profile_url") | ||
// .provider(AuthProvider.google).providerId("13453252535").role(Role.MEMBER).build(); | ||
// // template 설정 | ||
// Template template = Template.builder().template("템플릿").templateName("4F").build(); | ||
// | ||
// userRepository.save(user1); | ||
// templateRepository.save(template); | ||
// | ||
// System.out.println(user1.getUserIdx()); | ||
// System.out.println(template.getTemplateIdx()); | ||
} | ||
|
||
@Test | ||
void 회고글이_없는_경우(){ | ||
// list로 글 읽어오기 | ||
List<Post> posts = postRepository.findAllByOrderByViewDesc(PageRequest.of(0,10)); | ||
System.out.println(posts); | ||
|
||
// when | ||
|
||
// 없으면 빈 배열? 아니면 exception? | ||
|
||
} | ||
} |
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.
회고글 존재하지 않을 땐 예외 날리는 것보단 빈 배열 200으로 응답하는게 낫지 않을까?
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.
그 두 개 방법이랑 고민해봤는데
등등의 이유로 일단 exception 처리는 해놨는데, ApiPagingResult가 Controller 쪽으로 빼서 변환하기 어렵더라구 함 다시 시도해볼게!
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.
CommentController.getCommentsByPostIdx 한번 보는거 추천~