3232import org .mockito .junit .jupiter .MockitoExtension ;
3333import org .sopt .app .application .platform .dto .PlatformUserInfoResponse ;
3434import org .sopt .app .application .platform .dto .PlatformUserInfoResponse .SoptActivities ;
35+ import org .sopt .app .application .rank .RankCacheService ;
3536import org .sopt .app .application .soptamp .SoptampEvent .SoptampUserAllCacheSyncEvent ;
3637import org .sopt .app .application .soptamp .SoptampEvent .SoptampUserProfileCacheSyncEvent ;
3738import org .sopt .app .application .soptamp .SoptampEvent .SoptampUserScoreCacheSyncEvent ;
@@ -58,12 +59,21 @@ class SoptampUserServiceTest {
5859 @ Mock
5960 AppjamUserRepository appjamUserRepository ;
6061
62+ @ Mock
63+ RankCacheService rankCacheService ;
64+
6165 @ Mock
6266 EventPublisher eventPublisher ;
6367
6468 @ InjectMocks
6569 SoptampUserService soptampUserService ;
6670
71+ @ BeforeEach
72+ void setUp () {
73+ ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
74+ ReflectionTestUtils .setField (soptampUserService , "currentGeneration" , 37L );
75+ }
76+
6777 private PlatformUserInfoResponse buildProfile (String name , int lastGeneration , String part ) {
6878 return buildProfile (name , lastGeneration , part , true ); // SOPT 정규 활동 기본값
6979 }
@@ -87,18 +97,13 @@ private PlatformUserInfoResponse buildProfile(String name, int lastGeneration, S
8797 );
8898 }
8999
90- @ BeforeEach
91- void setUp () {
92- // 기본은 NORMAL 모드로 두고, 테스트에서 필요할 때 변경
93- ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
94- }
95-
96100 /* ==================== NORMAL 모드 테스트 ==================== */
97101
98102 @ Test
99103 @ DisplayName ("NORMAL 모드 - 프로필이 null이면 아무 동작도 하지 않는다" )
100104 void 일반모드_프로필널이면_동작없음 () {
101105 // given
106+ ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
102107 final long userId = 1L ;
103108
104109 // when
@@ -112,6 +117,7 @@ void setUp() {
112117 @ DisplayName ("NORMAL 모드 - 활동 내역이 없으면 아무 동작도 하지 않는다" )
113118 void 일반모드_활동내역없으면_동작없음 () {
114119 // given
120+ ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
115121 final long userId = 1L ;
116122
117123 PlatformUserInfoResponse profile = new PlatformUserInfoResponse (
@@ -197,6 +203,8 @@ void setUp() {
197203 void 일반모드_기수변경되면_닉네임재생성과_포인트리셋 () {
198204 // given
199205 ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
206+ // 기수 필터링을 위해 현재 기수를 38로 임시 설정
207+ ReflectionTestUtils .setField (soptampUserService , "currentGeneration" , 38L );
200208
201209 final long userId = 1L ;
202210 PlatformUserInfoResponse profile = buildProfile ("김솝트" , 38 , "서버" );
@@ -232,6 +240,7 @@ void setUp() {
232240 @ DisplayName ("NORMAL 모드 - isSopt=false인 Makers 활동만 있으면 SoptampUser를 생성하지 않는다" )
233241 void 일반모드_Makers이면_솝탬프유저_생성안함 () {
234242 // given
243+ ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
235244 final long userId = 1L ;
236245 // "백엔드" 파트, isSopt=false → getLatestSoptActivity() = null
237246 PlatformUserInfoResponse profile = buildProfile ("김솝트" , 37 , "백엔드" , false );
@@ -247,6 +256,7 @@ void setUp() {
247256 @ DisplayName ("NORMAL 모드 - 메이커스(isSopt=false)이면서 동시에 SOPT 서버 파트(isSopt=true) 활동이 있으면 SOPT 활동 기준으로 생성된다" )
248257 void 일반모드_메이커스이면서_솝트파트있으면_솝트파트기준으로_생성 () {
249258 // given
259+ ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
250260 final long userId = 1L ;
251261 PlatformUserInfoResponse .SoptActivities presidentActivity =
252262 new PlatformUserInfoResponse .SoptActivities (1 , 37 , "BE" , null , false );
@@ -312,7 +322,8 @@ void setUp() {
312322 assertThat (saved .getTotalPoints ()).isZero ();
313323 assertThat (saved .getGeneration ()).isEqualTo (37L );
314324
315- verify (eventPublisher ).raise (any (SoptampUserAllCacheSyncEvent .class ));
325+ // 앱잼 모드에서는 이벤트를 발행하지 않음 (Helper 로직 기준)
326+ verify (eventPublisher , never ()).raise (any ());
316327 }
317328
318329 @ Test
@@ -341,7 +352,7 @@ void setUp() {
341352 assertThat (saved .getNickname ()).contains ("김솝트" );
342353 assertThat (saved .getTotalPoints ()).isZero ();
343354
344- verify (eventPublisher ) .raise (any (SoptampUserAllCacheSyncEvent . class ));
355+ verify (eventPublisher , never ()) .raise (any ());
345356 }
346357
347358 @ Test
@@ -370,7 +381,7 @@ void setUp() {
370381 assertThat (saved .getNickname ()).contains ("김솝트" );
371382 assertThat (saved .getTotalPoints ()).isZero ();
372383
373- verify (eventPublisher ) .raise (any (SoptampUserAllCacheSyncEvent . class ));
384+ verify (eventPublisher , never ()) .raise (any ());
374385 }
375386
376387 @ Test
@@ -416,7 +427,7 @@ void setUp() {
416427 assertThat (existing .getTotalPoints ()).isZero ();
417428 assertThat (existing .getGeneration ()).isEqualTo (37L );
418429
419- verify (eventPublisher ) .raise (any (SoptampUserAllCacheSyncEvent . class ));
430+ verify (eventPublisher , never ()) .raise (any ());
420431 }
421432
422433 @ Test
@@ -494,15 +505,14 @@ void setUp() {
494505 assertThat (existing .getNickname ()).isEqualTo ("비트김솝트A" );
495506 assertThat (existing .getTotalPoints ()).isZero ();
496507
497- verify (eventPublisher ) .raise (any (SoptampUserAllCacheSyncEvent . class ));
508+ verify (eventPublisher , never ()) .raise (any ());
498509 }
499510
500511 @ Test
501512 @ DisplayName ("NORMAL 모드 - 다른 유저가 같은 파트 기반 닉네임을 쓰고 있으면 접미사 A를 붙인다" )
502513 void 일반모드_닉네임충돌시_접미사A추가 () {
503514 // given
504515 ReflectionTestUtils .setField (soptampUserService , "appjamMode" , false );
505-
506516 final long userId = 1L ;
507517 PlatformUserInfoResponse profile = buildProfile ("김솝트" , 37 , "서버" );
508518
0 commit comments