Skip to content

Commit 34fd953

Browse files
committed
test(volunteer-apply): 리뷰 생성에 필요한 조회 기능 테스트
1 parent bf24294 commit 34fd953

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.somemore.volunteerapply.service;
2+
3+
import com.somemore.IntegrationTestSupport;
4+
import com.somemore.volunteerapply.domain.ApplyStatus;
5+
import com.somemore.volunteerapply.domain.VolunteerApply;
6+
import com.somemore.volunteerapply.repository.VolunteerApplyRepository;
7+
import org.junit.jupiter.api.DisplayName;
8+
import org.junit.jupiter.api.Test;
9+
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.transaction.annotation.Transactional;
11+
12+
import java.util.List;
13+
import java.util.UUID;
14+
15+
import static org.assertj.core.api.Assertions.assertThat;
16+
17+
@Transactional
18+
class VolunteerApplyQueryServiceTest extends IntegrationTestSupport {
19+
20+
@Autowired
21+
private VolunteerApplyQueryService volunteerApplyQueryService;
22+
23+
@Autowired
24+
private VolunteerApplyRepository volunteerApplyRepository;
25+
26+
@DisplayName("recruitIds로 봉사자 ID 리스트를 조회할 수 있다")
27+
@Test
28+
void getVolunteerIdsByRecruitIds() {
29+
// Given
30+
Long recruitId1 = 1L;
31+
Long recruitId2 = 2L;
32+
UUID volunteerId1 = UUID.randomUUID();
33+
UUID volunteerId2 = UUID.randomUUID();
34+
35+
VolunteerApply apply1 = createVolunteerApply(recruitId1, volunteerId1);
36+
VolunteerApply apply2 = createVolunteerApply(recruitId2, volunteerId2);
37+
38+
volunteerApplyRepository.save(apply1);
39+
volunteerApplyRepository.save(apply2);
40+
41+
// When
42+
List<UUID> volunteerIds = volunteerApplyQueryService.getVolunteerIdsByRecruitIds(List.of(recruitId1, recruitId2));
43+
44+
// Then
45+
assertThat(volunteerIds)
46+
.hasSize(2)
47+
.containsExactlyInAnyOrder(volunteerId1, volunteerId2);
48+
}
49+
50+
private VolunteerApply createVolunteerApply(Long recruitId, UUID volunteerId) {
51+
return VolunteerApply.builder()
52+
.volunteerId(volunteerId)
53+
.recruitBoardId(recruitId)
54+
.status(ApplyStatus.WAITING)
55+
.attended(false)
56+
.build();
57+
}
58+
59+
@DisplayName("모집글 아이디와 봉사자 아이디로 조회할 수 있다")
60+
@Test
61+
void getByRecruitIdAndVolunteerId() {
62+
// given
63+
Long recruitId = 1234L;
64+
UUID volunteerId = UUID.randomUUID();
65+
66+
VolunteerApply newApply = VolunteerApply.builder()
67+
.volunteerId(volunteerId)
68+
.recruitBoardId(recruitId)
69+
.status(ApplyStatus.APPROVED)
70+
.attended(false)
71+
.build();
72+
volunteerApplyRepository.save(newApply);
73+
74+
// when
75+
VolunteerApply apply = volunteerApplyQueryService.getByRecruitIdAndVolunteerId(
76+
recruitId, volunteerId);
77+
78+
// then
79+
assertThat(apply.getRecruitBoardId()).isEqualTo(recruitId);
80+
assertThat(apply.getVolunteerId()).isEqualTo(volunteerId);
81+
}
82+
}

0 commit comments

Comments
 (0)