88import com .somemore .IntegrationTestSupport ;
99import com .somemore .volunteerapply .domain .ApplyStatus ;
1010import com .somemore .volunteerapply .domain .VolunteerApply ;
11+ import com .somemore .volunteerapply .dto .condition .VolunteerApplySearchCondition ;
1112import com .somemore .volunteerapply .dto .response .VolunteerApplyResponseDto ;
1213import com .somemore .volunteerapply .dto .response .VolunteerApplySummaryResponseDto ;
1314import com .somemore .volunteerapply .repository .VolunteerApplyRepository ;
1617import org .junit .jupiter .api .DisplayName ;
1718import org .junit .jupiter .api .Test ;
1819import org .springframework .beans .factory .annotation .Autowired ;
20+ import org .springframework .data .domain .Page ;
21+ import org .springframework .data .domain .PageRequest ;
22+ import org .springframework .data .domain .Pageable ;
1923import org .springframework .transaction .annotation .Transactional ;
2024
2125@ Transactional
@@ -118,6 +122,51 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() {
118122 assertThat (dto .volunteerId ()).isEqualTo (volunteerId );
119123 }
120124
125+ @ DisplayName ("모집글 아이디로 지원 리스트를 페이징 조회할 수 있다." )
126+ @ Test
127+ void getAllByRecruitId () {
128+ // given
129+ Long boardId = 1L ;
130+ VolunteerApply apply1 = createApply (UUID .randomUUID (), boardId );
131+ VolunteerApply apply2 = createApply (UUID .randomUUID (), boardId );
132+ volunteerApplyRepository .saveAll (List .of (apply1 , apply2 ));
133+
134+ VolunteerApplySearchCondition condition = VolunteerApplySearchCondition .builder ()
135+ .pageable (getPageable ())
136+ .build ();
137+
138+ // when
139+ Page <VolunteerApply > applies = volunteerApplyQueryService .getAllByRecruitId (boardId ,
140+ condition );
141+
142+ // then
143+ assertThat (applies ).hasSize (2 );
144+ }
145+
146+ @ DisplayName ("봉사자 아이디로 봉사 지원 리스트를 페이징 조회 할 수있다." )
147+ @ Test
148+ void getVolunteerAppliesByVolunteerId () {
149+ // given
150+ UUID volunteerId = UUID .randomUUID ();
151+
152+ VolunteerApply apply1 = createApply (volunteerId , 200L );
153+ VolunteerApply apply2 = createApply (volunteerId , 201L );
154+ VolunteerApply apply3 = createApply (volunteerId , 202L );
155+ VolunteerApply apply4 = createApply (UUID .randomUUID (), 203L );
156+ volunteerApplyRepository .saveAll (List .of (apply1 , apply2 , apply3 , apply4 ));
157+
158+ VolunteerApplySearchCondition condition = VolunteerApplySearchCondition .builder ()
159+ .pageable (getPageable ())
160+ .build ();
161+
162+ // when
163+ Page <VolunteerApply > applies = volunteerApplyQueryService .getAllByVolunteerId (
164+ volunteerId , condition );
165+
166+ // then
167+ assertThat (applies ).hasSize (3 );
168+ }
169+
121170 private VolunteerApply createApply (UUID volunteerId , Long recruitId ) {
122171 return createApply (volunteerId , recruitId , WAITING );
123172 }
@@ -130,4 +179,8 @@ private VolunteerApply createApply(UUID volunteerId, Long recruitId, ApplyStatus
130179 .attended (false )
131180 .build ();
132181 }
182+
183+ private Pageable getPageable () {
184+ return PageRequest .of (0 , 4 );
185+ }
133186}
0 commit comments