11package io .crops .warmletter .domain .share .service ;
22import io .crops .warmletter .domain .auth .facade .AuthFacade ;
3+ import io .crops .warmletter .domain .badword .service .BadWordService ;
34import io .crops .warmletter .domain .share .dto .request .ShareProposalRequest ;
45import io .crops .warmletter .domain .share .dto .response .*;
56import io .crops .warmletter .domain .share .entity .SharePost ;
@@ -48,6 +49,9 @@ class ShareProposalServiceTest {
4849 @ Mock
4950 private ApplicationEventPublisher notificationPublisher ;
5051
52+ @ Mock
53+ private BadWordService badWordService ;
54+
5155 @ Mock
5256 private AuthFacade authFacade ;
5357
@@ -73,6 +77,7 @@ void requestShareProposal_Success() {
7377 when (authFacade .getCurrentUserId ()).thenReturn (requesterId );
7478 when (shareProposalRepository .save (any (ShareProposal .class ))).thenReturn (shareProposal );
7579 when (shareProposalRepository .findShareProposalWithZipCode (anyLong ())).thenReturn (expectedResponse );
80+ doNothing ().when (badWordService ).validateText (request .getMessage ());
7681
7782 ShareProposalResponse response = shareProposalService .requestShareProposal (request );
7883
@@ -82,6 +87,7 @@ void requestShareProposal_Success() {
8287 () -> assertEquals (expectedResponse .getZipCode (), response .getZipCode ())
8388 );
8489
90+ verify (badWordService ).validateText (request .getMessage ());
8591 verify (authFacade ).getCurrentUserId (); // AuthFacade 호출 검증 추가
8692 verify (shareProposalRepository ).save (any (ShareProposal .class ));
8793 verify (shareProposalLetterRepository ).saveAll (anyList ());
@@ -103,11 +109,13 @@ void requestShareProposal_ThrowsException_WhenLetterIdsInvalid() {
103109 );
104110
105111 when (authFacade .getCurrentUserId ()).thenReturn (currentUserId );
112+ doNothing ().when (badWordService ).validateText (request .getMessage ());
106113
107114 // when & then
108115 NullPointerException exception = assertThrows (NullPointerException .class , () ->
109116 shareProposalService .requestShareProposal (request ));
110117
118+ verify (badWordService ).validateText (request .getMessage ());
111119 verify (authFacade ).getCurrentUserId ();
112120 }
113121
@@ -219,6 +227,7 @@ void requestShareProposal_LetterSaveFail() {
219227 verify (shareProposalRepository ).save (any (ShareProposal .class ));
220228 }
221229
230+
222231 @ Test
223232 @ DisplayName ("존재하지 않는 공유 제안 승인 실패" )
224233 void approveShareProposal_NotFound () {
0 commit comments