-
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
[Docs] 마이페이지 API REST Docs 작성 #107
Conversation
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.
고생하셨습니다. 리뷰 확인 부탁 드립니다!
public class RatingControllerDocsTest extends RestDocsSupport { | ||
|
||
private final RatingService ratingService = mock(RatingService.class); | ||
|
||
@Override | ||
protected Object initController() { | ||
return new RatingController(ratingService); | ||
} | ||
|
||
@DisplayName("별점 생성 API") | ||
@Test | ||
void createRating() throws Exception { | ||
RatingCreateRequest request = RatingCreateRequest.builder() | ||
.bookIsbn("00000001") | ||
.rating("3.5") | ||
.build(); | ||
|
||
mockMvc.perform( | ||
post("/v1/ratings") | ||
.content(objectMapper.writeValueAsString(request)) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
) | ||
.andDo(print()) | ||
.andExpect(status().isOk()) | ||
.andDo(document("rating/create", | ||
preprocessRequest(prettyPrint()), | ||
preprocessResponse(prettyPrint()), | ||
requestFields( | ||
fieldWithPath("bookIsbn").type(JsonFieldType.STRING) | ||
.description("책 isbn"), | ||
fieldWithPath("rating").type(JsonFieldType.STRING) | ||
.description("별점") | ||
), | ||
responseFields( | ||
fieldWithPath("code").type(JsonFieldType.NUMBER) | ||
.description("코드"), | ||
fieldWithPath("status").type(JsonFieldType.STRING) | ||
.description("상태"), | ||
fieldWithPath("message").type(JsonFieldType.STRING) | ||
.description("메시지"), | ||
fieldWithPath("data").type(JsonFieldType.NULL) | ||
.description("return data null") | ||
) | ||
)); | ||
} | ||
|
||
@DisplayName("별점 삭제 API") | ||
@Test | ||
void deleteRating() throws Exception { | ||
mockMvc.perform( | ||
delete("/v1/ratings/{ratingId}", 1) | ||
.contentType(MediaType.APPLICATION_JSON) | ||
) | ||
.andDo(print()) | ||
.andExpect(status().isOk()) | ||
.andDo(document("rating/delete", | ||
preprocessRequest(prettyPrint()), | ||
preprocessResponse(prettyPrint()), | ||
pathParameters( | ||
parameterWithName("ratingId") | ||
.description("별점 ID") | ||
), | ||
responseFields( | ||
fieldWithPath("code").type(JsonFieldType.NUMBER) | ||
.description("코드"), | ||
fieldWithPath("status").type(JsonFieldType.STRING) | ||
.description("상태"), | ||
fieldWithPath("message").type(JsonFieldType.STRING) | ||
.description("메시지"), | ||
fieldWithPath("data").type(JsonFieldType.NULL) | ||
.description("return data null") | ||
) | ||
)); | ||
} |
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.
RatingControllerDocsTest
에 @PatchMapping
테스트가 누락된 거 같습니다!
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.
넵 반영했습니다 !
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.
고생하셨습니다!
정우님이 말씀하신 REST Docs 테스트만 수정하시면 될거같습니다!
💡 연관된 이슈
close #101
📝 작업 내용
해당 API 추가하고 REST Docs도 작성했습니다.
💬 리뷰 요구 사항
궁금한 점 있으시면 코멘트 남겨주세요 !