diff --git a/src/test/java/toy/bookchat/bookchat/domain/chatroom/api/ChatRoomControllerTest.java b/src/test/java/toy/bookchat/bookchat/domain/chatroom/api/ChatRoomControllerTest.java index 94cf6a10..8b0cb445 100644 --- a/src/test/java/toy/bookchat/bookchat/domain/chatroom/api/ChatRoomControllerTest.java +++ b/src/test/java/toy/bookchat/bookchat/domain/chatroom/api/ChatRoomControllerTest.java @@ -253,7 +253,9 @@ class ChatRoomControllerTest extends ControllerTestExtension { fieldWithPath("userChatRoomResponseList[].senderDefaultProfileImageType").type(NUMBER).description("마지막 채팅 보낸 사람 기본 프로필 이미지 타입"), fieldWithPath("userChatRoomResponseList[].lastChatId").type(NUMBER).description("마지막 채팅 ID"), fieldWithPath("userChatRoomResponseList[].lastChatContent").type(STRING).description("마지막 채팅 내용"), - fieldWithPath("userChatRoomResponseList[].lastChatDispatchTime").type(STRING).description("마지막 채팅 발송 시간") + fieldWithPath("userChatRoomResponseList[].lastChatDispatchTime").type(STRING).description("마지막 채팅 발송 시간"), + fieldWithPath("userChatRoomResponseList[].isBanned").type(BOOLEAN).description("사용자가 차단된 채팅방인지 여부"), + fieldWithPath("userChatRoomResponseList[].isExploded").type(BOOLEAN).description("채팅방 폭파 여부") ).and(getCursorField()))); } @@ -595,6 +597,8 @@ private UserChatRoomResponse getChatRoomResponse(ChatRoom chatRoom, Chat chat) { .lastChatId(chat.getId()) .lastChatContent(chat.getMessage()) .lastChatDispatchTime(LocalDateTime.now()) + .isExploded(false) + .isBanned(false) .build(); } } \ No newline at end of file diff --git a/src/test/java/toy/bookchat/bookchat/domain/chatroom/repository/ChatRoomRepositoryTest.java b/src/test/java/toy/bookchat/bookchat/domain/chatroom/repository/ChatRoomRepositoryTest.java index 7ddcb839..4cb84c82 100644 --- a/src/test/java/toy/bookchat/bookchat/domain/chatroom/repository/ChatRoomRepositoryTest.java +++ b/src/test/java/toy/bookchat/bookchat/domain/chatroom/repository/ChatRoomRepositoryTest.java @@ -102,6 +102,7 @@ class ChatRoomRepositoryTest { .roomSid("IwZrRxR5") .roomSize(110) .defaultRoomImageType(2) + .isDeleted(true) .build(); ChatRoom chatRoom3 = ChatRoom.builder() .book(book1) @@ -114,6 +115,12 @@ class ChatRoomRepositoryTest { chatRoomRepository.save(chatRoom2); chatRoomRepository.save(chatRoom3); + ChatRoomBlockedUser chatRoomBlockedUser = ChatRoomBlockedUser.builder() + .user(user1) + .chatRoom(chatRoom3) + .build(); + chatRoomBlockedUserRepository.save(chatRoomBlockedUser); + Participant participant1 = Participant.builder().user(user1).chatRoom(chatRoom1) .participantStatus(HOST).build(); Participant participant2 = Participant.builder().user(user1).chatRoom(chatRoom2) @@ -167,6 +174,8 @@ class ChatRoomRepositoryTest { .lastChatId(chat4.getId()) .lastChatContent(chat4.getMessage()) .lastChatDispatchTime(chat4.getCreatedAt()) + .isBanned(true) + .isExploded(false) .build(); UserChatRoomResponse userChatRoomResponse2 = UserChatRoomResponse.builder() @@ -184,14 +193,16 @@ class ChatRoomRepositoryTest { .lastChatId(chat2.getId()) .lastChatContent(chat2.getMessage()) .lastChatDispatchTime(chat2.getCreatedAt()) + .isBanned(false) + .isExploded(true) .build(); PageRequest pageRequest = PageRequest.of(0, 2, Sort.by("id").descending()); List contents = List.of(userChatRoomResponse1, userChatRoomResponse2); Slice result = toSlice(contents, pageRequest); - Slice slice = chatRoomRepository.findUserChatRoomsWithLastChat( - pageRequest, null, null, user1.getId()); + Slice slice = chatRoomRepository.findUserChatRoomsWithLastChat(pageRequest, null, null, user1.getId()); + assertThat(slice.getContent()).usingRecursiveComparison() .ignoringFieldsOfTypes(LocalDateTime.class) .isEqualTo(result.getContent()); @@ -219,6 +230,7 @@ class ChatRoomRepositoryTest { .roomSid("4SyVX") .roomSize(77) .defaultRoomImageType(1) + .isDeleted(true) .build(); ChatRoom chatRoom2 = ChatRoom.builder() .book(book2) @@ -236,6 +248,12 @@ class ChatRoomRepositoryTest { .build(); chatRoomRepository.saveAll(List.of(chatRoom1, chatRoom2, chatRoom3)); + ChatRoomBlockedUser chatRoomBlockedUser = ChatRoomBlockedUser.builder() + .chatRoom(chatRoom1) + .user(user1) + .build(); + chatRoomBlockedUserRepository.save(chatRoomBlockedUser); + Participant participant1 = Participant.builder().user(user1).chatRoom(chatRoom1) .participantStatus(HOST).build(); Participant participant2 = Participant.builder().user(user1).chatRoom(chatRoom2) @@ -251,6 +269,8 @@ class ChatRoomRepositoryTest { .roomSid(chatRoom1.getRoomSid()) .defaultRoomImageType(chatRoom1.getDefaultRoomImageType()) .roomMemberCount(1L) + .isExploded(true) + .isBanned(true) .build(); PageRequest pageRequest = PageRequest.of(0, 2, Sort.by("id").ascending()); diff --git a/src/test/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomServiceTest.java b/src/test/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomServiceTest.java index 21bbe5f5..56e5bd9d 100644 --- a/src/test/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomServiceTest.java +++ b/src/test/java/toy/bookchat/bookchat/domain/chatroom/service/ChatRoomServiceTest.java @@ -200,18 +200,16 @@ private static CreateChatRoomRequest getCreateChatRoomRequest(BookRequest bookRe .roomName(chatRoom1.getRoomName()) .roomMemberCount(1L) .defaultRoomImageType(chatRoom1.getDefaultRoomImageType()) + .isBanned(false) + .isExploded(false) .build(); List result = List.of(userChatRoomResponse); PageRequest pageRequest = PageRequest.of(0, 1, Sort.by("id").descending()); Slice slice = new SliceImpl<>(result, pageRequest, true); - when(chatRoomRepository.findUserChatRoomsWithLastChat(any(), any(), any(), - any())).thenReturn( - slice); - UserChatRoomsResponseSlice userChatRoomsResponseSlice = chatRoomService.getUserChatRooms( - any(), any(), any(), any()); - - assertThat(userChatRoomsResponseSlice).usingRecursiveComparison() - .isEqualTo(UserChatRoomsResponseSlice.of(slice)); + when(chatRoomRepository.findUserChatRoomsWithLastChat(any(), any(), any(), any())).thenReturn(slice); + UserChatRoomsResponseSlice userChatRoomsResponseSlice = chatRoomService.getUserChatRooms(any(), any(), any(), any()); + + assertThat(userChatRoomsResponseSlice).usingRecursiveComparison().isEqualTo(UserChatRoomsResponseSlice.of(slice)); } @Test