|
1 | 1 | package com.somemore.domains.volunteerapply.controller; |
2 | 2 |
|
3 | | -import static com.somemore.domains.volunteerapply.domain.ApplyStatus.WAITING; |
4 | | -import static org.mockito.ArgumentMatchers.any; |
5 | | -import static org.mockito.BDDMockito.given; |
6 | | -import static org.springframework.http.MediaType.APPLICATION_JSON; |
7 | | -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
8 | | -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
9 | | -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
10 | | - |
11 | 3 | import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; |
12 | 4 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; |
13 | 5 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; |
14 | 6 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; |
15 | 7 | import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; |
16 | 8 | import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase; |
17 | 9 | import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase; |
| 10 | +import com.somemore.global.exception.NoSuchElementException; |
18 | 11 | import com.somemore.support.ControllerTestSupport; |
19 | 12 | import com.somemore.support.annotation.WithMockCustomUser; |
20 | | -import java.util.Collections; |
21 | | -import java.util.UUID; |
22 | 13 | import org.junit.jupiter.api.DisplayName; |
23 | 14 | import org.junit.jupiter.api.Test; |
24 | 15 | import org.springframework.boot.test.mock.mockito.MockBean; |
25 | 16 | import org.springframework.data.domain.Page; |
26 | 17 | import org.springframework.data.domain.PageImpl; |
27 | 18 |
|
| 19 | +import java.util.Collections; |
| 20 | +import java.util.UUID; |
| 21 | + |
| 22 | +import static com.somemore.domains.volunteerapply.domain.ApplyStatus.WAITING; |
| 23 | +import static com.somemore.global.exception.ExceptionMessage.NOT_EXISTS_VOLUNTEER_APPLY; |
| 24 | +import static org.mockito.ArgumentMatchers.any; |
| 25 | +import static org.mockito.BDDMockito.given; |
| 26 | +import static org.springframework.http.MediaType.APPLICATION_JSON; |
| 27 | +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
| 28 | +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; |
| 29 | +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
| 30 | + |
28 | 31 | class VolunteerApplyQueryApiControllerTest extends ControllerTestSupport { |
29 | 32 |
|
30 | 33 | @MockBean |
@@ -68,6 +71,27 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception { |
68 | 71 | .andExpect(jsonPath("$.data.attended").value(false)); |
69 | 72 | } |
70 | 73 |
|
| 74 | + @DisplayName("특정 모집글 봉사자 지원 단건 조회 성공 테스트 - 지원 내역이 없는 경우") |
| 75 | + @Test |
| 76 | + void getVolunteerApplyByRecruitIdAndVolunteerIdWhenDoesNotExist() throws Exception { |
| 77 | + // given |
| 78 | + Long recruitBoardId = 1L; |
| 79 | + UUID volunteerId = UUID.randomUUID(); |
| 80 | + |
| 81 | + given(volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, |
| 82 | + volunteerId)) |
| 83 | + .willThrow(new NoSuchElementException(NOT_EXISTS_VOLUNTEER_APPLY)); |
| 84 | + |
| 85 | + // when & then |
| 86 | + mockMvc.perform( |
| 87 | + get("/api/volunteer-apply/recruit-board/{recruitBoardId}/volunteer/{volunteerId}", |
| 88 | + recruitBoardId, volunteerId) |
| 89 | + .accept(APPLICATION_JSON)) |
| 90 | + .andExpect(status().isOk()) |
| 91 | + .andExpect(jsonPath("$.code").value(210)) |
| 92 | + .andExpect(jsonPath("$.message").value("지원 내역이 없습니다.")); |
| 93 | + } |
| 94 | + |
71 | 95 | @DisplayName("모집글 지원자 통계 조회 성공 테스트") |
72 | 96 | @Test |
73 | 97 | void getSummaryByRecruitBoardId() throws Exception { |
|
0 commit comments