Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion questions-server/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,4 @@ operation::bookmarked-questions[snippets='request-headers,query-parameters,http-

사용자가 북마크한 문제 번호 목록을 조회합니다.

operation::check-bookmark[snippets='request-headers,query-parameters,http-request,http-response,response-fields']
operation::check-bookmark[snippets='request-headers,http-request,http-response,response-fields']
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,6 @@ public ResponseEntity<ResponseStatus> createBookmark(@RequestHeader("Authorizati
}


@DeleteMapping("/book-mark")
public ResponseEntity<ResponseStatus> deleteBookMark(@RequestHeader("Authorization") String authHeader,
@RequestParam Long questionId) {
String username = jwtUtils.extractUsername(authHeader);
userQuestionService.deleteBookMark(username, questionId);
return ResponseEntity.ok().build();
}

@GetMapping("/book-mark")
public ResponseEntity<List<QuestionInfoDto>> checkBookmarkAndQuestions(@RequestHeader("Authorization") String authHeader) {
String username = jwtUtils.extractUsername(authHeader);
Expand All @@ -129,6 +121,14 @@ public ResponseEntity<List<QuestionDto>> getBookMarkQuestions(@RequestHeader("Au
return ResponseEntity.ok(userQuestionService.getBookMarkQuestion(username, certificationId));
}

@DeleteMapping("/book-mark")
public ResponseEntity<ResponseStatus> deleteBookMark(@RequestHeader("Authorization") String authHeader,
@RequestParam Long questionId) {
String username = jwtUtils.extractUsername(authHeader);
userQuestionService.deleteBookMark(username, questionId);
return ResponseEntity.ok().build();
}




Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

@ExtendWith({RestDocumentationExtension.class, SpringExtension.class})
@WebMvcTest(controllers = ExamController.class, excludeAutoConfiguration = {
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration.class
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.servlet.SecurityFilterAutoConfiguration.class,
org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration.class
})
@AutoConfigureRestDocs
class BasicExamControllerTest {
Expand All @@ -52,10 +52,10 @@ class BasicExamControllerTest {

@MockBean
private ExamService examService;

@MockBean
private UserQuestionService userQuestionService;

@MockBean
private JwtUtils jwtUtils;

Expand Down Expand Up @@ -392,18 +392,20 @@ void createBookmark() throws Exception {
doNothing().when(userQuestionService).createBookMark(anyString(), anyLong());

// when & then
mockMvc.perform(post("/exam/book-mark")
mockMvc.perform(post("/exam/book-mark?questionId=1")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.AUTHORIZATION, "Bearer jwt-token-here")
.param("questionId", "1"))
.header(HttpHeaders.AUTHORIZATION, "Bearer jwt-token-here"))
.andDo(print())
.andExpect(status().isOk())
.andDo(document("create-bookmark",
ApiDocumentUtils.getDocumentRequest(),
ApiDocumentUtils.getDocumentResponse(),
requestHeaders(
headerWithName("Authorization").description("JWT 인증 토큰")
),
queryParameters(
parameterWithName("questionId").description("문제 ID")
)
));
}
Expand Down Expand Up @@ -441,9 +443,8 @@ void deleteBookmark() throws Exception {
doNothing().when(userQuestionService).deleteBookMark(anyString(), anyLong());

// when & then
mockMvc.perform(delete("/exam/book-mark")
mockMvc.perform(delete("/exam/book-mark?questionId=1")
.header(HttpHeaders.AUTHORIZATION, "Bearer jwt-token-here")
.param("questionId", "1")
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
.header(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON_VALUE))
.andDo(print())
Expand All @@ -453,6 +454,9 @@ void deleteBookmark() throws Exception {
ApiDocumentUtils.getDocumentResponse(),
requestHeaders(
headerWithName("Authorization").description("JWT 인증 토큰")
),
queryParameters(
parameterWithName("questionId").description("문제 번호")
)
));
}
Expand Down Expand Up @@ -482,7 +486,10 @@ void getBookmarkQuestions() throws Exception {
requestHeaders(
headerWithName("Authorization").description("JWT 인증 토큰")
),
responseFields(
queryParameters(
parameterWithName("certificationId").description("자격증ID")
)
,responseFields(
fieldWithPath("[].questionId").type(JsonFieldType.NUMBER)
.description("문제 ID"),
fieldWithPath("[].content").type(JsonFieldType.STRING)
Expand All @@ -494,4 +501,6 @@ void getBookmarkQuestions() throws Exception {
)
));
}


}
Loading