Skip to content

Commit

Permalink
docs : API 분리로 인한 Docs 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
1000kkannoo committed Aug 22, 2023
1 parent 3a5681b commit 573dedd
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 51 deletions.
21 changes: 16 additions & 5 deletions src/docs/asciidoc/api/lecture/lecture.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,24 @@ include::{snippets}/get-lecture-reviews/path-parameters.adoc[]
include::{snippets}/get-lecture-reviews/http-response.adoc[]
include::{snippets}/get-lecture-reviews/response-fields.adoc[]

=== (Scope it) 별점 높은 수강 후기들 & 강의력 좋은 강의 조회 API
=== 별점 높은 수강 후기들 조회 API

==== HTTP Request Headers
include::{snippets}/scope-main/request-headers.adoc[]
include::{snippets}/scope-main/http-request.adoc[]
include::{snippets}/scope-review-score/request-headers.adoc[]
include::{snippets}/scope-review-score/http-request.adoc[]

==== HTTP Response body
include::{snippets}/scope-main/http-response.adoc[]
include::{snippets}/scope-main/response-fields.adoc[]
include::{snippets}/scope-review-score/http-response.adoc[]
include::{snippets}/scope-review-score/response-fields.adoc[]


=== 강의력 좋은 강의 조회 API

==== HTTP Request Headers
include::{snippets}/scope-review-lecture/request-headers.adoc[]
include::{snippets}/scope-review-lecture/http-request.adoc[]

==== HTTP Response body
include::{snippets}/scope-review-lecture/http-response.adoc[]
include::{snippets}/scope-review-lecture/response-fields.adoc[]

105 changes: 59 additions & 46 deletions src/test/java/dnd/project/docs/lecture/LectureControllerDocsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import dnd.project.domain.lecture.response.LectureScopeListReadResponse;
import dnd.project.domain.lecture.service.LectureService;
import dnd.project.domain.review.entity.ReviewTag;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders;
import org.springframework.restdocs.payload.JsonFieldType;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

import java.time.LocalDateTime;
import java.util.ArrayList;
Expand Down Expand Up @@ -327,9 +325,9 @@ void getLectureReviews() throws Exception {
.description("후기 추천수"))));
}

@DisplayName("scope 페이지 추천 강의 조회 API")
@DisplayName("별점 높은 수강 후기들 API")
@Test
void getScopeLectures() throws Exception {
void getScopeReviewsScore() throws Exception {
// given
// 후기 높은 리뷰 생성
LectureScopeListReadResponse.DetailReview detailReview1 = new LectureScopeListReadResponse.DetailReview(
Expand All @@ -350,6 +348,53 @@ void getScopeLectures() throws Exception {
List<LectureScopeListReadResponse.DetailReview> highScoreReviews =
List.of(detailReview1, detailReview2, detailReview3);

given(lectureService.getScopeReviewsScore(any()))
.willReturn(highScoreReviews);

// when // then
mockMvc.perform(
RestDocumentationRequestBuilders.get("/lectures/scope/reviews")
.header("Authorization", "Bearer AccessToken")
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document("scope-review-score",
preprocessResponse(prettyPrint()),
requestHeaders(
headerWithName("Authorization")
.description("발급된 JWT AccessToken / NULL 허용")
),
responseFields(
fieldWithPath("code").type(NUMBER)
.description("상태 코드"),
fieldWithPath("message").type(STRING)
.description("상태 메세지"),
fieldWithPath("data[]").type(ARRAY)
.description("별점 높은 수강 후기 리스트"),
fieldWithPath("data[].id").type(NUMBER)
.description("후기 ID"),
fieldWithPath("data[].lectureTitle").type(STRING)
.description("강의 제목"),
fieldWithPath("data[].imageUrl").type(STRING)
.description("유저 프로필 이미지 URL"),
fieldWithPath("data[].userName").type(STRING)
.description("유저 이름"),
fieldWithPath("data[].createdDate").type(STRING)
.description("후기 작성 날짜"),
fieldWithPath("data[].score").type(NUMBER)
.description("후기 점수"),
fieldWithPath("data[].content").type(STRING)
.description("후기 내용"),
fieldWithPath("data[].tags").type(STRING)
.description("후기 태그")
)
));
}

@DisplayName("강의력 좋은 강의 조회 API")
@Test
void getScopeLecturesBest() throws Exception {
// given
// 추천 강의 생성
LectureScopeListReadResponse.DetailLecture detailLecture1 = new LectureScopeListReadResponse.DetailLecture(
1L, "coloso", "https://fastcampus.co.kr/dev_online_linux", "리눅스 실전 정복 올인원 패키지 Online.", "박수현,원규연"
Expand All @@ -365,25 +410,17 @@ void getScopeLectures() throws Exception {

List<LectureScopeListReadResponse.DetailLecture> bestLectures = List.of(detailLecture1, detailLecture2, detailLecture3);

given(lectureService.getScopeLectures(any()))
.willReturn(
LectureScopeListReadResponse.builder()
.isAnonymous(false)
.userName("클래스코프")
.interests("요리,프로그래밍")
.highScoreReviews(highScoreReviews)
.bestLectures(bestLectures)
.build()
);
given(lectureService.getScopeLecturesBest(any()))
.willReturn(bestLectures);

// when // then
mockMvc.perform(
RestDocumentationRequestBuilders.get("/lectures/scope")
RestDocumentationRequestBuilders.get("/lectures/scope/lectures")
.header("Authorization", "Bearer AccessToken")
)
.andDo(print())
.andExpect(status().isOk())
.andDo(document("scope-main",
.andDo(document("scope-review-lecture",
preprocessResponse(prettyPrint()),
requestHeaders(
headerWithName("Authorization")
Expand All @@ -394,41 +431,17 @@ void getScopeLectures() throws Exception {
.description("상태 코드"),
fieldWithPath("message").type(STRING)
.description("상태 메세지"),
fieldWithPath("data.isAnonymous").type(BOOLEAN)
.description("비로그인 유저 여부"),
fieldWithPath("data.userName").type(STRING)
.description("유저 네임 / 비로그인 값 : 'anonymous'"),
fieldWithPath("data.interests").type(STRING)
.description("유저 관심분야 / 비로그인 값 : 'anonymous'"),
fieldWithPath("data.highScoreReviews[]").type(ARRAY)
.description("별점 높은 수강 후기 리스트"),
fieldWithPath("data.highScoreReviews[].id").type(NUMBER)
.description("후기 ID"),
fieldWithPath("data.highScoreReviews[].lectureTitle").type(STRING)
.description("강의 제목"),
fieldWithPath("data.highScoreReviews[].imageUrl").type(STRING)
.description("유저 프로필 이미지 URL"),
fieldWithPath("data.highScoreReviews[].userName").type(STRING)
.description("유저 이름"),
fieldWithPath("data.highScoreReviews[].createdDate").type(STRING)
.description("후기 작성 날짜"),
fieldWithPath("data.highScoreReviews[].score").type(NUMBER)
.description("후기 점수"),
fieldWithPath("data.highScoreReviews[].content").type(STRING)
.description("후기 내용"),
fieldWithPath("data.highScoreReviews[].tags").type(STRING)
.description("후기 태그"),
fieldWithPath("data.bestLectures[]").type(ARRAY)
fieldWithPath("data[]").type(ARRAY)
.description("강의력 좋은 강의 리스트"),
fieldWithPath("data.bestLectures[].id").type(NUMBER)
fieldWithPath("data[].id").type(NUMBER)
.description("강의 Id"),
fieldWithPath("data.bestLectures[].source").type(STRING)
fieldWithPath("data[].source").type(STRING)
.description("강의 플랫폼"),
fieldWithPath("data.bestLectures[].imageUrl").type(STRING)
fieldWithPath("data[].imageUrl").type(STRING)
.description("강의 이미지 URL"),
fieldWithPath("data.bestLectures[].title").type(STRING)
fieldWithPath("data[].title").type(STRING)
.description("강의 제목"),
fieldWithPath("data.bestLectures[].name").type(STRING)
fieldWithPath("data[].name").type(STRING)
.description("강사 이름")
)
));
Expand Down

0 comments on commit 573dedd

Please sign in to comment.