-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 리뷰의 랭킹 점수 계산 로직 추가 * test: 리뷰 랭킹 점수 계산 관련 테스트 추가 * refactor: 리뷰 랭킹 기능 수정 * test: 리뷰 랭킹 서비스 테스트 추가 * style: import 와일드카드 제거 * refactor: 좋아요 1개 이상인 리뷰만 랭킹에 들어갈 수 있도록 수정 * refactor: 사용하지 않는 메서드 및 테스트 삭제 * test: findReviewsByFavoriteCountGreaterThanEqual 테스트 추가 * style: ReviewServiceTest 와일드카드 제거 * style: import 정렬 순서 변경 * fix: 충돌 해결
- Loading branch information
1 parent
16de45c
commit 9467d94
Showing
7 changed files
with
290 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
backend/src/test/java/com/funeat/review/domain/ReviewTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.funeat.review.domain; | ||
|
||
import static com.funeat.fixture.CategoryFixture.카테고리_간편식사_생성; | ||
import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; | ||
import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점1점_생성; | ||
import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.time.LocalDateTime; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator; | ||
import org.junit.jupiter.api.Nested; | ||
import org.junit.jupiter.api.Test; | ||
|
||
@SuppressWarnings("NonAsciiCharacters") | ||
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) | ||
class ReviewTest { | ||
|
||
@Nested | ||
class calculateRankingScore_성공_테스트 { | ||
|
||
@Test | ||
void 리뷰_좋아요_수와_리뷰_생성_시간으로_해당_리뷰의_랭킹_점수를_구할_수_있다() { | ||
// given | ||
final var member = 멤버_멤버1_생성(); | ||
final var category = 카테고리_간편식사_생성(); | ||
final var product = 상품_삼각김밥_가격1000원_평점1점_생성(category); | ||
final var favoriteCount = 4L; | ||
final var review = 리뷰_이미지test5_평점5점_재구매X_생성(member, product, favoriteCount, LocalDateTime.now().minusDays(1L)); | ||
|
||
final var expected = favoriteCount / Math.pow(2.0, 0.5); | ||
|
||
// when | ||
final var actual = review.calculateRankingScore(); | ||
|
||
// then | ||
assertThat(actual).isEqualTo(expected); | ||
} | ||
} | ||
} |
Oops, something went wrong.