From c96aefd054d45f666c8922c2027589161c52eaad Mon Sep 17 00:00:00 2001 From: BGuga Date: Mon, 23 Oct 2023 16:24:37 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=EB=AC=B8=EC=84=9C=ED=99=94=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/documentation/adoc/quiz.adoc | 14 +++++- .../prolog/docu/QuizDocumentation.java | 46 ++++++++++++++++++- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/backend/src/documentation/adoc/quiz.adoc b/backend/src/documentation/adoc/quiz.adoc index 335881caf..085234723 100644 --- a/backend/src/documentation/adoc/quiz.adoc +++ b/backend/src/documentation/adoc/quiz.adoc @@ -25,11 +25,21 @@ include::{snippets}/quiz/detail/http-response.adoc[] ==== Request -include::{snippets}/quiz/list/http-request.adoc[] +include::{snippets}/quiz/list-keyword/http-request.adoc[] ==== Response -include::{snippets}/quiz/list/http-response.adoc[] +include::{snippets}/quiz/list-keyword/http-response.adoc[] + +=== 커리큘럼별 퀴즈 목록 조회 + +==== Request + +include::{snippets}/quiz/list-curriculum/http-request.adoc[] + +==== Response + +include::{snippets}/quiz/list-curriculum/http-response.adoc[] === 퀴즈 삭제 diff --git a/backend/src/documentation/java/wooteco/prolog/docu/QuizDocumentation.java b/backend/src/documentation/java/wooteco/prolog/docu/QuizDocumentation.java index 45bfeee7c..e6d3a81ec 100644 --- a/backend/src/documentation/java/wooteco/prolog/docu/QuizDocumentation.java +++ b/backend/src/documentation/java/wooteco/prolog/docu/QuizDocumentation.java @@ -2,17 +2,24 @@ import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import java.util.Arrays; +import java.util.List; import org.junit.jupiter.api.Test; +import org.mockito.BDDMockito; +import org.mockito.Mockito; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpStatus; import wooteco.prolog.NewDocumentation; import wooteco.prolog.roadmap.application.QuizService; +import wooteco.prolog.roadmap.application.dto.CurriculumQuizResponse; import wooteco.prolog.roadmap.application.dto.QuizRequest; import wooteco.prolog.roadmap.application.dto.QuizResponse; import wooteco.prolog.roadmap.application.dto.QuizzesResponse; @@ -61,10 +68,47 @@ public class QuizDocumentation extends NewDocumentation { given .when().get("/sessions/{sessionId}/keywords/{keywordId}/quizs", 1L, 1L) - .then().log().all().apply(document("quiz/list")) + .then().log().all().apply(document("quiz/list-keyword")) .statusCode(HttpStatus.OK.value()); } + @Test + void Curriculum별_Quiz_조회() { + given(quizService.findQuizzesByCurriculumId(anyLong())) + .willReturn(makeMockResponse()); + + given + .when().get("/curriculums/{curriculumId}/quizzes", 1L) + .then().log().all().apply(document("quiz/list-curriculum")) + .statusCode(HttpStatus.OK.value()); + } + + private List makeMockResponse() { + CurriculumQuizResponse response1 = new CurriculumQuizResponse() { + @Override + public Long getId() { + return 1L; + } + + @Override + public String getQuestion() { + return "question1"; + } + }; + CurriculumQuizResponse response2 = new CurriculumQuizResponse() { + @Override + public Long getId() { + return 2L; + } + + @Override + public String getQuestion() { + return "question2"; + } + }; + return Arrays.asList(response1, response2); + } + @Test void 퀴즈_수정() { doNothing().when(quizService).updateQuiz(any(), any());