-
Notifications
You must be signed in to change notification settings - Fork 1
[REFACTOR] 리뷰 생성 및 컨트롤러 테스트 리팩토링 #254
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
92e7c0d
refactor(review): review 생성 리팩토링
leebs0521 a56f303
test(review): review 생성 리팩토링에 따른 테스트
leebs0521 6944983
refactor(exception): 유효성 검사 실패시 해당 메세지 출력하도록 변경
leebs0521 18cd3d8
test(exception): 유효성 검사 실패시 해당 메세지 출력하도록 변경에 따른 테스트
leebs0521 c1bf380
refactor(controller-test): ControllerTestSupport 리팩토링
leebs0521 d279bb3
test(controller-test): ControllerTestSupport 리팩토링에 따른 테스트
leebs0521 94719de
test(volunteer-apply): 누락된 테스트 추가
leebs0521 e00f475
test(controller-test): print() 제거
leebs0521 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 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
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
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 |
|---|---|---|
| @@ -1,25 +1,25 @@ | ||
| package com.somemore.domains.center.controller; | ||
|
|
||
| import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_CENTER; | ||
| import static org.mockito.Mockito.times; | ||
| import static org.mockito.Mockito.verify; | ||
| import static org.mockito.Mockito.when; | ||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
| import com.somemore.domains.center.dto.response.CenterProfileResponseDto; | ||
| import com.somemore.domains.center.usecase.query.CenterQueryUseCase; | ||
| import com.somemore.global.exception.BadRequestException; | ||
| import com.somemore.support.ControllerTestSupport; | ||
| import java.util.List; | ||
| import java.util.UUID; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.DisplayName; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.springframework.boot.test.mock.mockito.MockBean; | ||
| import org.springframework.http.MediaType; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_CENTER; | ||
| import static org.mockito.Mockito.*; | ||
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; | ||
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; | ||
|
|
||
| class CenterQueryApiControllerTest extends ControllerTestSupport { | ||
|
|
||
| @MockBean | ||
|
|
@@ -53,16 +53,18 @@ void getCenterProfile() throws Exception { | |
| get("/api/center/profile/{centerId}", centerId) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| ) | ||
| .andDo(print()) | ||
| .andExpect(status().isOk()) | ||
| .andExpect(jsonPath("$.code").value("200")) | ||
| .andExpect(jsonPath("$.message").value("기관 프로필 조회 성공")) | ||
| .andExpect(jsonPath("$.data.center_id").value(centerId.toString())) // center_id로 수정 | ||
| .andExpect(jsonPath("$.data.name").value("Test Center")) | ||
| .andExpect(jsonPath("$.data.contact_number").value("010-1234-5678")) // contact_number로 수정 | ||
| .andExpect(jsonPath("$.data.img_url").value("http://example.com/image.jpg")) // img_url로 수정 | ||
| .andExpect(jsonPath("$.data.contact_number").value( | ||
| "010-1234-5678")) // contact_number로 수정 | ||
| .andExpect(jsonPath("$.data.img_url").value( | ||
| "http://example.com/image.jpg")) // img_url로 수정 | ||
| .andExpect(jsonPath("$.data.introduce").value("This is a test center.")) | ||
| .andExpect(jsonPath("$.data.homepage_link").value("http://example.com")) // homepage_link로 수정 | ||
| .andExpect(jsonPath("$.data.homepage_link").value( | ||
| "http://example.com")) // homepage_link로 수정 | ||
| .andExpect(jsonPath("$.data.prefer_items").isArray()); // prefer_items로 수정 | ||
|
Comment on lines
59
to
68
Collaborator
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. 주석의미를 여쭤보고 싶습니다~
Collaborator
Author
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. 이거 기존 코드라 제가 작성한 부분이 아니에요 |
||
|
|
||
| verify(centerQueryUseCase, times(1)).getCenterProfileByCenterId(centerId); | ||
|
|
@@ -81,7 +83,6 @@ void getCenterProfile_NotFound() throws Exception { | |
| get("/api/center/profile/{centerId}", nonExistentCenterId) | ||
| .contentType(MediaType.APPLICATION_JSON) | ||
| ) | ||
| .andDo(print()) | ||
| .andExpect(status().isBadRequest()) | ||
| .andExpect(jsonPath("$.status").value("400")) | ||
| .andExpect(jsonPath("$.detail").value("존재하지 않는 기관입니다.")); | ||
|
|
||
19 changes: 9 additions & 10 deletions
19
src/test/java/com/somemore/domains/center/controller/PreferItemCommandApiControllerTest.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
Oops, something went wrong.
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.
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.
조회에 사용되는 쿼리 같은데 Review의 모든 컬럼이 필요한건지 여쭤보고 싶습니다
만약 아니라면 필요한 컬럼만 추출해서 응답시간 단축, 자원 절약을 시도해보는게 어떨까요
쿼리 최적화를 위한 6가지팁
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.
모두 필요합니다 리스트 조회에 대한 거라 필요합니다.