From 6107af5a0ecdd7567504d035cae5d43002d8c83a Mon Sep 17 00:00:00 2001 From: hs12 <loveanna1228@gmail.com> Date: Fri, 22 Nov 2024 15:50:53 +0900 Subject: [PATCH] =?UTF-8?q?[test]=20:=20=EC=B1=84=ED=8C=85=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=20API=20?= =?UTF-8?q?=EB=A9=94=EC=84=9C=EB=93=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ChatInquiryControllerTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java b/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java index 992bffe2..4b3e0c88 100644 --- a/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java +++ b/src/test/java/com/dnd/gongmuin/chat_inquiry/controller/ChatInquiryControllerTest.java @@ -57,6 +57,7 @@ void teardown() { creditHistoryRepository.deleteAll(); memberRepository.deleteAll(); questionPostRepository.deleteAll(); + chatInquiryRepository.deleteAll(); chatRoomRepository.deleteAll(); chatMessageRepository.deleteAll(); } @@ -82,6 +83,32 @@ void createChatInquiry() throws Exception { .andDo(MockMvcResultHandlers.print()); } + @DisplayName("[채팅 요청 아이디로 상세 채팅 요청을 조회할 수 있다.]") + @Test + void getChatInquiryById() throws Exception { + //given + Member chatPartner = memberRepository.save(MemberFixture.member5()); + QuestionPost questionPost = questionPostRepository.save(QuestionPostFixture.questionPost(loginMember)); + ChatInquiry chatInquiry = chatInquiryRepository.save( + ChatInquiryFixture.chatInquiry(questionPost, loginMember, chatPartner, INQUIRY_MESSAGE) + ); + + //when & then + mockMvc.perform(get("/api/chat/inquiries/{chatInquiryId}", chatInquiry.getId()) + .cookie(accessToken)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.chatInquiryId") + .value(chatInquiry.getId())) + .andExpect(jsonPath("$.inquiryStatus") + .value(InquiryStatus.PENDING.getLabel())) + .andExpect(jsonPath("$.chatPartner.memberId") + .value(chatPartner.getId())) + .andExpect(jsonPath("$.isInquirer") + .value(chatInquiry.getInquirer().equals(loginMember))) + .andExpect(jsonPath("$.inquiryStatus") + .value(InquiryStatus.PENDING.getLabel())); + } + @DisplayName("[회원의 채팅 요청 목록을 조회할 수 있다.]") @Test void getChatInquiresByMember() throws Exception {