Skip to content

Commit

Permalink
[test] : 답변채택 쿼리 개수 개선 v2 통합테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
dudxo committed Nov 21, 2024
1 parent ee91d72 commit 18b9c6e
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void chooseAnswer() throws Exception {
= questionPostRepository.save(QuestionPostFixture.questionPost(loginMember));
Member answerer = memberRepository.save(MemberFixture.member2());
Answer answer = answerRepository.save(AnswerFixture.answer(questionPost.getId(), answerer));
long startTime = System.currentTimeMillis();

mockMvc.perform(post("/api/question-posts/answers/{answerId}", answer.getId())
.cookie(accessToken)
Expand All @@ -137,5 +138,31 @@ void chooseAnswer() throws Exception {
.andExpect(jsonPath("$.memberInfo.nickname").value(answerer.getNickname()))
.andExpect(jsonPath("$.memberInfo.memberJobGroup").value(answerer.getJobGroup().getLabel())
);
long endTime = System.currentTimeMillis();
System.out.println("Execution time: " + (endTime - startTime) + " ms");
}

@DisplayName("[질문자는 답변을 채택할 수 있다.V2]")
@Test
void chooseAnswerV2() throws Exception {
QuestionPost questionPost
= questionPostRepository.save(QuestionPostFixture.questionPost(loginMember));
Member answerer = memberRepository.save(MemberFixture.member2());
Answer answer = answerRepository.save(AnswerFixture.answer(questionPost.getId(), answerer));
long startTime = System.currentTimeMillis();

mockMvc.perform(post("/api/v2/question-posts/answers/{answerId}", answer.getId())
.cookie(accessToken)
)
.andExpect(status().isOk())
.andExpect(jsonPath("$.content").value(answer.getContent()))
.andExpect(jsonPath("$.isChosen").value(true))
.andExpect(jsonPath("$.isQuestioner").value(false))
.andExpect(jsonPath("$.memberInfo.memberId").value(answerer.getId()))
.andExpect(jsonPath("$.memberInfo.nickname").value(answerer.getNickname()))
.andExpect(jsonPath("$.memberInfo.memberJobGroup").value(answerer.getJobGroup().getLabel())
);
long endTime = System.currentTimeMillis();
System.out.println("Execution time: " + (endTime - startTime) + " ms");
}
}

0 comments on commit 18b9c6e

Please sign in to comment.