@@ -64,6 +64,9 @@ class RoomServiceTest {
6464
6565 @ Mock
6666 private RoomThumbnailService roomThumbnailService ;
67+
68+ @ Mock
69+ private org .springframework .messaging .simp .SimpMessagingTemplate messagingTemplate ;
6770
6871 @ InjectMocks
6972 private RoomService roomService ;
@@ -400,13 +403,15 @@ void kickMember_Success() {
400403 given (roomMemberRepository .findByRoomIdAndUserId (1L , 1L )).willReturn (Optional .of (hostMember ));
401404 given (roomParticipantService .getParticipants (1L )).willReturn (java .util .Set .of (2L )); // 온라인 사용자 목록
402405 given (roomMemberRepository .findByRoomIdAndUserId (1L , 2L )).willReturn (Optional .empty ()); // VISITOR는 DB에 없음
403- given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom ));
406+ given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom )); // Room 조회 추가
404407
405408 // when
406409 roomService .kickMember (1L , 2L , 1L );
407410
408411 // then
409412 verify (roomParticipantService , times (1 )).exitRoom (2L , 1L ); // Redis 퇴장 확인
413+ verify (messagingTemplate , times (1 )).convertAndSendToUser (eq ("2" ), eq ("/queue/kick" ), any ()); // WebSocket 메시지 전송 확인
414+ verify (eventPublisher , times (1 )).publishEvent (any (com .back .domain .notification .event .studyroom .MemberKickedEvent .class )); // 이벤트 발행 확인
410415 }
411416
412417 @ Test
@@ -418,13 +423,15 @@ void kickMember_VisitorSuccess() {
418423 given (roomMemberRepository .findByRoomIdAndUserId (1L , 1L )).willReturn (Optional .of (hostMember ));
419424 given (roomParticipantService .getParticipants (1L )).willReturn (java .util .Set .of (2L )); // VISITOR가 온라인 상태
420425 given (roomMemberRepository .findByRoomIdAndUserId (1L , 2L )).willReturn (Optional .empty ()); // DB에 없음
421- given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom ));
426+ given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom )); // Room 조회 추가
422427
423428 // when
424429 roomService .kickMember (1L , 2L , 1L );
425430
426431 // then
427432 verify (roomParticipantService , times (1 )).exitRoom (2L , 1L );
433+ verify (messagingTemplate , times (1 )).convertAndSendToUser (eq ("2" ), eq ("/queue/kick" ), any ()); // WebSocket 메시지 전송 확인
434+ verify (eventPublisher , times (1 )).publishEvent (any (com .back .domain .notification .event .studyroom .MemberKickedEvent .class )); // 이벤트 발행 확인
428435 }
429436
430437 @ Test
@@ -448,13 +455,15 @@ void kickMember_MemberSuccess() {
448455 given (roomMemberRepository .findByRoomIdAndUserId (1L , 1L )).willReturn (Optional .of (hostMember ));
449456 given (roomParticipantService .getParticipants (1L )).willReturn (java .util .Set .of (2L )); // MEMBER가 온라인 상태
450457 given (roomMemberRepository .findByRoomIdAndUserId (1L , 2L )).willReturn (Optional .of (targetMember )); // DB에 있음
451- given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom ));
458+ given (roomRepository .findById (1L )).willReturn (Optional .of (testRoom )); // Room 조회 추가
452459
453460 // when
454461 roomService .kickMember (1L , 2L , 1L );
455462
456463 // then
457464 verify (roomParticipantService , times (1 )).exitRoom (2L , 1L );
465+ verify (messagingTemplate , times (1 )).convertAndSendToUser (eq ("2" ), eq ("/queue/kick" ), any ()); // WebSocket 메시지 전송 확인
466+ verify (eventPublisher , times (1 )).publishEvent (any (com .back .domain .notification .event .studyroom .MemberKickedEvent .class )); // 이벤트 발행 확인
458467 }
459468
460469 @ Test
0 commit comments