Skip to content

Commit cf8e1c3

Browse files
committed
test(volunteer-apply): facade 에서 레포지토리가 아닌 UseCase를 의존하도록 변경에 따른 테스트
1 parent 8e90d85 commit cf8e1c3

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/test/java/com/somemore/volunteerapply/service/VolunteerApplyQueryServiceTest.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.somemore.IntegrationTestSupport;
99
import com.somemore.volunteerapply.domain.ApplyStatus;
1010
import com.somemore.volunteerapply.domain.VolunteerApply;
11+
import com.somemore.volunteerapply.dto.condition.VolunteerApplySearchCondition;
1112
import com.somemore.volunteerapply.dto.response.VolunteerApplyResponseDto;
1213
import com.somemore.volunteerapply.dto.response.VolunteerApplySummaryResponseDto;
1314
import com.somemore.volunteerapply.repository.VolunteerApplyRepository;
@@ -16,6 +17,9 @@
1617
import org.junit.jupiter.api.DisplayName;
1718
import org.junit.jupiter.api.Test;
1819
import 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;
1923
import 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

Comments
 (0)