11package io .crops .warmletter .domain .share .service ;
2+
23import io .crops .warmletter .domain .auth .facade .AuthFacade ;
34import io .crops .warmletter .domain .share .cache .PostLikeRedisManager ;
45import io .crops .warmletter .domain .share .dto .response .SharePostLikeResponse ;
1011import org .mockito .InjectMocks ;
1112import org .mockito .Mock ;
1213import org .mockito .junit .jupiter .MockitoExtension ;
14+
1315import static org .junit .jupiter .api .Assertions .*;
1416import static org .mockito .Mockito .*;
1517
@@ -54,7 +56,6 @@ void getLikeCountAndStatus_Success() {
5456 SharePostLikeResponse mockResponse = new SharePostLikeResponse (5L , true );
5557
5658 when (authFacade .getCurrentUserId ()).thenReturn (memberId );
57- when (redisManager .isLiked (sharePostId , memberId )).thenReturn (true );
5859 when (sharePostLikeRepository .getLikeCountAndStatus (sharePostId , memberId ))
5960 .thenReturn (mockResponse );
6061
@@ -66,7 +67,6 @@ void getLikeCountAndStatus_Success() {
6667 assertEquals (5L , result .getLikeCount ());
6768 assertTrue (result .isLiked ());
6869 verify (authFacade ).getCurrentUserId ();
69- verify (redisManager ).isLiked (sharePostId , memberId );
7070 verify (sharePostLikeRepository ).getLikeCountAndStatus (sharePostId , memberId );
7171 }
7272
@@ -79,7 +79,6 @@ void getLikeCountAndStatus_NotLiked() {
7979 SharePostLikeResponse mockResponse = new SharePostLikeResponse (10L , false );
8080
8181 when (authFacade .getCurrentUserId ()).thenReturn (memberId );
82- when (redisManager .isLiked (sharePostId , memberId )).thenReturn (false );
8382 when (sharePostLikeRepository .getLikeCountAndStatus (sharePostId , memberId ))
8483 .thenReturn (mockResponse );
8584
@@ -91,7 +90,6 @@ void getLikeCountAndStatus_NotLiked() {
9190 assertEquals (10L , result .getLikeCount ());
9291 assertFalse (result .isLiked ());
9392 verify (authFacade ).getCurrentUserId ();
94- verify (redisManager ).isLiked (sharePostId , memberId );
9593 verify (sharePostLikeRepository ).getLikeCountAndStatus (sharePostId , memberId );
9694 }
9795
@@ -108,31 +106,6 @@ void getLikeCountAndStatus_NullPostId() {
108106 });
109107
110108 verify (authFacade ).getCurrentUserId ();
111- verify (redisManager , never ()).isLiked (any (), any ());
112109 verify (sharePostLikeRepository , never ()).getLikeCountAndStatus (any (), any ());
113110 }
114- @ Test
115- @ DisplayName ("좋아요 개수와 상태 조회 - Redis는 false, DB는 true일 때 redis 우선 " )
116- void getLikeCountAndStatus_RedisNotLikedDbLiked () {
117- // given
118- Long sharePostId = 1L ;
119- Long memberId = 1L ;
120- SharePostLikeResponse mockResponse = new SharePostLikeResponse (10L , true );
121-
122- when (authFacade .getCurrentUserId ()).thenReturn (memberId );
123- when (redisManager .isLiked (sharePostId , memberId )).thenReturn (false );
124- when (sharePostLikeRepository .getLikeCountAndStatus (sharePostId , memberId ))
125- .thenReturn (mockResponse );
126-
127- // when
128- SharePostLikeResponse result = sharePostLikeService .getLikeCountAndStatus (sharePostId );
129-
130- // then
131- assertNotNull (result );
132- assertEquals (10L , result .getLikeCount ());
133- assertFalse (result .isLiked ());
134- verify (authFacade ).getCurrentUserId ();
135- verify (redisManager ).isLiked (sharePostId , memberId );
136- verify (sharePostLikeRepository ).getLikeCountAndStatus (sharePostId , memberId );
137- }
138111}
0 commit comments