From 60bfd7365f9d331ef284e439d3e131ae67b020b9 Mon Sep 17 00:00:00 2001 From: leebs0521 Date: Tue, 7 Jan 2025 17:26:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?refactor(volunteer-apply):=20=ED=8A=B9?= =?UTF-8?q?=EC=A0=95=20=EB=AA=A8=EC=A7=91=EA=B8=80=EC=97=90=20=EB=8C=80?= =?UTF-8?q?=ED=95=9C=20=EB=B4=89=EC=82=AC=EC=9E=90=EC=9D=98=20=EC=A7=80?= =?UTF-8?q?=EC=9B=90=20=EC=A1=B0=ED=9A=8C=20=ED=95=84=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20=20-=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VolunteerApplyQueryApiController.java | 8 +-- ...teerApplyWithReviewStatusResponseDto.java} | 16 ++--- .../VolunteerApplyQueryFacadeService.java | 62 +++++++++---------- .../service/VolunteerApplyQueryService.java | 8 --- .../VolunteerApplyQueryFacadeUseCase.java | 12 ++-- .../usecase/VolunteerApplyQueryUseCase.java | 3 - 6 files changed, 48 insertions(+), 61 deletions(-) rename src/main/java/com/somemore/domains/volunteerapply/dto/response/{VolunteerApplyResponseDto.java => VolunteerApplyWithReviewStatusResponseDto.java} (73%) diff --git a/src/main/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiController.java b/src/main/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiController.java index 2a4deff85..506d941a2 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiController.java +++ b/src/main/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiController.java @@ -5,6 +5,7 @@ import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; +import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase; import com.somemore.global.auth.annotation.CurrentUser; @@ -34,19 +35,18 @@ public class VolunteerApplyQueryApiController { @Operation(summary = "특정 모집글 봉사자 지원 단건 조회", description = "특정 모집글에 대한 봉사자 지원을 조회합니다.") @GetMapping("/volunteer-apply/recruit-board/{recruitBoardId}/volunteer/{volunteerId}") - public ApiResponse getVolunteerApplyByRecruitIdAndVolunteerId( + public ApiResponse getVolunteerApplyByRecruitIdAndVolunteerId( @PathVariable Long recruitBoardId, @PathVariable UUID volunteerId ) { try { return ApiResponse.ok( 200, - volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId( - recruitBoardId, volunteerId), + volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId), "특정 모집글에 대한 봉사자 지원 단건 조회 성공" ); } catch (NoSuchElementException e) { - return ApiResponse.ok(210, "지원 내역이 없습니다."); + return ApiResponse.ok(210, null, "지원 내역이 없습니다."); } } diff --git a/src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyResponseDto.java b/src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyWithReviewStatusResponseDto.java similarity index 73% rename from src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyResponseDto.java rename to src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyWithReviewStatusResponseDto.java index 51011ab1c..fe77034b7 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyResponseDto.java +++ b/src/main/java/com/somemore/domains/volunteerapply/dto/response/VolunteerApplyWithReviewStatusResponseDto.java @@ -1,6 +1,6 @@ package com.somemore.domains.volunteerapply.dto.response; -import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; import com.somemore.domains.volunteerapply.domain.ApplyStatus; import com.somemore.domains.volunteerapply.domain.VolunteerApply; @@ -9,33 +9,35 @@ import java.util.UUID; import lombok.Builder; -@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +@JsonNaming(SnakeCaseStrategy.class) @Builder -public record VolunteerApplyResponseDto( +public record VolunteerApplyWithReviewStatusResponseDto( @Schema(description = "봉사 지원 ID", example = "1") Long id, @Schema(description = "봉사자 UUID", example = "f5a8779a-bcc9-4fc5-b8a1-7b2a383054a9") UUID volunteerId, @Schema(description = "모집글 ID", example = "101") Long recruitBoardId, - @Schema(description = "지원 상태", example = "WAITING", allowableValues = {"WAITING", - "APPROVED", "REJECTED"}) + @Schema(description = "지원 상태", example = "WAITING", allowableValues = {"WAITING", "APPROVED", "REJECTED"}) ApplyStatus status, @Schema(description = "봉사 참여 여부", example = "false") Boolean attended, + @Schema(description = "리뷰 작성 여부", example = "false") + Boolean isReviewed, @Schema(description = "지원서 생성 일시", example = "2024-11-01T12:00:00") LocalDateTime createdAt, @Schema(description = "지원서 수정 일시", example = "2024-11-01T12:30:00") LocalDateTime updatedAt ) { - public static VolunteerApplyResponseDto from(VolunteerApply volunteerApply) { - return VolunteerApplyResponseDto.builder() + public static VolunteerApplyWithReviewStatusResponseDto of(VolunteerApply volunteerApply, boolean isReviewed) { + return VolunteerApplyWithReviewStatusResponseDto.builder() .id(volunteerApply.getId()) .volunteerId(volunteerApply.getVolunteerId()) .recruitBoardId(volunteerApply.getRecruitBoardId()) .status(volunteerApply.getStatus()) .attended(volunteerApply.getAttended()) + .isReviewed(isReviewed) .createdAt(volunteerApply.getCreatedAt()) .updatedAt(volunteerApply.getUpdatedAt()) .build(); diff --git a/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeService.java b/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeService.java index dcde866d1..80e9eea25 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeService.java +++ b/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeService.java @@ -1,16 +1,18 @@ package com.somemore.domains.volunteerapply.service; import com.somemore.domains.recruitboard.domain.RecruitBoard; +import com.somemore.domains.recruitboard.service.validator.RecruitBoardValidator; import com.somemore.domains.recruitboard.usecase.RecruitBoardQueryUseCase; +import com.somemore.domains.review.usecase.ReviewQueryUseCase; import com.somemore.domains.volunteer.repository.mapper.VolunteerSimpleInfo; import com.somemore.domains.volunteer.usecase.VolunteerQueryUseCase; import com.somemore.domains.volunteerapply.domain.VolunteerApply; import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; +import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase; -import com.somemore.global.exception.BadRequestException; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Page; import org.springframework.stereotype.Service; @@ -21,8 +23,6 @@ import java.util.UUID; import java.util.stream.Collectors; -import static com.somemore.global.exception.ExceptionMessage.UNAUTHORIZED_RECRUIT_BOARD; - @RequiredArgsConstructor @Transactional(readOnly = true) @Service @@ -31,52 +31,49 @@ public class VolunteerApplyQueryFacadeService implements VolunteerApplyQueryFaca private final VolunteerApplyQueryUseCase volunteerApplyQueryUseCase; private final RecruitBoardQueryUseCase recruitBoardQueryUseCase; private final VolunteerQueryUseCase volunteerQueryUseCase; + private final ReviewQueryUseCase reviewQueryUseCase; + private final RecruitBoardValidator recruitBoardValidator; + + @Override + public VolunteerApplyWithReviewStatusResponseDto getVolunteerApplyByRecruitIdAndVolunteerId(Long recruitId, UUID volunteerId) { + VolunteerApply apply = volunteerApplyQueryUseCase.getByRecruitIdAndVolunteerId(recruitId, volunteerId); + boolean isReviewed = checkIfReviewed(apply); + + return VolunteerApplyWithReviewStatusResponseDto.of(apply, isReviewed); + } @Override public Page getVolunteerAppliesByRecruitIdAndCenterId( Long recruitId, UUID centerId, VolunteerApplySearchCondition condition) { - validateAuthorization(recruitId, centerId); - - Page applies = volunteerApplyQueryUseCase.getAllByRecruitId(recruitId, - condition); + RecruitBoard recruitBoard = recruitBoardQueryUseCase.getById(recruitId); + recruitBoardValidator.validateWriter(recruitBoard, centerId); - Map volunteerMap = getVolunteerInfoMap( - applies); + Page applies = volunteerApplyQueryUseCase.getAllByRecruitId(recruitId, condition); + Map volunteerMap = getVolunteerInfoMap(applies); return applies.map( - apply -> VolunteerApplyVolunteerInfoResponseDto.of( - apply, - volunteerMap.getOrDefault(apply.getVolunteerId(), null) - )); + apply -> VolunteerApplyVolunteerInfoResponseDto.of(apply, volunteerMap.getOrDefault(apply.getVolunteerId(), null))); } @Override public Page getVolunteerAppliesByVolunteerId( UUID volunteerId, VolunteerApplySearchCondition condition) { - Page applies = volunteerApplyQueryUseCase.getAllByVolunteerId(volunteerId, - condition); - + Page applies = volunteerApplyQueryUseCase.getAllByVolunteerId(volunteerId, condition); Map boardMap = getRecruitBoardMap(applies); return applies.map( - apply -> VolunteerApplyRecruitInfoResponseDto.of( - apply, - boardMap.getOrDefault(apply.getRecruitBoardId(), null) - )); + apply -> VolunteerApplyRecruitInfoResponseDto.of(apply, boardMap.getOrDefault(apply.getRecruitBoardId(), null))); } - private void validateAuthorization(Long recruitId, UUID centerId) { - RecruitBoard recruitBoard = recruitBoardQueryUseCase.getById(recruitId); - if (recruitBoard.isWriter(centerId)) { - return; - } - - throw new BadRequestException(UNAUTHORIZED_RECRUIT_BOARD); + private boolean checkIfReviewed(VolunteerApply apply) { + return apply.isVolunteerActivityCompleted() + && reviewQueryUseCase.existsByVolunteerApplyId(apply.getId()); } private Map getRecruitBoardMap(Page applies) { - List boardIds = applies.getContent().stream().map(VolunteerApply::getRecruitBoardId) + List boardIds = applies.getContent().stream() + .map(VolunteerApply::getRecruitBoardId) .toList(); List boards = recruitBoardQueryUseCase.getAllByIds(boardIds); @@ -86,15 +83,14 @@ private Map getRecruitBoardMap(Page applies) } private Map getVolunteerInfoMap(Page applies) { - List volunteerIds = applies.getContent().stream().map(VolunteerApply::getVolunteerId) + List volunteerIds = applies.getContent().stream() + .map(VolunteerApply::getVolunteerId) .toList(); - List volunteers = volunteerQueryUseCase.getVolunteerSimpleInfosByIds( - volunteerIds); + List volunteers = volunteerQueryUseCase.getVolunteerSimpleInfosByIds(volunteerIds); return volunteers.stream() - .collect(Collectors.toMap(VolunteerSimpleInfo::id, - volunteer -> volunteer)); + .collect(Collectors.toMap(VolunteerSimpleInfo::id, volunteer -> volunteer)); } } diff --git a/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryService.java b/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryService.java index 457517a9b..7a90d7fa1 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryService.java +++ b/src/main/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryService.java @@ -2,7 +2,6 @@ import com.somemore.domains.volunteerapply.domain.VolunteerApply; import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; -import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryUseCase; @@ -46,13 +45,6 @@ public VolunteerApplySummaryResponseDto getSummaryByRecruitId(Long recruitId) { return VolunteerApplySummaryResponseDto.from(applies); } - @Override - public VolunteerApplyResponseDto getVolunteerApplyByRecruitIdAndVolunteerId(Long recruitId, UUID volunteerId) { - VolunteerApply apply = getByRecruitIdAndVolunteerId(recruitId, volunteerId); - - return VolunteerApplyResponseDto.from(apply); - } - @Override public Page getAllByRecruitId(Long recruitId, VolunteerApplySearchCondition condition) { return volunteerApplyRepository.findAllByRecruitId(recruitId, condition); diff --git a/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryFacadeUseCase.java b/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryFacadeUseCase.java index d2a7e889f..1412c0954 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryFacadeUseCase.java +++ b/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryFacadeUseCase.java @@ -2,18 +2,18 @@ import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; +import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; +import org.springframework.data.domain.Page; import java.util.UUID; -import org.springframework.data.domain.Page; public interface VolunteerApplyQueryFacadeUseCase { - Page getVolunteerAppliesByRecruitIdAndCenterId( - Long recruitId, - UUID centerId, VolunteerApplySearchCondition condition); + VolunteerApplyWithReviewStatusResponseDto getVolunteerApplyByRecruitIdAndVolunteerId(Long recruitId, UUID volunteerId); + + Page getVolunteerAppliesByRecruitIdAndCenterId(Long recruitId, UUID centerId, VolunteerApplySearchCondition condition); - Page getVolunteerAppliesByVolunteerId(UUID volunteerId, - VolunteerApplySearchCondition condition); + Page getVolunteerAppliesByVolunteerId(UUID volunteerId, VolunteerApplySearchCondition condition); } diff --git a/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryUseCase.java b/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryUseCase.java index f1c490a60..0590718b8 100644 --- a/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryUseCase.java +++ b/src/main/java/com/somemore/domains/volunteerapply/usecase/VolunteerApplyQueryUseCase.java @@ -2,7 +2,6 @@ import com.somemore.domains.volunteerapply.domain.VolunteerApply; import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; -import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; import org.springframework.data.domain.Page; @@ -17,8 +16,6 @@ public interface VolunteerApplyQueryUseCase { VolunteerApplySummaryResponseDto getSummaryByRecruitId(Long recruitId); - VolunteerApplyResponseDto getVolunteerApplyByRecruitIdAndVolunteerId(Long recruitId, UUID volunteerId); - List getVolunteerIdsByRecruitIds(List recruitIds); List getAllByIds(List ids); From fb1f847ecdf0a13cc3afeb13193432cb128ebe49 Mon Sep 17 00:00:00 2001 From: leebs0521 Date: Tue, 7 Jan 2025 17:26:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?test(volunteer-apply):=20=ED=8A=B9=EC=A0=95?= =?UTF-8?q?=20=EB=AA=A8=EC=A7=91=EA=B8=80=EC=97=90=20=EB=8C=80=ED=95=9C=20?= =?UTF-8?q?=EB=B4=89=EC=82=AC=EC=9E=90=EC=9D=98=20=EC=A7=80=EC=9B=90=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=ED=95=84=EB=93=9C=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?test=20=20-=20=EB=A6=AC=EB=B7=B0=20=EC=9E=91=EC=84=B1=20?= =?UTF-8?q?=EC=97=AC=EB=B6=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VolunteerApplyQueryApiControllerTest.java | 8 ++-- .../VolunteerApplyQueryFacadeServiceTest.java | 38 ++++++++++++++++++- .../VolunteerApplyQueryServiceTest.java | 14 ------- 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/test/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiControllerTest.java b/src/test/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiControllerTest.java index 28a323091..baeb6fc5e 100644 --- a/src/test/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiControllerTest.java +++ b/src/test/java/com/somemore/domains/volunteerapply/controller/VolunteerApplyQueryApiControllerTest.java @@ -2,7 +2,7 @@ import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; -import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; +import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; import com.somemore.domains.volunteerapply.usecase.VolunteerApplyQueryFacadeUseCase; @@ -44,7 +44,7 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception { Long recruitBoardId = 1L; UUID volunteerId = UUID.randomUUID(); - VolunteerApplyResponseDto response = VolunteerApplyResponseDto.builder() + VolunteerApplyWithReviewStatusResponseDto response = VolunteerApplyWithReviewStatusResponseDto.builder() .id(1L) .volunteerId(volunteerId) .recruitBoardId(recruitBoardId) @@ -52,7 +52,7 @@ void getVolunteerApplyByRecruitIdAndVolunteerId() throws Exception { .attended(false) .build(); - given(volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, + given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId)) .willReturn(response); @@ -78,7 +78,7 @@ void getVolunteerApplyByRecruitIdAndVolunteerIdWhenDoesNotExist() throws Excepti Long recruitBoardId = 1L; UUID volunteerId = UUID.randomUUID(); - given(volunteerApplyQueryUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, + given(volunteerApplyQueryFacadeUseCase.getVolunteerApplyByRecruitIdAndVolunteerId(recruitBoardId, volunteerId)) .willThrow(new NoSuchElementException(NOT_EXISTS_VOLUNTEER_APPLY)); diff --git a/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeServiceTest.java b/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeServiceTest.java index 7a315dc2d..3c397ef29 100644 --- a/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeServiceTest.java +++ b/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryFacadeServiceTest.java @@ -2,6 +2,8 @@ import com.somemore.domains.recruitboard.domain.RecruitBoard; import com.somemore.domains.recruitboard.repository.RecruitBoardRepository; +import com.somemore.domains.review.domain.Review; +import com.somemore.domains.review.repository.ReviewRepository; import com.somemore.domains.volunteer.domain.Volunteer; import com.somemore.domains.volunteer.domain.VolunteerDetail; import com.somemore.domains.volunteer.dto.request.VolunteerRegisterRequestDto; @@ -11,6 +13,7 @@ import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyRecruitInfoResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyVolunteerInfoResponseDto; +import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyWithReviewStatusResponseDto; import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository; import com.somemore.support.IntegrationTestSupport; import org.junit.jupiter.api.DisplayName; @@ -42,7 +45,30 @@ class VolunteerApplyQueryFacadeServiceTest extends IntegrationTestSupport { private VolunteerDetailRepository volunteerDetailRepository; @Autowired private VolunteerApplyRepository volunteerApplyRepository; + @Autowired + private ReviewRepository reviewRepository; + + @DisplayName("모집글 아이디와 봉사자 아이디로 지원 응답 값을 조회할 수 있다.") + @Test + void getVolunteerApplyByRecruitIdAndVolunteerId() { + // given + Long recruitBoardId = 1234L; + UUID volunteerId = UUID.randomUUID(); + VolunteerApply apply = createApply(volunteerId, recruitBoardId); + volunteerApplyRepository.save(apply); + + Review review = createReview(apply.getId(), volunteerId); + reviewRepository.save(review); + + // when + VolunteerApplyWithReviewStatusResponseDto dto = volunteerApplyQueryFacadeService.getVolunteerApplyByRecruitIdAndVolunteerId( + recruitBoardId, volunteerId); + // then + assertThat(dto.recruitBoardId()).isEqualTo(recruitBoardId); + assertThat(dto.volunteerId()).isEqualTo(volunteerId); + assertThat(dto.isReviewed()).isTrue(); + } @DisplayName("모집글 아이디와 기관 아이디로 필터에 맞는 지원자 간단 정보를 조회할 수 있다.") @Test @@ -108,6 +134,16 @@ void getVolunteerAppliesByVolunteerId() { assertThat(result).hasSize(3); } + private static Review createReview(Long volunteerApplyId, UUID volunteerId) { + return Review.builder() + .volunteerApplyId(volunteerApplyId) + .volunteerId(volunteerId) + .title("리뷰 제목") + .content("리뷰 내용") + .imgUrl("리뷰 이미지") + .build(); + } + private static VolunteerDetail createVolunteerDetail(UUID volunteerId) { VolunteerRegisterRequestDto volunteerRegisterRequestDto = @@ -130,7 +166,7 @@ private static VolunteerApply createApply(UUID volunteerId, Long recruitId) { .volunteerId(volunteerId) .recruitBoardId(recruitId) .status(APPROVED) - .attended(false) + .attended(true) .build(); } diff --git a/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryServiceTest.java b/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryServiceTest.java index 32db1413d..10a594ad8 100644 --- a/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryServiceTest.java +++ b/src/test/java/com/somemore/domains/volunteerapply/service/VolunteerApplyQueryServiceTest.java @@ -3,7 +3,6 @@ import com.somemore.domains.volunteerapply.domain.ApplyStatus; import com.somemore.domains.volunteerapply.domain.VolunteerApply; import com.somemore.domains.volunteerapply.dto.condition.VolunteerApplySearchCondition; -import com.somemore.domains.volunteerapply.dto.response.VolunteerApplyResponseDto; import com.somemore.domains.volunteerapply.dto.response.VolunteerApplySummaryResponseDto; import com.somemore.domains.volunteerapply.repository.VolunteerApplyRepository; import com.somemore.global.exception.NoSuchElementException; @@ -131,19 +130,6 @@ void getSummaryByRecruitBoardId() { assertThat(dto.reject()).isEqualTo(rejectCount); } - @DisplayName("모집글 아이디와 봉사자 아이디로 지원 응답 값을 조회할 수 있다.") - @Test - void getVolunteerApplyByRecruitIdAndVolunteerId() { - // given - // when - VolunteerApplyResponseDto dto = volunteerApplyQueryService.getVolunteerApplyByRecruitIdAndVolunteerId( - recruitBoardId, volunteerId); - - // then - assertThat(dto.recruitBoardId()).isEqualTo(recruitBoardId); - assertThat(dto.volunteerId()).isEqualTo(volunteerId); - } - @DisplayName("모집글 아이디로 지원 리스트를 페이징 조회할 수 있다.") @Test void getAllByRecruitId() {