diff --git a/backend/src/main/java/corea/auth/dto/GithubPullRequestReview.java b/backend/src/main/java/corea/auth/dto/GithubPullRequestReview.java index 731b4f458..86e4ba855 100644 --- a/backend/src/main/java/corea/auth/dto/GithubPullRequestReview.java +++ b/backend/src/main/java/corea/auth/dto/GithubPullRequestReview.java @@ -12,5 +12,8 @@ public record GithubPullRequestReview( @JsonProperty("html_url") String html_url -){ +) { + public boolean isEqualGithubUserId(String githubUserId) { + return user.id().equals(githubUserId); + } } diff --git a/backend/src/main/java/corea/auth/service/GithubOAuthProvider.java b/backend/src/main/java/corea/auth/service/GithubOAuthProvider.java index cfb250561..b7f1aa482 100644 --- a/backend/src/main/java/corea/auth/service/GithubOAuthProvider.java +++ b/backend/src/main/java/corea/auth/service/GithubOAuthProvider.java @@ -1,8 +1,8 @@ package corea.auth.service; -import corea.auth.dto.GithubPullRequestReview; import corea.auth.dto.GithubUserInfo; import corea.auth.infrastructure.GithubOAuthClient; +import corea.room.domain.PullRequestReviews; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -17,7 +17,7 @@ public GithubUserInfo getUserInfo(String code) { return githubOAuthClient.getUserInfo(accessToken); } - public GithubPullRequestReview[] getPullRequestReview(String prLink) { - return githubOAuthClient.getReviewLink(prLink); + public PullRequestReviews getPullRequestReview(String prLink) { + return new PullRequestReviews(githubOAuthClient.getReviewLink(prLink)); } } diff --git a/backend/src/main/java/corea/exception/ExceptionType.java b/backend/src/main/java/corea/exception/ExceptionType.java index f3ededd11..8e2110580 100644 --- a/backend/src/main/java/corea/exception/ExceptionType.java +++ b/backend/src/main/java/corea/exception/ExceptionType.java @@ -17,6 +17,8 @@ public enum ExceptionType { INVALID_CALCULATION_FORMULA(HttpStatus.BAD_REQUEST, "잘못된 계산식입니다."), INVALID_VALUE(HttpStatus.BAD_REQUEST, "올바르지 않은 값입니다."), INVALID_RECRUITMENT_DEADLINE(HttpStatus.BAD_REQUEST, "올바르지 않은 모집 마감 시간입니다."), + NOT_EXIST_GITHUB_REVIEW(HttpStatus.BAD_REQUEST, "깃허브 리뷰가 존재하지 않습니다."), + INVALID_REVIEW_DEADLINE(HttpStatus.BAD_REQUEST, "올바르지 않은 리뷰 마감 시간입니다."), INVALID_PULL_REQUEST_URL(HttpStatus.BAD_REQUEST, "올바르지 않은 풀 리퀘스트 주소입니다."), diff --git a/backend/src/main/java/corea/review/service/ReviewService.java b/backend/src/main/java/corea/review/service/ReviewService.java index 35673305e..90dcaa93a 100644 --- a/backend/src/main/java/corea/review/service/ReviewService.java +++ b/backend/src/main/java/corea/review/service/ReviewService.java @@ -8,6 +8,7 @@ import corea.matching.repository.MatchResultRepository; import corea.member.domain.Member; import corea.member.repository.MemberRepository; +import corea.room.domain.PullRequestReviews; import lombok.RequiredArgsConstructor; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -39,18 +40,14 @@ public void completeReview(long roomId, long reviewerId, long revieweeId) { private void updateReviewLink(MatchResult matchResult, long reviewerId) { Member reviewer = memberRepository.findById(reviewerId) .orElseThrow(() -> new CoreaException(ExceptionType.MEMBER_NOT_FOUND, String.format("%d에 해당하는 멤버가 없습니다.", reviewerId))); - String userName = reviewer.getUsername(); - String newReviewLink = findReviewLink(userName, matchResult.getPrLink()); + String githubUserId = reviewer.getGithubUserId(); + String newReviewLink = findReviewLink(githubUserId, matchResult.getPrLink()); matchResult.updateReviewLink(newReviewLink); } - private String findReviewLink(String userName, String prLink) { - GithubPullRequestReview[] githubPullRequestReviews = githubOAuthProvider.getPullRequestReview(prLink); - return Stream.of(githubPullRequestReviews) - .filter(review -> review.user().login().equals(userName)) - .findFirst() - .map(GithubPullRequestReview::html_url) - .orElse(prLink); + private String findReviewLink(String githubUserId, String prLink) { + PullRequestReviews pullRequestReviews = githubOAuthProvider.getPullRequestReview(prLink); + return pullRequestReviews.getReviewUrl(githubUserId); } private MatchResult getMatchResult(long roomId, long reviewerId, long revieweeId) { diff --git a/backend/src/main/java/corea/room/domain/PullRequestReviews.java b/backend/src/main/java/corea/room/domain/PullRequestReviews.java new file mode 100644 index 000000000..35003c44d --- /dev/null +++ b/backend/src/main/java/corea/room/domain/PullRequestReviews.java @@ -0,0 +1,17 @@ +package corea.room.domain; + +import corea.auth.dto.GithubPullRequestReview; +import corea.exception.CoreaException; +import corea.exception.ExceptionType; + +import java.util.Arrays; + +public record PullRequestReviews(GithubPullRequestReview[] pullRequestReviews) { + public String getReviewUrl(String githubUserId) { + return Arrays.stream(pullRequestReviews) + .filter(githubPullRequestReview -> githubPullRequestReview.isEqualGithubUserId(githubUserId)) + .findFirst() + .map(GithubPullRequestReview::html_url) + .orElseThrow(() -> new CoreaException(ExceptionType.NOT_EXIST_GITHUB_REVIEW)); + } +} diff --git a/backend/src/test/java/corea/bdd/MatchingGiven.java b/backend/src/test/java/corea/bdd/MatchingGiven.java new file mode 100644 index 000000000..22f652af7 --- /dev/null +++ b/backend/src/test/java/corea/bdd/MatchingGiven.java @@ -0,0 +1,27 @@ +package corea.bdd; + +import corea.matching.dto.MatchResultResponse; +import corea.matching.dto.MatchResultResponses; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import java.util.List; + +public class MatchingGiven { + public static void 매칭(String accessToken, long roomId) { + //@formatter:off + RestAssured.given().auth().oauth2(accessToken).contentType(ContentType.JSON) + .when().post("/rooms/"+roomId+"/matching") + .then().assertThat().statusCode(200); + //@formatter:on + } + + public static List 리뷰이_목록_조회(String accessToken, long roomId) { + //@formatter:off + MatchResultResponses responses = RestAssured.given().auth().oauth2(accessToken).contentType(ContentType.JSON) + .when().get("/rooms/"+roomId+"/reviewees") + .then().assertThat().statusCode(200).extract().as(MatchResultResponses.class); + //@formatter:on + return responses.matchResultResponses(); + } +} diff --git a/backend/src/test/java/corea/bdd/MemberGiven.java b/backend/src/test/java/corea/bdd/MemberGiven.java new file mode 100644 index 000000000..e12c89d00 --- /dev/null +++ b/backend/src/test/java/corea/bdd/MemberGiven.java @@ -0,0 +1,29 @@ +package corea.bdd; + +import corea.auth.dto.GithubUserInfo; +import corea.auth.dto.LoginRequest; +import corea.auth.service.GithubOAuthProvider; +import corea.member.domain.Member; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.mockito.Mockito; + +public class MemberGiven { + + public static String 멤버_로그인(GithubOAuthProvider githubOAuthProvider, Member member) { + String mockingCode = member.getGithubUserId(); + Mockito.when(githubOAuthProvider.getUserInfo(mockingCode)) + .thenReturn(new GithubUserInfo( + member.getUsername(), + member.getName(), + member.getThumbnailUrl(), + member.getEmail(), + member.getGithubUserId() + )); + //@formatter:off + return RestAssured.given().body(new LoginRequest(mockingCode)).contentType(ContentType.JSON) + .when().post("/login") + .then().statusCode(200).extract().header("Authorization"); + //@formatter:on + } +} diff --git a/backend/src/test/java/corea/bdd/ParticipationGiven.java b/backend/src/test/java/corea/bdd/ParticipationGiven.java new file mode 100644 index 000000000..b3f6e5bf0 --- /dev/null +++ b/backend/src/test/java/corea/bdd/ParticipationGiven.java @@ -0,0 +1,15 @@ +package corea.bdd; + +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +public class ParticipationGiven { + + public static void 방_참가(String accessToken, long roomId) { + //@formatter:off + RestAssured.given().auth().oauth2(accessToken).contentType(ContentType.JSON) + .when().post("/participate/"+roomId) + .then().assertThat().statusCode(200); + //@formatter:on + } +} diff --git a/backend/src/test/java/corea/bdd/ReviewGiven.java b/backend/src/test/java/corea/bdd/ReviewGiven.java new file mode 100644 index 000000000..f0fffd85f --- /dev/null +++ b/backend/src/test/java/corea/bdd/ReviewGiven.java @@ -0,0 +1,15 @@ +package corea.bdd; + +import corea.review.dto.ReviewRequest; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +public class ReviewGiven { + public static void 리뷰_완료(String accessToken, long roomId, long revieweeId) { + //@formatter:off + RestAssured.given().auth().oauth2(accessToken).body(new ReviewRequest(roomId,revieweeId)).contentType(ContentType.JSON) + .when().post("/review/complete") + .then().assertThat().statusCode(200); + //@formatter:on + } +} diff --git a/backend/src/test/java/corea/bdd/RoomGiven.java b/backend/src/test/java/corea/bdd/RoomGiven.java new file mode 100644 index 000000000..31bb4e95f --- /dev/null +++ b/backend/src/test/java/corea/bdd/RoomGiven.java @@ -0,0 +1,35 @@ +package corea.bdd; + +import corea.room.domain.RoomClassification; +import corea.room.dto.RoomCreateRequest; +import corea.room.dto.RoomResponse; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; + +import java.time.LocalDateTime; +import java.util.List; + +public class RoomGiven { + public static RoomResponse 방생성(String accessToken, int matchingSize) { + + LocalDateTime now = LocalDateTime.now(); + final RoomCreateRequest request = + new RoomCreateRequest( + "제목", "내용", "https://github.com/example/java-racingcar", + "https://gongu.copyright.or.kr/gongu/wrt/cmmn/wrtFileImageView.do?wrtSn=13301655&filePath=L2Rpc2sxL25ld2RhdGEvMjAyMS8yMS9DTFMxMDAwNC8xMzMwMTY1NV9XUlRfMjFfQ0xTMTAwMDRfMjAyMTEyMTNfMQ==&thumbAt=Y&thumbSe=b_tbumb&wrtTy=10004", + matchingSize, + List.of("TDD", "클린코드"), + 200, + now.plusHours(2), + now.plusDays(2), + RoomClassification.BACKEND + ); + + //@formatter:off + return RestAssured.given().auth().oauth2(accessToken).body(request).contentType(ContentType.JSON) + .when().post("/rooms") + .then().assertThat().statusCode(201).extract().as(RoomResponse.class); + //@formatter:on + } + +} diff --git a/backend/src/test/java/corea/feedback/controller/SocialFeedbackFeedbackControllerTest.java b/backend/src/test/java/corea/feedback/controller/SocialFeedbackFeedbackControllerTest.java index 483ce594c..fe397945d 100644 --- a/backend/src/test/java/corea/feedback/controller/SocialFeedbackFeedbackControllerTest.java +++ b/backend/src/test/java/corea/feedback/controller/SocialFeedbackFeedbackControllerTest.java @@ -1,68 +1,92 @@ package corea.feedback.controller; import config.ControllerTest; -import corea.auth.service.TokenService; +import corea.auth.service.GithubOAuthProvider; +import corea.bdd.MemberGiven; +import corea.bdd.RoomGiven; import corea.feedback.dto.SocialFeedbackRequest; -import corea.fixture.MatchResultFixture; import corea.fixture.MemberFixture; -import corea.fixture.RoomFixture; -import corea.matching.repository.MatchResultRepository; -import corea.member.domain.Member; -import corea.member.repository.MemberRepository; -import corea.room.domain.Room; -import corea.room.repository.RoomRepository; +import corea.matching.domain.PullRequestInfo; +import corea.matching.dto.MatchResultResponse; +import corea.matching.service.PullRequestProvider; +import corea.room.domain.PullRequestReviews; import io.restassured.RestAssured; import io.restassured.http.ContentType; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; +import org.mockito.Mockito; +import org.springframework.boot.test.mock.mockito.MockBean; +import java.time.LocalDateTime; import java.util.List; +import static corea.bdd.MatchingGiven.리뷰이_목록_조회; +import static corea.bdd.MatchingGiven.매칭; +import static corea.bdd.ParticipationGiven.방_참가; +import static corea.bdd.ReviewGiven.리뷰_완료; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; + @ControllerTest class SocialFeedbackFeedbackControllerTest { - @Autowired - private RoomRepository roomRepository; + @MockBean + private PullRequestProvider pullRequestProvider; + + @MockBean + private GithubOAuthProvider githubOAuthProvider; - @Autowired - private MemberRepository memberRepository; + @BeforeEach + void setUp() { + PullRequestInfo info = Mockito.mock(PullRequestInfo.class); + when(info.containsGithubMemberId(anyString())).thenReturn(true); + when(info.getPullrequestLinkWithGithubMemberId(anyString())).thenReturn(""); + when(pullRequestProvider.getUntilDeadline(anyString(), any(LocalDateTime.class))) + .thenReturn(info); - @Autowired - private MatchResultRepository matchResultRepository; + PullRequestReviews pullRequestReviews = Mockito.mock(PullRequestReviews.class); + when(pullRequestReviews.getReviewUrl(anyString())).thenReturn(""); - @Autowired - private TokenService tokenService; + when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(pullRequestReviews); + } @Test @DisplayName("소셜(리뷰이 -> 리뷰어)에 대한 피드백을 작성한다.") void create() { - Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - Room room = roomRepository.save(RoomFixture.ROOM_DOMAIN(manager)); - Member reviewer = memberRepository.save(MemberFixture.MEMBER_PORORO()); - Member reviewee = memberRepository.save(MemberFixture.MEMBER_YOUNGSU()); - String token = tokenService.createAccessToken(reviewee); - matchResultRepository.save(MatchResultFixture.MATCH_RESULT_DOMAIN( - room.getId(), - reviewer, - reviewee - )); + String 액세스_토큰 = MemberGiven.멤버_로그인(githubOAuthProvider, MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); + long 방번호 = RoomGiven.방생성(액세스_토큰, 2) + .id(); + + String 리뷰어_토큰 = MemberGiven.멤버_로그인(githubOAuthProvider, MemberFixture.MEMBER_PORORO()); + String 리뷰이_토큰 = MemberGiven.멤버_로그인(githubOAuthProvider, MemberFixture.MEMBER_YOUNGSU()); + + 방_참가(리뷰어_토큰, 방번호); + 방_참가(리뷰이_토큰, 방번호); + + 매칭(액세스_토큰, 방번호); + + Long 리뷰이_아이디 = 리뷰이_목록_조회(리뷰어_토큰, 방번호) + .stream() + .findAny() + .map(MatchResultResponse::userId) + .orElseThrow(); + + + 리뷰_완료(리뷰어_토큰, 방번호, 리뷰이_아이디); SocialFeedbackRequest request = new SocialFeedbackRequest( - reviewer.getId(), + 리뷰이_아이디, 4, List.of("방의 목적에 맞게 코드를 작성했어요", "코드를 이해하기 쉬웠어요"), "유용한 블로그나 아티클도 남겨주시고, \n 사소한 부분까지 잘 챙겨준게 좋았씁니다." ); - RestAssured.given() - .auth() - .oauth2(token) - .contentType(ContentType.JSON) - .body(request) - .when() - .post("/rooms/" + room.getId() + "/social/feedbacks") - .then() - .statusCode(200); + //@formatter:off + RestAssured.given().auth().oauth2(리뷰어_토큰).body(request).contentType(ContentType.JSON) + .when().post("/rooms/" + 방번호 + "/social/feedbacks") + .then().statusCode(200); + //@formatter:on } } diff --git a/backend/src/test/java/corea/review/service/ReviewServiceTest.java b/backend/src/test/java/corea/review/service/ReviewServiceTest.java index 83a876b4f..adb661e54 100644 --- a/backend/src/test/java/corea/review/service/ReviewServiceTest.java +++ b/backend/src/test/java/corea/review/service/ReviewServiceTest.java @@ -1,6 +1,7 @@ package corea.review.service; import config.ServiceTest; +import corea.auth.service.GithubOAuthProvider; import corea.exception.CoreaException; import corea.fixture.MatchResultFixture; import corea.fixture.MemberFixture; @@ -10,15 +11,21 @@ import corea.matching.repository.MatchResultRepository; import corea.member.domain.Member; import corea.member.repository.MemberRepository; +import corea.room.domain.PullRequestReviews; import corea.room.domain.Room; import corea.room.repository.RoomRepository; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.transaction.annotation.Transactional; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.when; @ServiceTest class ReviewServiceTest { @@ -35,6 +42,17 @@ class ReviewServiceTest { @Autowired private MatchResultRepository matchResultRepository; + @MockBean + private GithubOAuthProvider githubOAuthProvider; + + @BeforeEach + void setup(){ + PullRequestReviews pullRequestReviews = Mockito.mock(PullRequestReviews.class); + when(pullRequestReviews.getReviewUrl(anyString())).thenReturn(""); + + when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(pullRequestReviews); + } + @Test @Transactional @DisplayName("리뷰를 완료한다.") diff --git a/backend/src/test/java/corea/room/domain/PullRequestReviewsTest.java b/backend/src/test/java/corea/room/domain/PullRequestReviewsTest.java new file mode 100644 index 000000000..cfbfb7c24 --- /dev/null +++ b/backend/src/test/java/corea/room/domain/PullRequestReviewsTest.java @@ -0,0 +1,44 @@ +package corea.room.domain; + +import corea.auth.dto.GithubPullRequestReview; +import corea.auth.dto.GithubUserInfo; +import corea.exception.CoreaException; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +class PullRequestReviewsTest { + + private final GithubPullRequestReview[] githubPullRequestReviews = new GithubPullRequestReview[]{ + new GithubPullRequestReview("1", + new GithubUserInfo( + "youngsu5582", + "조희선", + "https://gongu.copyright.or.kr/gongu/wrt", + "corea@naver.com", + "98307410" + ), + "review_url" + ) + }; + + @Test + @DisplayName("리뷰가 존재하면, 리뷰의 URL 을 가져온다.") + void get_html_url_when_exist_review() { + PullRequestReviews pullRequestReviews = new PullRequestReviews(githubPullRequestReviews); + String reviewUrl = pullRequestReviews.getReviewUrl("98307410"); + Assertions.assertThat(reviewUrl) + .isEqualTo("review_url"); + } + + @Test + @DisplayName("리뷰가 존재하지 않는 ID 를 넣으면 예외를 발생한다.") + void throw_exception_when_review_not_exist() { + PullRequestReviews pullRequestReviews = new PullRequestReviews(githubPullRequestReviews); + assertThatThrownBy(() -> pullRequestReviews.getReviewUrl("notExist")) + .isInstanceOf(CoreaException.class); + } + +} diff --git a/backend/src/test/java/corea/scheduler/service/AutomaticUpdateServiceTest.java b/backend/src/test/java/corea/scheduler/service/AutomaticUpdateServiceTest.java index 94153ea3a..63875109f 100644 --- a/backend/src/test/java/corea/scheduler/service/AutomaticUpdateServiceTest.java +++ b/backend/src/test/java/corea/scheduler/service/AutomaticUpdateServiceTest.java @@ -16,11 +16,14 @@ import corea.member.domain.Profile; import corea.member.repository.MemberRepository; import corea.review.service.ReviewService; +import corea.room.domain.PullRequestReviews; import corea.room.dto.RoomResponse; import corea.room.service.RoomService; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; +import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.scheduling.TaskScheduler; @@ -66,12 +69,21 @@ class AutomaticUpdateServiceTest { @MockBean private GithubOAuthProvider githubOAuthProvider; + @BeforeEach + void setup(){ + PullRequestReviews pullRequestReviews = Mockito.mock(PullRequestReviews.class); + when(pullRequestReviews.getReviewUrl(anyString())).thenReturn(""); + + when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(pullRequestReviews); + } + @Test @DisplayName("리뷰 마감 시간이 되면 자동으로 상태를 변경한다.") void updateAtReviewDeadline() { Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - LocalDateTime reviewDeadline = LocalDateTime.now().plusDays(2); + LocalDateTime reviewDeadline = LocalDateTime.now() + .plusDays(2); RoomResponse response = roomService.create(manager.getId(), RoomFixture.ROOM_CREATE_REQUEST_WITH_REVIEW_DEADLINE(reviewDeadline)); when(taskScheduler.schedule(any(Runnable.class), any(Instant.class))).thenReturn(mock(ScheduledFuture.class)); @@ -83,9 +95,11 @@ void updateAtReviewDeadline() { verify(taskScheduler).schedule(runnableCaptor.capture(), timeCaptor.capture()); Instant scheduledTime = timeCaptor.getValue(); - runnableCaptor.getValue().run(); + runnableCaptor.getValue() + .run(); - assertThat(reviewDeadline.atZone(ZoneId.of("Asia/Seoul")).toInstant()).isEqualTo(scheduledTime); + assertThat(reviewDeadline.atZone(ZoneId.of("Asia/Seoul")) + .toInstant()).isEqualTo(scheduledTime); } @Test @@ -93,7 +107,8 @@ void updateAtReviewDeadline() { void cancel() { Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - LocalDateTime reviewDeadline = LocalDateTime.now().plusDays(2); + LocalDateTime reviewDeadline = LocalDateTime.now() + .plusDays(2); RoomResponse response = roomService.create(manager.getId(), RoomFixture.ROOM_CREATE_REQUEST_WITH_REVIEW_DEADLINE(reviewDeadline)); ScheduledFuture scheduledFuture = mock(ScheduledFuture.class); @@ -111,10 +126,10 @@ void cancel() { void increaseReviewCount() { Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - LocalDateTime reviewDeadline = LocalDateTime.now().plusDays(2); + LocalDateTime reviewDeadline = LocalDateTime.now() + .plusDays(2); RoomResponse response = roomService.create(manager.getId(), RoomFixture.ROOM_CREATE_REQUEST_WITH_REVIEW_DEADLINE(reviewDeadline)); - when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(new GithubPullRequestReview[0]); when(taskScheduler.schedule(any(Runnable.class), any(Instant.class))).thenReturn(mock(ScheduledFuture.class)); Member reviewer = memberRepository.save(MemberFixture.MEMBER_YOUNGSU()); @@ -128,10 +143,13 @@ void increaseReviewCount() { ArgumentCaptor timeCaptor = ArgumentCaptor.forClass(Instant.class); verify(taskScheduler).schedule(runnableCaptor.capture(), timeCaptor.capture()); - runnableCaptor.getValue().run(); + runnableCaptor.getValue() + .run(); - assertThat(reviewer.getProfile().getDeliverCount()).isEqualTo(1); - assertThat(reviewee.getProfile().getReceiveCount()).isEqualTo(1); + assertThat(reviewer.getProfile() + .getDeliverCount()).isEqualTo(1); + assertThat(reviewee.getProfile() + .getReceiveCount()).isEqualTo(1); } @Test @@ -140,10 +158,10 @@ void increaseReviewCount() { void updateDevelopFeedbackPoint() { Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - LocalDateTime reviewDeadline = LocalDateTime.now().plusDays(2); + LocalDateTime reviewDeadline = LocalDateTime.now() + .plusDays(2); RoomResponse response = roomService.create(manager.getId(), RoomFixture.ROOM_CREATE_REQUEST_WITH_REVIEW_DEADLINE(reviewDeadline)); - when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(new GithubPullRequestReview[0]); when(taskScheduler.schedule(any(Runnable.class), any(Instant.class))).thenReturn(mock(ScheduledFuture.class)); Member reviewer = memberRepository.save(MemberFixture.MEMBER_YOUNGSU()); @@ -159,7 +177,8 @@ void updateDevelopFeedbackPoint() { ArgumentCaptor timeCaptor = ArgumentCaptor.forClass(Instant.class); verify(taskScheduler).schedule(runnableCaptor.capture(), timeCaptor.capture()); - runnableCaptor.getValue().run(); + runnableCaptor.getValue() + .run(); Profile profile = reviewee.getProfile(); assertThat(profile.getFeedbackCount()).isEqualTo(1); @@ -172,10 +191,10 @@ void updateDevelopFeedbackPoint() { void updateSocialFeedbackPoint() { Member manager = memberRepository.save(MemberFixture.MEMBER_ROOM_MANAGER_JOYSON()); - LocalDateTime reviewDeadline = LocalDateTime.now().plusDays(2); + LocalDateTime reviewDeadline = LocalDateTime.now() + .plusDays(2); RoomResponse response = roomService.create(manager.getId(), RoomFixture.ROOM_CREATE_REQUEST_WITH_REVIEW_DEADLINE(reviewDeadline)); - when(githubOAuthProvider.getPullRequestReview(anyString())).thenReturn(new GithubPullRequestReview[0]); when(taskScheduler.schedule(any(Runnable.class), any(Instant.class))).thenReturn(mock(ScheduledFuture.class)); Member reviewer = memberRepository.save(MemberFixture.MEMBER_YOUNGSU()); @@ -191,7 +210,8 @@ void updateSocialFeedbackPoint() { ArgumentCaptor timeCaptor = ArgumentCaptor.forClass(Instant.class); verify(taskScheduler).schedule(runnableCaptor.capture(), timeCaptor.capture()); - runnableCaptor.getValue().run(); + runnableCaptor.getValue() + .run(); Profile profile = reviewer.getProfile(); assertThat(profile.getFeedbackCount()).isEqualTo(1);