11package com .oronaminc .join .member .service ;
22
3- import static org .assertj .core .api .Assertions .*;
4- import static org .mockito .Mockito .*;
5-
6- import java .time .LocalDateTime ;
7- import java .util .List ;
8-
3+ import com .oronaminc .join .member .domain .Member ;
4+ import com .oronaminc .join .member .dto .*;
5+ import com .oronaminc .join .participant .domain .Participant ;
6+ import com .oronaminc .join .participant .domain .ParticipantType ;
7+ import com .oronaminc .join .participant .service .ParticipantReader ;
8+ import com .oronaminc .join .question .service .QuestionReader ;
9+ import com .oronaminc .join .room .domain .Room ;
910import org .junit .jupiter .api .DisplayName ;
1011import org .junit .jupiter .api .Test ;
1112import org .junit .jupiter .api .extension .ExtendWith ;
1819import org .springframework .data .domain .Pageable ;
1920import org .springframework .test .util .ReflectionTestUtils ;
2021
21- import com .oronaminc .join .member .domain .Member ;
22- import com .oronaminc .join .member .dto .MyPageType ;
23- import com .oronaminc .join .member .dto .MyProfileGetResponse ;
24- import com .oronaminc .join .member .dto .MyProfileUpdateRequest ;
25- import com .oronaminc .join .member .dto .MyRoomsGetResponse ;
26- import com .oronaminc .join .member .dto .ParticipantCountDto ;
27- import com .oronaminc .join .member .dto .ParticipationType ;
28- import com .oronaminc .join .participant .domain .Participant ;
29- import com .oronaminc .join .participant .domain .ParticipantType ;
30- import com .oronaminc .join .participant .service .ParticipantReader ;
31- import com .oronaminc .join .question .service .QuestionReader ;
32- import com .oronaminc .join .room .domain .Room ;
22+ import java .time .LocalDateTime ;
23+ import java .util .List ;
24+
25+ import static org .assertj .core .api .Assertions .assertThat ;
26+ import static org .mockito .Mockito .when ;
3327
3428@ ExtendWith (MockitoExtension .class )
3529class MyPageServiceTests {
@@ -54,14 +48,14 @@ void getMyProfile_success_test() {
5448 Member member = Member .builder ().build ();
5549
5650 List <ParticipantCountDto > pc = List .of (
57- new ParticipantCountDto (ParticipantType .PRESENTER , 1L ),
58- new ParticipantCountDto (ParticipantType .TEAM , 1L ),
59- new ParticipantCountDto (ParticipantType .GUEST , 1L )
51+ new ParticipantCountDto (ParticipantType .PRESENTER , 1L ),
52+ new ParticipantCountDto (ParticipantType .TEAM , 1L ),
53+ new ParticipantCountDto (ParticipantType .GUEST , 1L )
6054 );
6155
6256 when (memberReader .getById (member .getId ())).thenReturn (member );
6357 when (participantReader .countByMemberIdGroupByParticipantType (member .getId ()))
64- .thenReturn (pc );
58+ .thenReturn (pc );
6559
6660 // when
6761 MyProfileGetResponse myProfile = myPageService .getMyProfile (member .getId ());
@@ -84,7 +78,7 @@ void getMyProfile_success_test2() {
8478
8579 when (memberReader .getById (member .getId ())).thenReturn (member );
8680 when (participantReader .countByMemberIdGroupByParticipantType (member .getId ()))
87- .thenReturn (pc );
81+ .thenReturn (pc );
8882
8983 // when
9084 MyProfileGetResponse myProfile = myPageService .getMyProfile (member .getId ());
@@ -127,8 +121,8 @@ void getMyRooms_success_test() {
127121 Pageable pageable = PageRequest .of (0 , 10 );
128122
129123 Room room1 = Room .builder ()
130- .title ("~1~의 정석" )
131- .build ();
124+ .title ("~1~의 정석" )
125+ .build ();
132126 Room room2 = Room .builder ().title ("~2~의 정석" ).build ();
133127 Room room3 = Room .builder ().title ("~3~의 정석" ).build ();
134128 ReflectionTestUtils .setField (room1 , "id" , 100L );
@@ -139,33 +133,35 @@ void getMyRooms_success_test() {
139133 ReflectionTestUtils .setField (room3 , "createdAt" , LocalDateTime .now ());
140134
141135 Participant participant1 = Participant .builder ()
142- .room (room1 )
143- .member (member )
144- .participantType (ParticipantType .PRESENTER )
145- .build ();
136+ .room (room1 )
137+ .member (member )
138+ .participantType (ParticipantType .PRESENTER )
139+ .build ();
146140 Participant participant2 = Participant .builder ()
147- .room (room2 )
148- .member (member )
149- .participantType (ParticipantType .TEAM )
150- .build ();
141+ .room (room2 )
142+ .member (member )
143+ .participantType (ParticipantType .TEAM )
144+ .build ();
151145 Participant participant3 = Participant .builder ()
152- .room (room3 )
153- .member (member )
154- .participantType (ParticipantType .GUEST )
155- .build ();
146+ .room (room3 )
147+ .member (member )
148+ .participantType (ParticipantType .GUEST )
149+ .build ();
150+ ReflectionTestUtils .setField (participant2 , "createdAt" , LocalDateTime .now ());
151+ ReflectionTestUtils .setField (participant3 , "createdAt" , LocalDateTime .now ());
156152
157153 List <Participant > pc = List .of (participant1 , participant2 , participant3 );
158154 Page <Participant > participantPage = new PageImpl <>(pc , pageable , 1 );
159155
160156 List <Long > roomIds = List .of (room1 .getId (), room2 .getId (), room3 .getId ());
161157 List <Object []> questions = List .of (
162- new Object []{room1 .getId (), 1L },
163- new Object []{room2 .getId (), 2L },
164- new Object []{room3 .getId (), 3L }
158+ new Object []{room1 .getId (), 1L },
159+ new Object []{room2 .getId (), 2L },
160+ new Object []{room3 .getId (), 3L }
165161 );
166162
167163 when (participantReader .findByMemberId (memberId , pageable ))
168- .thenReturn (participantPage );
164+ .thenReturn (participantPage );
169165 when (questionReader .countByRoomIds (roomIds )).thenReturn (questions );
170166
171167 // when
@@ -176,7 +172,7 @@ void getMyRooms_success_test() {
176172 assertThat (result .content ().getFirst ().roomId ()).isEqualTo (100L );
177173 assertThat (result .content ().getFirst ().title ()).isEqualTo ("~1~의 정석" );
178174 assertThat (result .content ().getFirst ().participationType ()).isEqualTo (
179- ParticipationType .CREATED );
175+ ParticipationType .CREATED );
180176 assertThat (result .content ().get (1 ).participationType ()).isEqualTo (ParticipationType .JOINED );
181177
182178 }
0 commit comments