From 4f5bd58d05915145ddf0d5fd9e037b5b2e09e585 Mon Sep 17 00:00:00 2001 From: Go-Jaecheol Date: Fri, 13 Oct 2023 07:54:59 +0900 Subject: [PATCH 1/5] =?UTF-8?q?refactor:=20=EC=83=81=ED=92=88=20=EB=9E=AD?= =?UTF-8?q?=ED=82=B9=20=EC=A1=B0=ED=9A=8C=20=EC=8B=9C=20=EA=B8=B0=EA=B0=84?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/application/ProductService.java | 20 +++++++++++-------- .../persistence/ProductRepository.java | 8 ++++++-- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/com/funeat/product/application/ProductService.java b/backend/src/main/java/com/funeat/product/application/ProductService.java index 0301db183..90d6d511c 100644 --- a/backend/src/main/java/com/funeat/product/application/ProductService.java +++ b/backend/src/main/java/com/funeat/product/application/ProductService.java @@ -1,8 +1,5 @@ package com.funeat.product.application; -import static com.funeat.product.exception.CategoryErrorCode.CATEGORY_NOT_FOUND; -import static com.funeat.product.exception.ProductErrorCode.PRODUCT_NOT_FOUND; - import com.funeat.common.dto.PageDto; import com.funeat.product.domain.Category; import com.funeat.product.domain.Product; @@ -30,16 +27,21 @@ import com.funeat.review.persistence.ReviewRepository; import com.funeat.review.persistence.ReviewTagRepository; import com.funeat.tag.domain.Tag; -import java.util.Comparator; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.LocalDateTime; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static com.funeat.product.exception.CategoryErrorCode.CATEGORY_NOT_FOUND; +import static com.funeat.product.exception.ProductErrorCode.PRODUCT_NOT_FOUND; + @Service @Transactional(readOnly = true) public class ProductService { @@ -101,7 +103,9 @@ public ProductResponse findProductDetail(final Long productId) { } public RankingProductsResponse getTop3Products() { - final List productsAndReviewCounts = productRepository.findAllByAverageRatingGreaterThan3(); + final LocalDateTime endDateTime = LocalDateTime.now(); + final LocalDateTime startDateTime = endDateTime.minusWeeks(2L); + final List productsAndReviewCounts = productRepository.findAllByAverageRatingGreaterThan3(startDateTime, endDateTime); final Comparator rankingScoreComparator = Comparator.comparing( (ProductReviewCountDto it) -> it.getProduct().calculateRankingScore(it.getReviewCount()) ).reversed(); diff --git a/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java b/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java index c3adc5c4b..485211b3e 100644 --- a/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java +++ b/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java @@ -4,7 +4,6 @@ import com.funeat.product.domain.Product; import com.funeat.product.dto.ProductInCategoryDto; import com.funeat.product.dto.ProductReviewCountDto; -import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -12,6 +11,9 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; +import java.time.LocalDateTime; +import java.util.List; + public interface ProductRepository extends JpaRepository, JpaSpecificationExecutor { @Query(value = "SELECT new com.funeat.product.dto.ProductInCategoryDto(p.id, p.name, p.price, p.image, p.averageRating, COUNT(r)) " @@ -36,8 +38,10 @@ Page findAllByCategoryOrderByReviewCountDesc(@Param("categ + "FROM Product p " + "LEFT JOIN Review r ON r.product.id = p.id " + "WHERE p.averageRating > 3.0 " + + "AND r.createdAt BETWEEN :startDateTime AND :endDateTime " + "GROUP BY p.id") - List findAllByAverageRatingGreaterThan3(); + List findAllByAverageRatingGreaterThan3(final LocalDateTime startDateTime, + final LocalDateTime endDateTime); @Query("SELECT p FROM Product p " + "WHERE p.name LIKE CONCAT('%', :name, '%') " From 7a85cabd10fe5d5a752cf7eeee7703c6779c3af7 Mon Sep 17 00:00:00 2001 From: Go-Jaecheol Date: Fri, 13 Oct 2023 07:55:53 +0900 Subject: [PATCH 2/5] =?UTF-8?q?test:=20=EC=83=81=ED=92=88=20=EB=9E=AD?= =?UTF-8?q?=ED=82=B9=20=EA=B4=80=EB=A0=A8=20Repository=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/funeat/review/domain/Review.java | 20 ++++-- .../com/funeat/fixture/ReviewFixture.java | 7 ++ .../persistence/ProductRepositoryTest.java | 65 ++++++++++++++----- 3 files changed, 73 insertions(+), 19 deletions(-) diff --git a/backend/src/main/java/com/funeat/review/domain/Review.java b/backend/src/main/java/com/funeat/review/domain/Review.java index 3545371e3..c94a9e998 100644 --- a/backend/src/main/java/com/funeat/review/domain/Review.java +++ b/backend/src/main/java/com/funeat/review/domain/Review.java @@ -3,10 +3,7 @@ import com.funeat.member.domain.Member; import com.funeat.member.domain.favorite.ReviewFavorite; import com.funeat.product.domain.Product; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -16,6 +13,9 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; @Entity public class Review { @@ -80,6 +80,18 @@ public Review(final Member member, final Product findProduct, final String image this.favoriteCount = favoriteCount; } + public Review(final Member member, final Product findProduct, final String image, final Long rating, + final String content, final Boolean reBuy, final Long favoriteCount, final LocalDateTime createdAt) { + this.member = member; + this.product = findProduct; + this.image = image; + this.rating = rating; + this.content = content; + this.reBuy = reBuy; + this.favoriteCount = favoriteCount; + this.createdAt = createdAt; + } + public void addFavoriteCount() { this.favoriteCount++; } diff --git a/backend/src/test/java/com/funeat/fixture/ReviewFixture.java b/backend/src/test/java/com/funeat/fixture/ReviewFixture.java index 3ae53a3c7..e5bb8216e 100644 --- a/backend/src/test/java/com/funeat/fixture/ReviewFixture.java +++ b/backend/src/test/java/com/funeat/fixture/ReviewFixture.java @@ -5,6 +5,8 @@ import com.funeat.review.domain.Review; import com.funeat.review.dto.ReviewCreateRequest; import com.funeat.review.dto.ReviewFavoriteRequest; + +import java.time.LocalDateTime; import java.util.List; @SuppressWarnings("NonAsciiCharacters") @@ -65,6 +67,11 @@ public class ReviewFixture { return new Review(member, product, "test5", 5L, "test", false, count); } + public static Review 리뷰_이미지test5_평점5점_재구매X_생성(final Member member, final Product product, final Long count, + final LocalDateTime createdAt) { + return new Review(member, product, "test5", 5L, "test", false, count, createdAt); + } + public static ReviewCreateRequest 리뷰추가요청_생성(final Long rating, final List tagIds, final String content, final Boolean rebuy) { return new ReviewCreateRequest(rating, tagIds, content, rebuy); diff --git a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java index 887958516..20c4a18a6 100644 --- a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java +++ b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java @@ -1,5 +1,15 @@ package com.funeat.product.persistence; +import com.funeat.common.RepositoryTest; +import com.funeat.product.dto.ProductInCategoryDto; +import com.funeat.product.dto.ProductReviewCountDto; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; + import static com.funeat.fixture.CategoryFixture.카테고리_간편식사_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버2_생성; @@ -28,17 +38,10 @@ import static com.funeat.fixture.ReviewFixture.리뷰_이미지test2_평점2점_재구매X_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test3_평점3점_재구매O_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test4_평점4점_재구매O_생성; -import static com.funeat.fixture.ReviewFixture.리뷰_이미지test4_평점4점_재구매X_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매O_생성; +import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; import static org.assertj.core.api.Assertions.assertThat; -import com.funeat.common.RepositoryTest; -import com.funeat.product.dto.ProductInCategoryDto; -import com.funeat.product.dto.ProductReviewCountDto; -import java.util.List; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - @SuppressWarnings("NonAsciiCharacters") class ProductRepositoryTest extends RepositoryTest { @@ -223,12 +226,12 @@ class findAllByAverageRatingGreaterThan3_성공_테스트 { final var member3 = 멤버_멤버3_생성(); 복수_멤버_저장(member1, member2, member3); - final var review1_1 = 리뷰_이미지test1_평점1점_재구매X_생성(member1, product1, 0L); - final var review1_2 = 리뷰_이미지test5_평점5점_재구매O_생성(member2, product1, 0L); - final var review2_1 = 리뷰_이미지test3_평점3점_재구매O_생성(member3, product2, 0L); - final var review2_2 = 리뷰_이미지test4_평점4점_재구매X_생성(member1, product2, 0L); - final var review2_3 = 리뷰_이미지test5_평점5점_재구매O_생성(member2, product2, 0L); - final var review3_1 = 리뷰_이미지test5_평점5점_재구매O_생성(member1, product3, 0L); + final var review1_1 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product1, 0L, LocalDateTime.now().minusDays(2L)); + final var review1_2 = 리뷰_이미지test5_평점5점_재구매X_생성(member2, product1, 0L, LocalDateTime.now().minusDays(3L)); + final var review2_1 = 리뷰_이미지test5_평점5점_재구매X_생성(member3, product2, 0L, LocalDateTime.now().minusDays(10L)); + final var review2_2 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product2, 0L, LocalDateTime.now().minusDays(1L)); + final var review2_3 = 리뷰_이미지test5_평점5점_재구매X_생성(member2, product2, 0L, LocalDateTime.now().minusDays(9L)); + final var review3_1 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product3, 0L, LocalDateTime.now().minusDays(8L)); 복수_리뷰_저장(review1_1, review1_2, review2_1, review2_2, review2_3, review3_1); final var productReviewCountDto1 = new ProductReviewCountDto(product2, 3L); @@ -236,7 +239,39 @@ class findAllByAverageRatingGreaterThan3_성공_테스트 { final var expected = List.of(productReviewCountDto1, productReviewCountDto2); // when - final var actual = productRepository.findAllByAverageRatingGreaterThan3(); + final var startDateTime = LocalDateTime.now().minusWeeks(2L); + final var endDateTime = LocalDateTime.now(); + final var actual = productRepository.findAllByAverageRatingGreaterThan3(startDateTime, endDateTime); + + // then + assertThat(actual).usingRecursiveComparison() + .isEqualTo(expected); + } + + @Test + void 기간_안에_리뷰가_존재하는_상품이_없으면_빈_리스트를_반환한다() { + // given + final var category = 카테고리_간편식사_생성(); + 단일_카테고리_저장(category); + + final var product1 = 상품_삼각김밥_가격1000원_평점3점_생성(category); + final var product2 = 상품_삼각김밥_가격2000원_평점4점_생성(category); + 복수_상품_저장(product1, product2); + + final var member1 = 멤버_멤버1_생성(); + final var member2 = 멤버_멤버2_생성(); + 복수_멤버_저장(member1, member2); + + final var review1 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product1, 0L, LocalDateTime.now().minusDays(15L)); + final var review2 = 리뷰_이미지test5_평점5점_재구매X_생성(member2, product2, 0L, LocalDateTime.now().minusWeeks(3L)); + 복수_리뷰_저장(review1, review2); + + final var expected = Collections.emptyList(); + + // when + final var startDateTime = LocalDateTime.now().minusWeeks(2L); + final var endDateTime = LocalDateTime.now(); + final var actual = productRepository.findAllByAverageRatingGreaterThan3(startDateTime, endDateTime); // then assertThat(actual).usingRecursiveComparison() From bacffa723c2ff8c180f7fc931a902935a4899031 Mon Sep 17 00:00:00 2001 From: Go-Jaecheol Date: Fri, 13 Oct 2023 07:56:19 +0900 Subject: [PATCH 3/5] =?UTF-8?q?test:=20=EC=83=81=ED=92=88=20=EB=9E=AD?= =?UTF-8?q?=ED=82=B9=20=EA=B4=80=EB=A0=A8=20=EC=84=9C=EB=B9=84=EC=8A=A4=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/ProductServiceTest.java | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java b/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java index 5aa812dc6..ab3dab05e 100644 --- a/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java +++ b/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java @@ -1,5 +1,14 @@ package com.funeat.product.application; +import com.funeat.common.ServiceTest; +import com.funeat.product.dto.RankingProductDto; +import com.funeat.product.dto.RankingProductsResponse; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.Collections; +import java.util.List; + import static com.funeat.fixture.CategoryFixture.카테고리_즉석조리_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버2_생성; @@ -22,14 +31,6 @@ import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; import static org.assertj.core.api.Assertions.assertThat; -import com.funeat.common.ServiceTest; -import com.funeat.product.dto.RankingProductDto; -import com.funeat.product.dto.RankingProductsResponse; -import java.util.Collections; -import java.util.List; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - @SuppressWarnings("NonAsciiCharacters") class ProductServiceTest extends ServiceTest { @@ -109,16 +110,16 @@ class 상품_개수에_대한_테스트 { final var review1_4 = 리뷰_이미지test3_평점3점_재구매O_생성(member1, product1, 0L); final var review2_1 = 리뷰_이미지test4_평점4점_재구매O_생성(member1, product2, 0L); final var review2_2 = 리뷰_이미지test4_평점4점_재구매O_생성(member1, product2, 0L); - final var review3_1 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product2, 0L); - final var review4_1 = 리뷰_이미지test4_평점4점_재구매X_생성(member1, product2, 0L); - final var review4_2 = 리뷰_이미지test3_평점3점_재구매X_생성(member1, product2, 0L); - final var review4_3 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product2, 0L); + final var review3_1 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product3, 0L); + final var review4_1 = 리뷰_이미지test4_평점4점_재구매X_생성(member1, product4, 0L); + final var review4_2 = 리뷰_이미지test3_평점3점_재구매X_생성(member1, product4, 0L); + final var review4_3 = 리뷰_이미지test5_평점5점_재구매X_생성(member1, product4, 0L); 복수_리뷰_저장(review1_1, review1_2, review1_3, review1_4, review2_1, review2_2, review3_1, review4_1, review4_2, review4_3); - final var rankingProductDto1 = RankingProductDto.toDto(product2); - final var rankingProductDto2 = RankingProductDto.toDto(product3); - final var rankingProductDto3 = RankingProductDto.toDto(product4); + final var rankingProductDto1 = RankingProductDto.toDto(product3); + final var rankingProductDto2 = RankingProductDto.toDto(product4); + final var rankingProductDto3 = RankingProductDto.toDto(product2); final var rankingProductDtos = List.of(rankingProductDto1, rankingProductDto2, rankingProductDto3); final var expected = RankingProductsResponse.toResponse(rankingProductDtos); From 6ed3eec01a35f94faa14e6a6f0cb745c8a97c125 Mon Sep 17 00:00:00 2001 From: Go-Jaecheol Date: Wed, 18 Oct 2023 13:20:15 +0900 Subject: [PATCH 4/5] =?UTF-8?q?style:=20import=20=EC=A0=95=EB=A0=AC=20?= =?UTF-8?q?=EC=88=9C=EC=84=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product/application/ProductService.java | 17 ++++++++--------- .../persistence/ProductRepository.java | 5 ++--- .../java/com/funeat/review/domain/Review.java | 7 +++---- .../com/funeat/fixture/ReviewFixture.java | 1 - .../application/ProductServiceTest.java | 17 ++++++++--------- .../persistence/ProductRepositoryTest.java | 19 +++++++++---------- 6 files changed, 30 insertions(+), 36 deletions(-) diff --git a/backend/src/main/java/com/funeat/product/application/ProductService.java b/backend/src/main/java/com/funeat/product/application/ProductService.java index 90d6d511c..d438fb851 100644 --- a/backend/src/main/java/com/funeat/product/application/ProductService.java +++ b/backend/src/main/java/com/funeat/product/application/ProductService.java @@ -1,5 +1,8 @@ package com.funeat.product.application; +import static com.funeat.product.exception.CategoryErrorCode.CATEGORY_NOT_FOUND; +import static com.funeat.product.exception.ProductErrorCode.PRODUCT_NOT_FOUND; + import com.funeat.common.dto.PageDto; import com.funeat.product.domain.Category; import com.funeat.product.domain.Product; @@ -27,20 +30,16 @@ import com.funeat.review.persistence.ReviewRepository; import com.funeat.review.persistence.ReviewTagRepository; import com.funeat.tag.domain.Tag; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - import java.time.LocalDateTime; import java.util.Comparator; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; - -import static com.funeat.product.exception.CategoryErrorCode.CATEGORY_NOT_FOUND; -import static com.funeat.product.exception.ProductErrorCode.PRODUCT_NOT_FOUND; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @Transactional(readOnly = true) diff --git a/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java b/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java index 485211b3e..61958130f 100644 --- a/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java +++ b/backend/src/main/java/com/funeat/product/persistence/ProductRepository.java @@ -4,6 +4,8 @@ import com.funeat.product.domain.Product; import com.funeat.product.dto.ProductInCategoryDto; import com.funeat.product.dto.ProductReviewCountDto; +import java.time.LocalDateTime; +import java.util.List; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; @@ -11,9 +13,6 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.query.Param; -import java.time.LocalDateTime; -import java.util.List; - public interface ProductRepository extends JpaRepository, JpaSpecificationExecutor { @Query(value = "SELECT new com.funeat.product.dto.ProductInCategoryDto(p.id, p.name, p.price, p.image, p.averageRating, COUNT(r)) " diff --git a/backend/src/main/java/com/funeat/review/domain/Review.java b/backend/src/main/java/com/funeat/review/domain/Review.java index c94a9e998..0b8300fb7 100644 --- a/backend/src/main/java/com/funeat/review/domain/Review.java +++ b/backend/src/main/java/com/funeat/review/domain/Review.java @@ -3,7 +3,9 @@ import com.funeat.member.domain.Member; import com.funeat.member.domain.favorite.ReviewFavorite; import com.funeat.product.domain.Product; - +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; @@ -13,9 +15,6 @@ import javax.persistence.JoinColumn; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; @Entity public class Review { diff --git a/backend/src/test/java/com/funeat/fixture/ReviewFixture.java b/backend/src/test/java/com/funeat/fixture/ReviewFixture.java index e5bb8216e..c132ec3e4 100644 --- a/backend/src/test/java/com/funeat/fixture/ReviewFixture.java +++ b/backend/src/test/java/com/funeat/fixture/ReviewFixture.java @@ -5,7 +5,6 @@ import com.funeat.review.domain.Review; import com.funeat.review.dto.ReviewCreateRequest; import com.funeat.review.dto.ReviewFavoriteRequest; - import java.time.LocalDateTime; import java.util.List; diff --git a/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java b/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java index ab3dab05e..9f5b88c5b 100644 --- a/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java +++ b/backend/src/test/java/com/funeat/product/application/ProductServiceTest.java @@ -1,14 +1,5 @@ package com.funeat.product.application; -import com.funeat.common.ServiceTest; -import com.funeat.product.dto.RankingProductDto; -import com.funeat.product.dto.RankingProductsResponse; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import java.util.Collections; -import java.util.List; - import static com.funeat.fixture.CategoryFixture.카테고리_즉석조리_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버2_생성; @@ -31,6 +22,14 @@ import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; import static org.assertj.core.api.Assertions.assertThat; +import com.funeat.common.ServiceTest; +import com.funeat.product.dto.RankingProductDto; +import com.funeat.product.dto.RankingProductsResponse; +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + @SuppressWarnings("NonAsciiCharacters") class ProductServiceTest extends ServiceTest { diff --git a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java index 20c4a18a6..435752022 100644 --- a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java +++ b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java @@ -1,15 +1,5 @@ package com.funeat.product.persistence; -import com.funeat.common.RepositoryTest; -import com.funeat.product.dto.ProductInCategoryDto; -import com.funeat.product.dto.ProductReviewCountDto; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; - -import java.time.LocalDateTime; -import java.util.Collections; -import java.util.List; - import static com.funeat.fixture.CategoryFixture.카테고리_간편식사_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버2_생성; @@ -42,6 +32,15 @@ import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; import static org.assertj.core.api.Assertions.assertThat; +import com.funeat.common.RepositoryTest; +import com.funeat.product.dto.ProductInCategoryDto; +import com.funeat.product.dto.ProductReviewCountDto; +import java.time.LocalDateTime; +import java.util.Collections; +import java.util.List; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + @SuppressWarnings("NonAsciiCharacters") class ProductRepositoryTest extends RepositoryTest { From 7a49e6aa65c6d674f5eec19bc10c1ffd473d8048 Mon Sep 17 00:00:00 2001 From: Go-Jaecheol Date: Wed, 18 Oct 2023 13:27:29 +0900 Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=EC=B6=A9=EB=8F=8C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/funeat/review/domain/Review.java | 1 + .../persistence/ProductRepositoryTest.java | 21 ------------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/backend/src/main/java/com/funeat/review/domain/Review.java b/backend/src/main/java/com/funeat/review/domain/Review.java index c97f25c87..9b1a458d3 100644 --- a/backend/src/main/java/com/funeat/review/domain/Review.java +++ b/backend/src/main/java/com/funeat/review/domain/Review.java @@ -7,6 +7,7 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; diff --git a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java index a1775018c..107585475 100644 --- a/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java +++ b/backend/src/test/java/com/funeat/product/persistence/ProductRepositoryTest.java @@ -4,41 +4,20 @@ import static com.funeat.fixture.MemberFixture.멤버_멤버1_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버2_생성; import static com.funeat.fixture.MemberFixture.멤버_멤버3_생성; -import static com.funeat.fixture.PageFixture.가격_내림차순; -import static com.funeat.fixture.PageFixture.가격_오름차순; -import static com.funeat.fixture.PageFixture.리뷰수_내림차순; import static com.funeat.fixture.PageFixture.페이지요청_기본_생성; -import static com.funeat.fixture.PageFixture.페이지요청_생성; -import static com.funeat.fixture.PageFixture.평균_평점_내림차순; -import static com.funeat.fixture.PageFixture.평균_평점_오름차순; import static com.funeat.fixture.ProductFixture.상품_망고빙수_가격5000원_평점4점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_리뷰3개_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점1점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점2점_생성; import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점3점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점4점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격1000원_평점5점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격2000원_리뷰1개_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격2000원_평점1점_생성; import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격2000원_평점4점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격3000원_리뷰5개_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격3000원_평점1점_생성; import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격3000원_평점5점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격4000원_평점1점_생성; import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격4000원_평점2점_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격5000원_리뷰0개_생성; -import static com.funeat.fixture.ProductFixture.상품_삼각김밥_가격5000원_평점1점_생성; import static com.funeat.fixture.ProductFixture.상품_애플망고_가격3000원_평점5점_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test1_평점1점_재구매X_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test3_평점3점_재구매O_생성; -import static com.funeat.fixture.ReviewFixture.리뷰_이미지test4_평점4점_재구매O_생성; -import static com.funeat.fixture.ReviewFixture.리뷰_이미지test4_평점4점_재구매X_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매O_생성; import static com.funeat.fixture.ReviewFixture.리뷰_이미지test5_평점5점_재구매X_생성; import static org.assertj.core.api.Assertions.assertThat; import com.funeat.common.RepositoryTest; -import com.funeat.product.dto.ProductInCategoryDto; import com.funeat.product.dto.ProductReviewCountDto; import java.time.LocalDateTime; import java.util.Collections;