From 9be248e1ae517455620376239918b5d395fdd379 Mon Sep 17 00:00:00 2001 From: Hyeonji <110809927+skylar1220@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:54:30 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20feat:=20=EB=A6=AC=EB=B7=B0=EC=97=90=20?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EC=A0=95=EB=B3=B4=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80=20(#103)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test: QuestionTestFixture 생성 * feat: 모든 리뷰 문항을 조회하는 기능 구현 * feat: 모든 키워드를 조회하는 기능 구현 * test: ReviewerGroupFixture 생성 * feat: 리뷰 생성 시 필요한 리뷰어 그룹 정보를 조회하는 기능 구현 * feat: 리뷰 생성 시 필요한 정보를 조회하는 기능 구현 * refactor: @ServiceTest 적용 * refactor: swagger 적용 * refactor: 필드명 변경 * style: 개행 추가 * refactor: 날짜 형식 변경 * test: import문 제거 * refactor: ReviewCreationResponse 패키지 변경 * refactor: readOnly 트랜잭션 적용 * fix: 리뷰어 중복 검증 임시 제거 --------- Co-authored-by: donghoony --- .../keyword/dto/response/KeywordResponse.java | 2 +- .../keyword/service/KeywordService.java | 8 +-- .../reviewme/member/domain/ReviewerGroup.java | 2 + .../member/domain/ReviewerGroupGithubIds.java | 6 +- .../ReviewCreationReviewerGroupResponse.java | 27 ++++++++ .../member/service/ReviewerGroupService.java | 16 +++++ .../reviewme/review/controller/ReviewApi.java | 10 ++- .../review/controller/ReviewController.java | 9 ++- .../review/dto/response/QuestionResponse.java | 14 ++++ .../dto/response/ReviewCreationResponse.java | 20 ++++++ .../review/service/QuestionService.java | 23 +++++++ .../review/service/ReviewService.java | 17 +++++ .../java/reviewme/fixture/QuestionFixure.java | 18 +++++ .../fixture/ReviewerGroupFixture.java | 1 + .../keyword/service/KeywordServiceTest.java | 33 ++++++++++ .../member/domain/ReviewerGroupTest.java | 65 +++++++++---------- .../service/ReviewerGroupServiceTest.java | 47 ++++++++++++++ .../review/service/QuestionServiceTest.java | 33 ++++++++++ 18 files changed, 308 insertions(+), 43 deletions(-) create mode 100644 backend/src/main/java/reviewme/member/dto/response/ReviewCreationReviewerGroupResponse.java create mode 100644 backend/src/main/java/reviewme/review/dto/response/QuestionResponse.java create mode 100644 backend/src/main/java/reviewme/review/dto/response/ReviewCreationResponse.java create mode 100644 backend/src/main/java/reviewme/review/service/QuestionService.java create mode 100644 backend/src/test/java/reviewme/fixture/QuestionFixure.java create mode 100644 backend/src/test/java/reviewme/keyword/service/KeywordServiceTest.java create mode 100644 backend/src/test/java/reviewme/member/service/ReviewerGroupServiceTest.java create mode 100644 backend/src/test/java/reviewme/review/service/QuestionServiceTest.java diff --git a/backend/src/main/java/reviewme/keyword/dto/response/KeywordResponse.java b/backend/src/main/java/reviewme/keyword/dto/response/KeywordResponse.java index 09b72a1d1..6e75a1268 100644 --- a/backend/src/main/java/reviewme/keyword/dto/response/KeywordResponse.java +++ b/backend/src/main/java/reviewme/keyword/dto/response/KeywordResponse.java @@ -9,6 +9,6 @@ public record KeywordResponse( long id, @Schema(description = "키워드명") - String detail + String content ) { } diff --git a/backend/src/main/java/reviewme/keyword/service/KeywordService.java b/backend/src/main/java/reviewme/keyword/service/KeywordService.java index 9341d0b6a..f971f5127 100644 --- a/backend/src/main/java/reviewme/keyword/service/KeywordService.java +++ b/backend/src/main/java/reviewme/keyword/service/KeywordService.java @@ -3,8 +3,8 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import reviewme.keyword.dto.response.KeywordResponse; -import reviewme.keyword.dto.response.KeywordsResponse; import reviewme.keyword.repository.KeywordRepository; @Service @@ -13,11 +13,11 @@ public class KeywordService { private final KeywordRepository keywordRepository; - public KeywordsResponse findAllKeywords() { - List responses = keywordRepository.findAll() + @Transactional(readOnly = true) + public List findAllKeywords() { + return keywordRepository.findAll() .stream() .map(keyword -> new KeywordResponse(keyword.getId(), keyword.getContent())) .toList(); - return new KeywordsResponse(responses); } } diff --git a/backend/src/main/java/reviewme/member/domain/ReviewerGroup.java b/backend/src/main/java/reviewme/member/domain/ReviewerGroup.java index 60207d593..b1fcb948e 100644 --- a/backend/src/main/java/reviewme/member/domain/ReviewerGroup.java +++ b/backend/src/main/java/reviewme/member/domain/ReviewerGroup.java @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.List; import lombok.AccessLevel; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.NoArgsConstructor; import reviewme.member.domain.exception.InvalidDescriptionLengthException; @@ -29,6 +30,7 @@ @Entity @Table(name = "reviewer_group") @NoArgsConstructor(access = AccessLevel.PROTECTED) +@EqualsAndHashCode(of = "id") @Getter public class ReviewerGroup { diff --git a/backend/src/main/java/reviewme/member/domain/ReviewerGroupGithubIds.java b/backend/src/main/java/reviewme/member/domain/ReviewerGroupGithubIds.java index 43b9adfc0..fd00922be 100644 --- a/backend/src/main/java/reviewme/member/domain/ReviewerGroupGithubIds.java +++ b/backend/src/main/java/reviewme/member/domain/ReviewerGroupGithubIds.java @@ -25,9 +25,9 @@ public ReviewerGroupGithubIds(ReviewerGroup reviewerGroup, List github Set reviewers = githubIds.stream() .map(githubId -> new GithubIdReviewerGroup(githubId, reviewerGroup)) .collect(Collectors.toSet()); - if (reviewers.size() != githubIds.size()) { - throw new DuplicateReviewerException(); - } +// if (reviewers.size() != githubIds.size()) { +// throw new DuplicateReviewerException(); +// } this.reviewerGithubIds = reviewers; } diff --git a/backend/src/main/java/reviewme/member/dto/response/ReviewCreationReviewerGroupResponse.java b/backend/src/main/java/reviewme/member/dto/response/ReviewCreationReviewerGroupResponse.java new file mode 100644 index 000000000..7c902532a --- /dev/null +++ b/backend/src/main/java/reviewme/member/dto/response/ReviewCreationReviewerGroupResponse.java @@ -0,0 +1,27 @@ +package reviewme.member.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; + +@Schema(description = "리뷰 생성 시 필요한 리뷰어 그룹 응답") +public record ReviewCreationReviewerGroupResponse( + + @Schema(description = "리뷰어 그룹 아이디") + long id, + + @Schema(description = "리뷰 그룹 이름 (레포지토리명)") + String name, + + @Schema(description = "그룹 소개") + String description, + + @Schema(description = "리뷰 작성 기한") + LocalDateTime deadline, + + @Schema(description = "썸네일 URL") + String thumbnailUrl, + + @Schema(description = "리뷰이") + MemberResponse reviewee +) { +} diff --git a/backend/src/main/java/reviewme/member/service/ReviewerGroupService.java b/backend/src/main/java/reviewme/member/service/ReviewerGroupService.java index 10ec31a97..ff848a75b 100644 --- a/backend/src/main/java/reviewme/member/service/ReviewerGroupService.java +++ b/backend/src/main/java/reviewme/member/service/ReviewerGroupService.java @@ -2,11 +2,13 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import reviewme.member.domain.Member; import reviewme.member.domain.ReviewerGroup; import reviewme.member.dto.response.MemberResponse; import reviewme.member.dto.response.ReviewerGroupResponse; import reviewme.member.repository.ReviewerGroupRepository; +import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; @Service @RequiredArgsConstructor @@ -24,4 +26,18 @@ public ReviewerGroupResponse findReviewerGroup(long reviewerGroupId) { new MemberResponse(reviewee.getId(), reviewee.getName()) ); } + + @Transactional(readOnly = true) + public ReviewCreationReviewerGroupResponse findReviewCreationReviewerGroup(long reviewerGroupId) { + ReviewerGroup reviewerGroup = reviewerGroupRepository.getReviewerGroupById(reviewerGroupId); + Member reviewee = reviewerGroup.getReviewee(); + return new ReviewCreationReviewerGroupResponse( + reviewerGroup.getId(), + reviewerGroup.getGroupName(), + reviewerGroup.getDescription(), + reviewerGroup.getDeadline(), + reviewerGroup.getThumbnailUrl(), + new MemberResponse(reviewee.getId(), reviewee.getName()) + ); + } } diff --git a/backend/src/main/java/reviewme/review/controller/ReviewApi.java b/backend/src/main/java/reviewme/review/controller/ReviewApi.java index ea992c334..1acfa9bf3 100644 --- a/backend/src/main/java/reviewme/review/controller/ReviewApi.java +++ b/backend/src/main/java/reviewme/review/controller/ReviewApi.java @@ -6,6 +6,8 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import reviewme.review.dto.response.ReviewCreationResponse; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewDetailResponse; @@ -23,5 +25,11 @@ public interface ReviewApi { summary = "리뷰 조회", description = "단일 리뷰를 조회한다." ) - ResponseEntity findReview(@PathVariable long id); + ResponseEntity findReview(@PathVariable long id, @RequestParam long memberId); + + @Operation( + summary = "리뷰 생성 시 필요한 정보 조회", + description = "리뷰 생성 시 필요한 정보를 조회한다." + ) + ResponseEntity findReviewCreationSetup(@RequestParam long reviewerGroupId); } diff --git a/backend/src/main/java/reviewme/review/controller/ReviewController.java b/backend/src/main/java/reviewme/review/controller/ReviewController.java index 955492d8c..77685df1c 100644 --- a/backend/src/main/java/reviewme/review/controller/ReviewController.java +++ b/backend/src/main/java/reviewme/review/controller/ReviewController.java @@ -10,13 +10,14 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import reviewme.review.dto.response.ReviewCreationResponse; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewDetailResponse; import reviewme.review.service.ReviewService; @RestController @RequiredArgsConstructor -public class ReviewController { +public class ReviewController implements ReviewApi{ private final ReviewService reviewService; @@ -32,4 +33,10 @@ public ResponseEntity findReview(@PathVariable long id, ReviewDetailResponse response = reviewService.findReview(id, memberId); return ResponseEntity.ok(response); } + + @GetMapping("/reviews/write") + public ResponseEntity findReviewCreationSetup(@RequestParam long reviewerGroupId) { + ReviewCreationResponse response = reviewService.findReviewCreationSetup(reviewerGroupId); + return ResponseEntity.ok(response); + } } diff --git a/backend/src/main/java/reviewme/review/dto/response/QuestionResponse.java b/backend/src/main/java/reviewme/review/dto/response/QuestionResponse.java new file mode 100644 index 000000000..57a801643 --- /dev/null +++ b/backend/src/main/java/reviewme/review/dto/response/QuestionResponse.java @@ -0,0 +1,14 @@ +package reviewme.review.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "리뷰 문항 응답") +public record QuestionResponse( + + @Schema(description = "리뷰 문항 ID") + long id, + + @Schema(description = "리뷰 문항") + String content +) { +} diff --git a/backend/src/main/java/reviewme/review/dto/response/ReviewCreationResponse.java b/backend/src/main/java/reviewme/review/dto/response/ReviewCreationResponse.java new file mode 100644 index 000000000..cba063dfd --- /dev/null +++ b/backend/src/main/java/reviewme/review/dto/response/ReviewCreationResponse.java @@ -0,0 +1,20 @@ +package reviewme.review.dto.response; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; +import reviewme.keyword.dto.response.KeywordResponse; +import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; + +@Schema(description = "리뷰 생성 시 필요한 정보 응답") +public record ReviewCreationResponse( + + @Schema(description = "리뷰어 그룹") + ReviewCreationReviewerGroupResponse reviewerGroup, + + @Schema(description = "리뷰 문항 목록") + List questions, + + @Schema(description = "키워드 목록") + List keywords +) { +} diff --git a/backend/src/main/java/reviewme/review/service/QuestionService.java b/backend/src/main/java/reviewme/review/service/QuestionService.java new file mode 100644 index 000000000..41d482ee7 --- /dev/null +++ b/backend/src/main/java/reviewme/review/service/QuestionService.java @@ -0,0 +1,23 @@ +package reviewme.review.service; + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import reviewme.review.dto.response.QuestionResponse; +import reviewme.review.repository.QuestionRepository; + +@Service +@RequiredArgsConstructor +public class QuestionService { + + private final QuestionRepository questionRepository; + + @Transactional(readOnly = true) + public List findAllQuestions() { + return questionRepository.findAll() + .stream() + .map(question -> new QuestionResponse(question.getId(), question.getContent())) + .toList(); + } +} diff --git a/backend/src/main/java/reviewme/review/service/ReviewService.java b/backend/src/main/java/reviewme/review/service/ReviewService.java index 1e3167ee8..03fc236c1 100644 --- a/backend/src/main/java/reviewme/review/service/ReviewService.java +++ b/backend/src/main/java/reviewme/review/service/ReviewService.java @@ -7,14 +7,20 @@ import org.springframework.transaction.annotation.Transactional; import reviewme.keyword.domain.Keyword; import reviewme.keyword.domain.Keywords; +import reviewme.keyword.dto.response.KeywordResponse; import reviewme.keyword.repository.KeywordRepository; +import reviewme.keyword.service.KeywordService; import reviewme.member.domain.Member; import reviewme.member.domain.ReviewerGroup; import reviewme.member.repository.MemberRepository; import reviewme.member.repository.ReviewerGroupRepository; +import reviewme.member.service.ReviewerGroupService; import reviewme.review.domain.Question; import reviewme.review.domain.Review; import reviewme.review.domain.ReviewContent; +import reviewme.review.dto.response.ReviewCreationResponse; +import reviewme.review.dto.response.QuestionResponse; +import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; import reviewme.review.dto.request.CreateReviewRequest; import reviewme.review.dto.response.ReviewDetailResponse; import reviewme.review.dto.response.ReviewDetailReviewContentResponse; @@ -28,6 +34,9 @@ @RequiredArgsConstructor public class ReviewService { + private final ReviewerGroupService reviewerGroupService; + private final KeywordService keywordService; + private final QuestionService questionService; private final ReviewRepository reviewRepository; private final MemberRepository memberRepository; private final ReviewerGroupRepository reviewerGroupRepository; @@ -100,4 +109,12 @@ public ReviewDetailResponse findReview(long reviewId, long memberId) { keywordContents ); } + + @Transactional(readOnly = true) + public ReviewCreationResponse findReviewCreationSetup(long reviewerGroupId) { + ReviewCreationReviewerGroupResponse reviewerGroup = reviewerGroupService.findReviewCreationReviewerGroup(reviewerGroupId); + List questions = questionService.findAllQuestions(); + List keywords = keywordService.findAllKeywords(); + return new ReviewCreationResponse(reviewerGroup, questions, keywords); + } } diff --git a/backend/src/test/java/reviewme/fixture/QuestionFixure.java b/backend/src/test/java/reviewme/fixture/QuestionFixure.java new file mode 100644 index 000000000..cfcba7b27 --- /dev/null +++ b/backend/src/test/java/reviewme/fixture/QuestionFixure.java @@ -0,0 +1,18 @@ +package reviewme.fixture; + +import reviewme.review.domain.Question; + +public enum QuestionFixure { + + 소프트스킬이_어떤가요, + 기술역량이_어떤가요, + ; + + public Question create() { + return new Question(replaceUnderscores()); + } + + private String replaceUnderscores() { + return name().replace("_", " "); + } +} diff --git a/backend/src/test/java/reviewme/fixture/ReviewerGroupFixture.java b/backend/src/test/java/reviewme/fixture/ReviewerGroupFixture.java index ff4661051..08b35c72c 100644 --- a/backend/src/test/java/reviewme/fixture/ReviewerGroupFixture.java +++ b/backend/src/test/java/reviewme/fixture/ReviewerGroupFixture.java @@ -12,6 +12,7 @@ @Getter public enum ReviewerGroupFixture { + 리뷰_그룹("리뷰 그룹", "그룹 설명", LocalDateTime.of(2024, 1, 1, 12, 0)), 데드라인_남은_그룹("데드라인 이전 그룹", "설명", LocalDateTime.now().plusDays(1)), 데드라인_지난_그룹("데드라인 지난 그룹", "설명", LocalDateTime.now().minusDays(1)), ; diff --git a/backend/src/test/java/reviewme/keyword/service/KeywordServiceTest.java b/backend/src/test/java/reviewme/keyword/service/KeywordServiceTest.java new file mode 100644 index 000000000..55f1e9417 --- /dev/null +++ b/backend/src/test/java/reviewme/keyword/service/KeywordServiceTest.java @@ -0,0 +1,33 @@ +package reviewme.keyword.service; + +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import reviewme.fixture.KeywordFixture; +import reviewme.keyword.dto.response.KeywordResponse; +import reviewme.keyword.repository.KeywordRepository; +import reviewme.support.ServiceTest; + +@ServiceTest +class KeywordServiceTest { + + @Autowired + KeywordService keywordService; + + @Autowired + KeywordRepository keywordRepository; + + @Test + void 모든_키워드를_조회한다() { + // given + keywordRepository.save(KeywordFixture.회의를_이끌어요.create()); + + // when + List keywords = keywordService.findAllKeywords(); + + // then + assertThat(keywords).hasSize(1); + } +} diff --git a/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java b/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java index 006e39cf5..e26e865b0 100644 --- a/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java +++ b/backend/src/test/java/reviewme/member/domain/ReviewerGroupTest.java @@ -10,7 +10,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import reviewme.member.domain.exception.DuplicateReviewerException; import reviewme.member.domain.exception.EmptyReviewerException; import reviewme.member.domain.exception.InvalidDescriptionLengthException; import reviewme.member.domain.exception.InvalidGroupNameLengthException; @@ -88,36 +87,36 @@ class ReviewerGroupTest { .isInstanceOf(EmptyReviewerException.class); } - @Test - void 리뷰어를_중복으로_가지게_그룹을_생성할_수_없다() { - // given - Member reviewer = 회원_산초.create(); - Member reviewee = 회원_커비.create(); - String groupName = "Group"; - String description = "Description"; - LocalDateTime deadline = LocalDateTime.now().plusDays(1); - List reviewerGithubIds = List.of(reviewer.getGithubId(), reviewer.getGithubId()); - - // when, then - assertThatThrownBy(() -> new ReviewerGroup(reviewee, reviewerGithubIds, groupName, description, deadline)) - .isInstanceOf(DuplicateReviewerException.class); - } - - @Test - void 리뷰어를_중복으로_추가할_수_없다() { - // given - Member reviewer = 회원_커비.create(); - Member reviewee = 회원_산초.create(); - - String groupName = "Group"; - String description = "Description"; - LocalDateTime deadline = LocalDateTime.now().plusDays(1); - List reviewerGithubIds = List.of(reviewer.getGithubId()); - ReviewerGroup reviewerGroup = new ReviewerGroup(reviewee, reviewerGithubIds, groupName, description, deadline); - GithubIdReviewerGroup githubIdReviewerGroup = new GithubIdReviewerGroup(reviewee.getGithubId(), reviewerGroup); - - // when, then - assertThatThrownBy(() -> reviewerGroup.addReviewerGithubId(githubIdReviewerGroup)) - .isInstanceOf(DuplicateReviewerException.class); - } +// @Test +// void 리뷰어를_중복으로_가지게_그룹을_생성할_수_없다() { +// // given +// Member reviewer = 회원_산초.create(); +// Member reviewee = 회원_커비.create(); +// String groupName = "Group"; +// String description = "Description"; +// LocalDateTime deadline = LocalDateTime.now().plusDays(1); +// List reviewerGithubIds = List.of(reviewer.getGithubId(), reviewer.getGithubId()); +// +// // when, then +// assertThatThrownBy(() -> new ReviewerGroup(reviewee, reviewerGithubIds, groupName, description, deadline)) +// .isInstanceOf(DuplicateReviewerException.class); +// } + +// @Test +// void 리뷰어를_중복으로_추가할_수_없다() { +// // given +// Member reviewer = 회원_커비.create(); +// Member reviewee = 회원_산초.create(); +// +// String groupName = "Group"; +// String description = "Description"; +// LocalDateTime deadline = LocalDateTime.now().plusDays(1); +// List reviewerGithubIds = List.of(reviewer.getGithubId()); +// ReviewerGroup reviewerGroup = new ReviewerGroup(reviewee, reviewerGithubIds, groupName, description, deadline); +// GithubIdReviewerGroup githubIdReviewerGroup = new GithubIdReviewerGroup(reviewee.getGithubId(), reviewerGroup); +// +// // when, then +// assertThatThrownBy(() -> reviewerGroup.addReviewerGithubId(githubIdReviewerGroup)) +// .isInstanceOf(DuplicateReviewerException.class); +// } } diff --git a/backend/src/test/java/reviewme/member/service/ReviewerGroupServiceTest.java b/backend/src/test/java/reviewme/member/service/ReviewerGroupServiceTest.java new file mode 100644 index 000000000..4b3dfbe8b --- /dev/null +++ b/backend/src/test/java/reviewme/member/service/ReviewerGroupServiceTest.java @@ -0,0 +1,47 @@ +package reviewme.member.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertAll; +import static reviewme.fixture.ReviewerGroupFixture.리뷰_그룹; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import reviewme.member.domain.GithubId; +import reviewme.member.domain.Member; +import reviewme.member.domain.ReviewerGroup; +import reviewme.member.dto.response.ReviewCreationReviewerGroupResponse; +import reviewme.member.repository.MemberRepository; +import reviewme.member.repository.ReviewerGroupRepository; +import reviewme.support.ServiceTest; + +@ServiceTest +class ReviewerGroupServiceTest { + + @Autowired + ReviewerGroupService reviewerGroupService; + + @Autowired + ReviewerGroupRepository reviewerGroupRepository; + + @Autowired + MemberRepository memberRepository; + + @Test + void 리뷰_생성_시_필요한_리뷰어_그룹_정보를_조회한다() { + // given + Member reviewee = memberRepository.save(new Member("산초", 1)); + List reviewergithubIds = List.of(new GithubId(2), new GithubId(3)); + ReviewerGroup reviewerGroup = reviewerGroupRepository.save(리뷰_그룹.create(reviewee, reviewergithubIds)); + + // when + ReviewCreationReviewerGroupResponse actual = reviewerGroupService.findReviewCreationReviewerGroup( + reviewerGroup.getId()); + + // then + assertAll( + () -> assertThat(actual.id()).isEqualTo(reviewerGroup.getId()), + () -> assertThat(actual.reviewee().id()).isEqualTo(reviewee.getId()) + ); + } +} diff --git a/backend/src/test/java/reviewme/review/service/QuestionServiceTest.java b/backend/src/test/java/reviewme/review/service/QuestionServiceTest.java new file mode 100644 index 000000000..a9c056a4b --- /dev/null +++ b/backend/src/test/java/reviewme/review/service/QuestionServiceTest.java @@ -0,0 +1,33 @@ +package reviewme.review.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static reviewme.fixture.QuestionFixure.소프트스킬이_어떤가요; + +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import reviewme.review.dto.response.QuestionResponse; +import reviewme.review.repository.QuestionRepository; +import reviewme.support.ServiceTest; + +@ServiceTest +class QuestionServiceTest { + + @Autowired + QuestionService questionService; + + @Autowired + QuestionRepository questionRepository; + + @Test + void 모든_리뷰_문항을_조회한다() { + // given + questionRepository.save(소프트스킬이_어떤가요.create()); + + // when + List questions = questionService.findAllQuestions(); + + // then + assertThat(questions).hasSize(1); + } +}