Skip to content

Commit fb1f847

Browse files
committed
test(volunteer-apply): 특정 모집글에 대한 봉사자의 지원 조회 필드 추가 test
- 리뷰 작성 여부 추가
1 parent 60bfd73 commit fb1f847

File tree

3 files changed

+41
-19
lines changed

3 files changed

+41
-19
lines changed

src/test/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiControllerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition;
44
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto;
5-
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto;
5+
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto;
66
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto;
77
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto;
88
import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase;
@@ -44,15 +44,15 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception {
4444
Long recruitBoardId = 1L;
4545
UUID volunteerId = UUID.randomUUID();
4646

47-
VolunteerApplyResponseDto response = VolunteerApplyResponseDto.builder()
47+
VolunteerApplyWithReviewStatusResponseDto response = VolunteerApplyWithReviewStatusResponseDto.builder()
4848
.id(1L)
4949
.volunteerId(volunteerId)
5050
.recruitBoardId(recruitBoardId)
5151
.status(WAITING)
5252
.attended(false)
5353
.build();
5454

55-
given(volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
55+
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
5656
volunteerId))
5757
.willReturn(response);
5858

@@ -78,7 +78,7 @@ void getVolunteerApplyByRecruitIdAndVolunteerIdWhenDoesNotExist() throws Excepti
7878
Long recruitBoardId = 1L;
7979
UUID volunteerId = UUID.randomUUID();
8080

81-
given(volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
81+
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
8282
volunteerId))
8383
.willThrow(new NoSuchElementException(NOT_EXISTS_VOLUNTEER_APPLY));
8484

src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeServiceTest.java

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.somemore.domains.recruitboard.domain.RecruitBoard;
44
import com.somemore.domains.recruitboard.repository.RecruitBoardRepository;
5+
import com.somemore.domains.review.domain.Review;
6+
import com.somemore.domains.review.repository.ReviewRepository;
57
import com.somemore.domains.volunteer.domain.Volunteer;
68
import com.somemore.domains.volunteer.domain.VolunteerDetail;
79
import com.somemore.domains.volunteer.dto.request.VolunteerRegisterRequestDto;
@@ -11,6 +13,7 @@
1113
import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition;
1214
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto;
1315
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto;
16+
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto;
1417
import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository;
1518
import com.somemore.support.IntegrationTestSupport;
1619
import org.junit.jupiter.api.DisplayName;
@@ -42,7 +45,30 @@ class VolunteerApplyQueryFacadeServiceTest extends IntegrationTestSupport {
4245
private VolunteerDetailRepository volunteerDetailRepository;
4346
@Autowired
4447
private VolunteerApplyRepository volunteerApplyRepository;
48+
@Autowired
49+
private ReviewRepository reviewRepository;
50+
51+
@DisplayName("모집글 아이디와 봉사자 아이디로 지원 응답 값을 조회할 수 있다.")
52+
@Test
53+
void getVolunteerApplyByRecruitIdAndVolunteerId() {
54+
// given
55+
Long recruitBoardId = 1234L;
56+
UUID volunteerId = UUID.randomUUID();
57+
VolunteerApply apply = createApply(volunteerId, recruitBoardId);
58+
volunteerApplyRepository.save(apply);
59+
60+
Review review = createReview(apply.getId(), volunteerId);
61+
reviewRepository.save(review);
62+
63+
// when
64+
VolunteerApplyWithReviewStatusResponseDto dto = volunteerApplyQueryFacadeService.getVolunteerApplyByRecruitIdAndVolunteerId(
65+
recruitBoardId, volunteerId);
4566

67+
// then
68+
assertThat(dto.recruitBoardId()).isEqualTo(recruitBoardId);
69+
assertThat(dto.volunteerId()).isEqualTo(volunteerId);
70+
assertThat(dto.isReviewed()).isTrue();
71+
}
4672

4773
@DisplayName("모집글 아이디와 기관 아이디로 필터에 맞는 지원자 간단 정보를 조회할 수 있다.")
4874
@Test
@@ -108,6 +134,16 @@ void getVolunteerAppliesByVolunteerId() {
108134
assertThat(result).hasSize(3);
109135
}
110136

137+
private static Review createReview(Long volunteerApplyId, UUID volunteerId) {
138+
return Review.builder()
139+
.volunteerApplyId(volunteerApplyId)
140+
.volunteerId(volunteerId)
141+
.title("리뷰 제목")
142+
.content("리뷰 내용")
143+
.imgUrl("리뷰 이미지")
144+
.build();
145+
}
146+
111147
private static VolunteerDetail createVolunteerDetail(UUID volunteerId) {
112148

113149
VolunteerRegisterRequestDto volunteerRegisterRequestDto =
@@ -130,7 +166,7 @@ private static VolunteerApply createApply(UUID volunteerId, Long recruitId) {
130166
.volunteerId(volunteerId)
131167
.recruitBoardId(recruitId)
132168
.status(APPROVED)
133-
.attended(false)
169+
.attended(true)
134170
.build();
135171
}
136172

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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import com.somemore.domains.volunteerapply.domain.ApplyStatus;
44
import com.somemore.domains.volunteerapply.domain.VolunteerApply;
55
import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition;
6-
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto;
76
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto;
87
import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository;
98
import com.somemore.global.exception.NoSuchElementException;
@@ -131,19 +130,6 @@ void getSummaryByRecruitBoardId() {
131130
assertThat(dto.reject()).isEqualTo(rejectCount);
132131
}
133132

134-
@DisplayName("모집글 아이디와 봉사자 아이디로 지원 응답 값을 조회할 수 있다.")
135-
@Test
136-
void getVolunteerApplyByRecruitIdAndVolunteerId() {
137-
// given
138-
// when
139-
VolunteerApplyResponseDto dto = volunteerApplyQueryService.getVolunteerApplyByRecruitIdAndVolunteerId(
140-
recruitBoardId, volunteerId);
141-
142-
// then
143-
assertThat(dto.recruitBoardId()).isEqualTo(recruitBoardId);
144-
assertThat(dto.volunteerId()).isEqualTo(volunteerId);
145-
}
146-
147133
@DisplayName("모집글 아이디로 지원 리스트를 페이징 조회할 수 있다.")
148134
@Test
149135
void getAllByRecruitId() {

0 commit comments

Comments
 (0)