|
1 | 1 | package com.somemore.domains.volunteerapply.service; |
2 | 2 |
|
| 3 | +import static com.somemore.domains.volunteerapply.domain.ApplyStatus.APPROVED; |
| 4 | +import static com.somemore.domains.volunteerapply.domain.ApplyStatus.REJECTED; |
| 5 | +import static com.somemore.domains.volunteerapply.domain.ApplyStatus.WAITING; |
| 6 | +import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_VOLUNTEER_APPLY; |
| 7 | +import static org.assertj.core.api.Assertions.assertThat; |
| 8 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| 9 | + |
3 | 10 | import com.somemore.domains.volunteerapply.domain.ApplyStatus; |
4 | 11 | import com.somemore.domains.volunteerapply.domain.VolunteerApply; |
5 | 12 | import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; |
6 | 13 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; |
7 | 14 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; |
8 | 15 | import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository; |
| 16 | +import com.somemore.global.exception.NoSuchElementException; |
9 | 17 | import com.somemore.support.IntegrationTestSupport; |
| 18 | +import java.util.List; |
| 19 | +import java.util.UUID; |
10 | 20 | import org.junit.jupiter.api.DisplayName; |
11 | 21 | import org.junit.jupiter.api.Test; |
12 | 22 | import org.springframework.beans.factory.annotation.Autowired; |
|
15 | 25 | import org.springframework.data.domain.Pageable; |
16 | 26 | import org.springframework.transaction.annotation.Transactional; |
17 | 27 |
|
18 | | -import java.util.List; |
19 | | -import java.util.UUID; |
20 | | - |
21 | | -import static com.somemore.domains.volunteerapply.domain.ApplyStatus.*; |
22 | | -import static org.assertj.core.api.Assertions.assertThat; |
23 | | - |
24 | 28 | @Transactional |
25 | 29 | class VolunteerApplyQueryServiceTest extends IntegrationTestSupport { |
26 | 30 |
|
@@ -193,6 +197,22 @@ void getAllByIds() { |
193 | 197 | .containsExactlyInAnyOrderElementsOf(ids); |
194 | 198 | } |
195 | 199 |
|
| 200 | + @DisplayName("존재하지 않는 봉사 지원을 조회할 경우 에러가 발생한다.") |
| 201 | + @Test |
| 202 | + void getByRecruitIdAndVolunteerIdWhenNotExist() { |
| 203 | + // given |
| 204 | + Long wrongBoardId = 999L; |
| 205 | + UUID wrongVolunteerId = UUID.randomUUID(); |
| 206 | + |
| 207 | + // when |
| 208 | + // then |
| 209 | + assertThatThrownBy( |
| 210 | + () -> volunteerApplyQueryService.getByRecruitIdAndVolunteerId(wrongBoardId, |
| 211 | + wrongVolunteerId) |
| 212 | + ).isInstanceOf(NoSuchElementException.class) |
| 213 | + .hasMessage(NOT_EXISTS_VOLUNTEER_APPLY.getMessage()); |
| 214 | + } |
| 215 | + |
196 | 216 | private VolunteerApply createApply(UUID volunteerId, Long recruitId) { |
197 | 217 | return createApply(volunteerId, recruitId, WAITING); |
198 | 218 | } |
|
0 commit comments