Skip to content

Commit 1b1bb3d

Browse files
committed
test(VolunteerApplyQueryService): 모집 아이디로 봉사자 아이디 리스트 조회 테스트 추가
1 parent 7947635 commit 1b1bb3d

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.somemore.volunteerApply.service;
2+
3+
import com.somemore.IntegrationTestSupport;
4+
import com.somemore.volunteerApply.domain.VolunteerApply;
5+
import com.somemore.volunteerApply.repository.VolunteerApplyRepository;
6+
import org.junit.jupiter.api.DisplayName;
7+
import org.junit.jupiter.api.Test;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.transaction.annotation.Transactional;
10+
11+
import java.util.List;
12+
import java.util.UUID;
13+
14+
import static org.assertj.core.api.Assertions.assertThat;
15+
16+
@Transactional
17+
class VolunteerApplyQueryServiceTest extends IntegrationTestSupport {
18+
19+
@Autowired
20+
private VolunteerApplyQueryService volunteerApplyQueryService;
21+
22+
@Autowired
23+
private VolunteerApplyRepository volunteerApplyRepository;
24+
25+
@DisplayName("recruitIds로 봉사자 ID 리스트를 조회할 수 있다")
26+
@Test
27+
void getVolunteerIdsByRecruitIds() {
28+
// Given
29+
Long recruitId1 = 1L;
30+
Long recruitId2 = 2L;
31+
UUID volunteerId1 = UUID.randomUUID();
32+
UUID volunteerId2 = UUID.randomUUID();
33+
34+
VolunteerApply apply1 = createVolunteerApply(recruitId1, volunteerId1);
35+
VolunteerApply apply2 = createVolunteerApply(recruitId2, volunteerId2);
36+
37+
volunteerApplyRepository.save(apply1);
38+
volunteerApplyRepository.save(apply2);
39+
40+
// When
41+
List<UUID> volunteerIds = volunteerApplyQueryService.getVolunteerIdsByRecruitIds(List.of(recruitId1, recruitId2));
42+
43+
// Then
44+
assertThat(volunteerIds)
45+
.hasSize(2)
46+
.containsExactlyInAnyOrder(volunteerId1, volunteerId2);
47+
}
48+
49+
private VolunteerApply createVolunteerApply(Long recruitId, UUID volunteerId) {
50+
return VolunteerApply.builder()
51+
.volunteerId(volunteerId)
52+
.recruitBoardId(recruitId)
53+
.status(null)
54+
.attended(null)
55+
.build();
56+
}
57+
}

0 commit comments

Comments
 (0)