Skip to content

Commit e56b93c

Browse files
authored
fix: 봉사자 특정 모집글 지원 상태 조회 API 수정 (#330)
* fix(volunteer-apply): 특정 게시글 봉사 지원 조회 수정 - 봉사자 로그인시 특정 게시글 봉사 지원 단건 조회 * test(volunteer-apply): 특정 게시글 봉사 지원 조회 수정 테스트 - 봉사자 로그인시 특정 게시글 봉사 지원 단건 조회
1 parent 27743e6 commit e56b93c

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

src/main/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiController.java

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase;
1010
import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase;
1111
import com.somemore.global.auth.annotation.CurrentUser;
12+
import com.somemore.global.auth.annotation.RoleId;
1213
import com.somemore.global.common.response.ApiResponse;
1314
import com.somemore.global.exception.NoSuchElementException;
1415
import io.swagger.v3.oas.annotations.Operation;
@@ -18,11 +19,7 @@
1819
import org.springframework.data.domain.Pageable;
1920
import org.springframework.data.web.PageableDefault;
2021
import org.springframework.security.access.annotation.Secured;
21-
import org.springframework.web.bind.annotation.GetMapping;
22-
import org.springframework.web.bind.annotation.PathVariable;
23-
import org.springframework.web.bind.annotation.RequestMapping;
24-
import org.springframework.web.bind.annotation.RequestParam;
25-
import org.springframework.web.bind.annotation.RestController;
22+
import org.springframework.web.bind.annotation.*;
2623

2724
import java.util.UUID;
2825

@@ -37,17 +34,18 @@ public class VolunteerApplyQueryApiController {
3734
private final VolunteerApplyQueryUseCase volunteerApplyQueryUseCase;
3835
private final VolunteerApplyQueryFacadeUseCase volunteerApplyQueryFacadeUseCase;
3936

40-
@Operation(summary = "특정 모집글 봉사자 지원 단건 조회", description = "특정 모집글에 대한 봉사자 지원을 조회합니다.")
41-
@GetMapping("/volunteer-apply/recruit-board/{recruitBoardId}/volunteer/{volunteerId}")
42-
public ApiResponse<VolunteerApplyWithReviewStatusResponseDto> getVolunteerApplyByRecruitIdAndVolunteerId(
37+
@Secured("ROLE_VOLUNTEER")
38+
@Operation(summary = "특정 모집글 봉사 지원 단건 조회", description = "특정 모집글에 대한 봉사 지원을 조회합니다.")
39+
@GetMapping("/volunteer-apply/recruit-board/{recruitBoardId}")
40+
public ApiResponse<VolunteerApplyWithReviewStatusResponseDto> getVolunteerApplyByRecruitBoardId(
4341
@PathVariable Long recruitBoardId,
44-
@PathVariable UUID volunteerId
42+
@RoleId UUID volunteerId
4543
) {
4644
try {
4745
return ApiResponse.ok(
4846
200,
4947
volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId),
50-
"특정 모집글에 대한 봉사자 지원 단건 조회 성공"
48+
"특정 모집글에 대한 봉사 지원 단건 조회 성공"
5149
);
5250
} catch (NoSuchElementException e) {
5351
return ApiResponse.ok(210, null, "지원 내역이 없습니다.");

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

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
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.VolunteerApplyWithReviewStatusResponseDto;
65
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto;
76
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto;
7+
import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto;
88
import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase;
99
import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase;
1010
import com.somemore.global.exception.NoSuchElementException;
1111
import com.somemore.support.ControllerTestSupport;
12+
import com.somemore.support.annotation.MockUser;
1213
import com.somemore.support.annotation.WithMockCustomUser;
1314
import org.junit.jupiter.api.DisplayName;
1415
import org.junit.jupiter.api.Test;
@@ -37,12 +38,13 @@ class VolunteerApplyQueryApiControllerTest extends ControllerTestSupport {
3738
private VolunteerApplyQueryFacadeUseCase volunteerApplyQueryFacadeUseCase;
3839

3940

40-
@DisplayName("특정 모집글 봉사자 지원 단건 조회 성공 테스트")
41+
@MockUser
42+
@DisplayName("특정 모집글 봉사 지원 단건 조회 성공 테스트")
4143
@Test
42-
void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception {
44+
void getVolunteerApplyByRecruitBoardId() throws Exception {
4345
// given
4446
Long recruitBoardId = 1L;
45-
UUID volunteerId = UUID.randomUUID();
47+
UUID volunteerId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
4648

4749
VolunteerApplyWithReviewStatusResponseDto response = VolunteerApplyWithReviewStatusResponseDto.builder()
4850
.id(1L)
@@ -52,40 +54,36 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception {
5254
.attended(false)
5355
.build();
5456

55-
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
56-
volunteerId))
57+
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId))
5758
.willReturn(response);
5859

5960
// when & then
60-
mockMvc.perform(
61-
get("/api/volunteer-apply/recruit-board/{recruitBoardId}/volunteer/{volunteerId}",
62-
recruitBoardId, volunteerId)
63-
.accept(APPLICATION_JSON))
61+
mockMvc.perform(get("/api/volunteer-apply/recruit-board/{recruitBoardId}", recruitBoardId)
62+
.accept(APPLICATION_JSON))
6463
.andExpect(status().isOk())
6564
.andExpect(jsonPath("$.code").value(200))
66-
.andExpect(jsonPath("$.message").value("특정 모집글에 대한 봉사자 지원 단건 조회 성공"))
65+
.andExpect(jsonPath("$.message").value("특정 모집글에 대한 봉사 지원 단건 조회 성공"))
6766
.andExpect(jsonPath("$.data.id").value(1))
6867
.andExpect(jsonPath("$.data.volunteer_id").value(volunteerId.toString()))
6968
.andExpect(jsonPath("$.data.recruit_board_id").value(recruitBoardId))
7069
.andExpect(jsonPath("$.data.status").value("WAITING"))
7170
.andExpect(jsonPath("$.data.attended").value(false));
7271
}
7372

73+
@MockUser
7474
@DisplayName("특정 모집글 봉사자 지원 단건 조회 성공 테스트 - 지원 내역이 없는 경우")
7575
@Test
76-
void getVolunteerApplyByRecruitIdAndVolunteerIdWhenDoesNotExist() throws Exception {
76+
void getVolunteerApplyByRecruitBoardIdWhenDoesNotExist() throws Exception {
7777
// given
7878
Long recruitBoardId = 1L;
79-
UUID volunteerId = UUID.randomUUID();
79+
UUID volunteerId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000");
8080

81-
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId,
82-
volunteerId))
81+
given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId))
8382
.willThrow(new NoSuchElementException(NOT_EXISTS_VOLUNTEER_APPLY));
8483

8584
// when & then
8685
mockMvc.perform(
87-
get("/api/volunteer-apply/recruit-board/{recruitBoardId}/volunteer/{volunteerId}",
88-
recruitBoardId, volunteerId)
86+
get("/api/volunteer-apply/recruit-board/{recruitBoardId}", recruitBoardId)
8987
.accept(APPLICATION_JSON))
9088
.andExpect(status().isOk())
9189
.andExpect(jsonPath("$.code").value(210))

0 commit comments

Comments
 (0)