diff --git a/src/main/java/gift/controller/GiftOrderController.java b/src/main/java/gift/controller/GiftOrderController.java index 8134331a7..5249c1e37 100644 --- a/src/main/java/gift/controller/GiftOrderController.java +++ b/src/main/java/gift/controller/GiftOrderController.java @@ -7,6 +7,7 @@ import gift.service.KakaoService; import gift.service.OptionService; import jakarta.validation.Valid; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; @@ -21,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController; import java.net.URI; -import java.util.List; @RestController @RequestMapping("/api/orders") @@ -51,7 +51,7 @@ public ResponseEntity getOrder(@PathVariable Long id) { } @GetMapping - public ResponseEntity> getOrders(@RequestAttribute("memberId") Long memberId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { + public ResponseEntity> getOrders(@RequestAttribute("memberId") Long memberId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { var orders = giftOrderService.getGiftOrders(memberId, pageable); return ResponseEntity.ok(orders); } diff --git a/src/main/java/gift/controller/ProductController.java b/src/main/java/gift/controller/ProductController.java index 61e478539..b18b67656 100644 --- a/src/main/java/gift/controller/ProductController.java +++ b/src/main/java/gift/controller/ProductController.java @@ -6,6 +6,7 @@ import gift.dto.product.ProductUpdateRequest; import gift.service.ProductService; import jakarta.validation.Valid; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; @@ -21,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController; import java.net.URI; -import java.util.List; @RestController @RequestMapping("/api/products") @@ -52,7 +52,7 @@ public ResponseEntity getProduct(@PathVariable Long id) { } @GetMapping - public ResponseEntity> getProducts(@RequestParam(required = false) Long categoryId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { + public ResponseEntity> getProducts(@RequestParam(required = false) Long categoryId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { if (categoryId == null) { var products = productService.getProducts(pageable); return ResponseEntity.ok(products); diff --git a/src/main/java/gift/controller/WishProductController.java b/src/main/java/gift/controller/WishProductController.java index 7565bbd5a..f95c5d75f 100644 --- a/src/main/java/gift/controller/WishProductController.java +++ b/src/main/java/gift/controller/WishProductController.java @@ -6,6 +6,7 @@ import gift.dto.wishproduct.WishProductUpdateRequest; import gift.service.WishProductService; import jakarta.validation.Valid; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; @@ -21,7 +22,6 @@ import org.springframework.web.bind.annotation.RestController; import java.net.URI; -import java.util.List; @RestController @RequestMapping("/api/wishes") @@ -52,7 +52,7 @@ public ResponseEntity getWishProduct(@RequestAttribute("mem } @GetMapping - public ResponseEntity> getWishProducts(@RequestAttribute("memberId") Long memberId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { + public ResponseEntity> getWishProducts(@RequestAttribute("memberId") Long memberId, @PageableDefault(sort = "id", direction = Sort.Direction.DESC) Pageable pageable) { var wishProducts = wishProductService.getWishProducts(memberId, pageable); return ResponseEntity.ok(wishProducts); } diff --git a/src/main/java/gift/controller/api/GiftOrderApi.java b/src/main/java/gift/controller/api/GiftOrderApi.java index 30578f21f..f1d1c5ebd 100644 --- a/src/main/java/gift/controller/api/GiftOrderApi.java +++ b/src/main/java/gift/controller/api/GiftOrderApi.java @@ -9,11 +9,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; -import java.util.List; - @Tag(name = "상품 주문 API") public interface GiftOrderApi { @@ -39,7 +38,7 @@ public interface GiftOrderApi { @ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true))) }) - ResponseEntity> getOrders(Long memberId, Pageable pageable); + ResponseEntity> getOrders(Long memberId, Pageable pageable); @Operation(summary = "특정 주문을 삭제한다.") @ApiResponses(value = { diff --git a/src/main/java/gift/controller/api/ProductApi.java b/src/main/java/gift/controller/api/ProductApi.java index d04bc7d2f..23465aca7 100644 --- a/src/main/java/gift/controller/api/ProductApi.java +++ b/src/main/java/gift/controller/api/ProductApi.java @@ -10,11 +10,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; -import java.util.List; - @Tag(name = "상품 API") public interface ProductApi { @@ -50,7 +49,7 @@ public interface ProductApi { @ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true))) }) - ResponseEntity> getProducts(Long categoryId, Pageable pageable); + ResponseEntity> getProducts(Long categoryId, Pageable pageable); @Operation(summary = "특정 상품을 삭제한다.") @ApiResponses(value = { diff --git a/src/main/java/gift/controller/api/WishProductApi.java b/src/main/java/gift/controller/api/WishProductApi.java index 71269e597..537fbd2f4 100644 --- a/src/main/java/gift/controller/api/WishProductApi.java +++ b/src/main/java/gift/controller/api/WishProductApi.java @@ -11,11 +11,10 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.http.ResponseEntity; -import java.util.List; - @Tag(name = "위시리스트 API") public interface WishProductApi { @@ -50,7 +49,7 @@ public interface WishProductApi { @ApiResponse(responseCode = "401", description = "허용되지 않는 요청", content = @Content(schema = @Schema(hidden = true))), @ApiResponse(responseCode = "500", description = "내부 서버의 오류", content = @Content(schema = @Schema(hidden = true))) }) - ResponseEntity> getWishProducts(Long memberId, Pageable pageable); + ResponseEntity> getWishProducts(Long memberId, Pageable pageable); @Operation(summary = "회원의 위시 리스트에서 상품을 삭제한다.") @ApiResponses(value = { diff --git a/src/main/java/gift/dto/category/CategoryInformation.java b/src/main/java/gift/dto/category/CategoryInformation.java deleted file mode 100644 index 1eff662b6..000000000 --- a/src/main/java/gift/dto/category/CategoryInformation.java +++ /dev/null @@ -1,10 +0,0 @@ -package gift.dto.category; - -public record CategoryInformation( - Long id, - String name -) { - public static CategoryInformation of(Long id, String name) { - return new CategoryInformation(id, name); - } -} diff --git a/src/main/java/gift/dto/product/ProductResponse.java b/src/main/java/gift/dto/product/ProductResponse.java index 4c53a6cb6..b79977626 100644 --- a/src/main/java/gift/dto/product/ProductResponse.java +++ b/src/main/java/gift/dto/product/ProductResponse.java @@ -1,7 +1,7 @@ package gift.dto.product; import com.fasterxml.jackson.annotation.JsonProperty; -import gift.dto.category.CategoryInformation; +import gift.dto.category.CategoryResponse; import gift.dto.option.OptionResponse; import java.util.List; @@ -12,10 +12,10 @@ public record ProductResponse( Integer price, String imageUrl, @JsonProperty("category") - CategoryInformation categoryInformation, + CategoryResponse categoryResponse, List options ) { - public static ProductResponse of(Long id, String name, Integer price, String imageUrl, CategoryInformation categoryInformation, List options) { - return new ProductResponse(id, name, price, imageUrl, categoryInformation, options); + public static ProductResponse of(Long id, String name, Integer price, String imageUrl, CategoryResponse categoryResponse, List options) { + return new ProductResponse(id, name, price, imageUrl, categoryResponse, options); } } diff --git a/src/main/java/gift/repository/GiftOrderRepository.java b/src/main/java/gift/repository/GiftOrderRepository.java index 085fb20e1..28ac64d50 100644 --- a/src/main/java/gift/repository/GiftOrderRepository.java +++ b/src/main/java/gift/repository/GiftOrderRepository.java @@ -1,16 +1,15 @@ package gift.repository; import gift.model.GiftOrder; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.List; - @Repository public interface GiftOrderRepository extends JpaRepository { - List findAllByMemberId(Long memberId, Pageable pageable); + Page findAllByMemberId(Long memberId, Pageable pageable); void deleteAllByOptionId(Long optionId); diff --git a/src/main/java/gift/repository/ProductRepository.java b/src/main/java/gift/repository/ProductRepository.java index 2ba6cd06c..b3d7ba253 100644 --- a/src/main/java/gift/repository/ProductRepository.java +++ b/src/main/java/gift/repository/ProductRepository.java @@ -1,6 +1,7 @@ package gift.repository; import gift.model.Product; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -11,5 +12,5 @@ public interface ProductRepository extends JpaRepository { List findAllByCategoryId(Long categoryId); - List findAllByCategoryId(Long categoryId, Pageable pageable); + Page findAllByCategoryId(Long categoryId, Pageable pageable); } diff --git a/src/main/java/gift/repository/WishProductRepository.java b/src/main/java/gift/repository/WishProductRepository.java index e2871fdbe..89c375cd0 100644 --- a/src/main/java/gift/repository/WishProductRepository.java +++ b/src/main/java/gift/repository/WishProductRepository.java @@ -3,11 +3,11 @@ import gift.model.Member; import gift.model.Product; import gift.model.WishProduct; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; -import java.util.List; import java.util.Optional; @Repository @@ -16,7 +16,7 @@ public interface WishProductRepository extends JpaRepository Optional findByProductAndMember(Product product, Member member); - List findAllByMemberId(Long memberId, Pageable pageable); + Page findAllByMemberId(Long memberId, Pageable pageable); void deleteAllByProductId(Long id); diff --git a/src/main/java/gift/service/GiftOrderService.java b/src/main/java/gift/service/GiftOrderService.java index 09ca4d96a..4af2fdbff 100644 --- a/src/main/java/gift/service/GiftOrderService.java +++ b/src/main/java/gift/service/GiftOrderService.java @@ -9,12 +9,12 @@ import gift.model.Option; import gift.repository.GiftOrderRepository; import gift.repository.MemberRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - @Service @Transactional public class GiftOrderService { @@ -43,11 +43,15 @@ public GiftOrderResponse getGiftOrder(Long id) { } @Transactional(readOnly = true) - public List getGiftOrders(Long memberId, Pageable pageable) { - return giftOrderRepository.findAllByMemberId(memberId, pageable) + public Page getGiftOrders(Long memberId, Pageable pageable) { + var pageResult = giftOrderRepository.findAllByMemberId(memberId, pageable); + var orders = pageResult + .getContent() .stream() .map(this::getGiftOrderResponseFromGiftOrder) .toList(); + + return new PageImpl<>(orders, pageable, pageResult.getTotalElements()); } public void deleteOrder(Long id) { diff --git a/src/main/java/gift/service/ProductService.java b/src/main/java/gift/service/ProductService.java index e8c66f5cf..c8dda1a03 100644 --- a/src/main/java/gift/service/ProductService.java +++ b/src/main/java/gift/service/ProductService.java @@ -1,6 +1,6 @@ package gift.service; -import gift.dto.category.CategoryInformation; +import gift.dto.category.CategoryResponse; import gift.dto.option.OptionRequest; import gift.dto.product.ProductAddRequest; import gift.dto.product.ProductResponse; @@ -11,6 +11,8 @@ import gift.model.Product; import gift.repository.CategoryRepository; import gift.repository.ProductRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -53,19 +55,27 @@ public ProductResponse getProduct(Long id) { } @Transactional(readOnly = true) - public List getProducts(Pageable pageable) { - return productRepository.findAll(pageable) + public Page getProducts(Pageable pageable) { + var pageResult = productRepository.findAll(pageable); + var products = pageResult + .getContent() .stream() .map(this::getProductResponseFromProduct) .toList(); + + return new PageImpl<>(products, pageable, pageResult.getTotalElements()); } @Transactional(readOnly = true) - public List getProducts(Long categoryId, Pageable pageable) { - return productRepository.findAllByCategoryId(categoryId, pageable) + public Page getProducts(Long categoryId, Pageable pageable) { + var pageResult = productRepository.findAllByCategoryId(categoryId, pageable); + var products = pageResult + .getContent() .stream() .map(this::getProductResponseFromProduct) .toList(); + + return new PageImpl<>(products, pageable, pageResult.getTotalElements()); } public void deleteProduct(Long productId) { @@ -108,9 +118,9 @@ private void productNameValidation(String name) { } private ProductResponse getProductResponseFromProduct(Product product) { - var categoryInformation = getCategoryInformationFromCategory(product.getCategory()); + var categoryResponse = getCategoryResponseFromCategory(product.getCategory()); var options = optionService.getOptions(product.getId()); - return ProductResponse.of(product.getId(), product.getName(), product.getPrice(), product.getImageUrl(), categoryInformation, options); + return ProductResponse.of(product.getId(), product.getName(), product.getPrice(), product.getImageUrl(), categoryResponse, options); } private Product findProductById(Long id) { @@ -118,7 +128,7 @@ private Product findProductById(Long id) { .orElseThrow(() -> new NotFoundElementException(id + "를 가진 상품옵션이 존재하지 않습니다.")); } - private CategoryInformation getCategoryInformationFromCategory(Category category) { - return CategoryInformation.of(category.getId(), category.getName()); + private CategoryResponse getCategoryResponseFromCategory(Category category) { + return CategoryResponse.of(category.getId(), category.getName(), category.getDescription(), category.getColor(), category.getImageUrl()); } } diff --git a/src/main/java/gift/service/WishProductService.java b/src/main/java/gift/service/WishProductService.java index 41254faa4..5a11b893a 100644 --- a/src/main/java/gift/service/WishProductService.java +++ b/src/main/java/gift/service/WishProductService.java @@ -12,12 +12,12 @@ import gift.repository.MemberRepository; import gift.repository.ProductRepository; import gift.repository.WishProductRepository; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.List; - @Service @Transactional public class WishProductService { @@ -63,11 +63,15 @@ public WishProductResponse getWishProduct(Long memberId, Long id) { } @Transactional(readOnly = true) - public List getWishProducts(Long memberId, Pageable pageable) { - return wishProductRepository.findAllByMemberId(memberId, pageable) + public Page getWishProducts(Long memberId, Pageable pageable) { + var pageResult = wishProductRepository.findAllByMemberId(memberId, pageable); + var wishProducts = pageResult + .getContent() .stream() .map(this::getWishProductResponseFromWishProduct) .toList(); + + return new PageImpl<>(wishProducts, pageable, pageResult.getTotalElements()); } public void deleteWishProduct(Long wishProductId) { diff --git a/src/test/java/gift/controller/ProductControllerTest.java b/src/test/java/gift/controller/ProductControllerTest.java index 874784b91..cf7e1940f 100644 --- a/src/test/java/gift/controller/ProductControllerTest.java +++ b/src/test/java/gift/controller/ProductControllerTest.java @@ -1,6 +1,5 @@ package gift.controller; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import gift.dto.auth.LoginRequest; import gift.dto.option.OptionRequest; @@ -210,11 +209,7 @@ void successGetProductsWithPageable() throws Exception { //when var getResult = mockMvc.perform(getRequest); //then - var productResult = getResult.andExpect(status().isOk()).andReturn(); - var productsString = productResult.getResponse().getContentAsString(); - var productResponseResult = objectMapper.readValue(productsString, new TypeReference>() { - }); - Assertions.assertThat(productResponseResult.size()).isEqualTo(4); + getResult.andExpect(status().isOk()); deleteProducts(productResponseList); } diff --git a/src/test/java/gift/controller/WishProductControllerTest.java b/src/test/java/gift/controller/WishProductControllerTest.java index 0ee4e0a40..fff8bc66a 100644 --- a/src/test/java/gift/controller/WishProductControllerTest.java +++ b/src/test/java/gift/controller/WishProductControllerTest.java @@ -1,6 +1,5 @@ package gift.controller; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import gift.dto.auth.LoginRequest; import gift.dto.wishproduct.WishProductAddRequest; @@ -98,11 +97,7 @@ void successGetWishProducts() throws Exception { //when var readResult = mockMvc.perform(getRequest); //then - var wishResult = readResult.andExpect(status().isOk()).andReturn(); - var wishResponseContent = wishResult.getResponse().getContentAsString(); - var wishProducts = objectMapper.readValue(wishResponseContent, new TypeReference>() { - }); - Assertions.assertThat(wishProducts.size()).isEqualTo(1); + readResult.andExpect(status().isOk()); wishProductService.deleteWishProduct(wishProduct.id()); } @@ -122,8 +117,8 @@ void successAddWishProductAlreadyExists() throws Exception { //then addResult.andExpect(status().isCreated()); var wishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 10)); - Assertions.assertThat(wishProducts.size()).isEqualTo(1); - Assertions.assertThat(wishProducts.get(0).quantity()).isEqualTo(20); + Assertions.assertThat(wishProducts.getContent().size()).isEqualTo(1); + Assertions.assertThat(wishProducts.getContent().get(0).quantity()).isEqualTo(20); wishProductService.deleteWishProduct(wishProduct.id()); } @@ -146,9 +141,9 @@ void successGetDifferentWishProducts() throws Exception { var managerWishLength = managerWishResult.getResponse().getContentLength(); Assertions.assertThat(managerWishLength).isEqualTo(0); var memberWishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 10)); - Assertions.assertThat(memberWishProducts.size()).isEqualTo(2); + Assertions.assertThat(memberWishProducts.getContent().size()).isEqualTo(2); - deleteWishProducts(memberWishProducts); + deleteWishProducts(memberWishProducts.getContent()); } @Test @@ -166,8 +161,8 @@ void successUpdateQuantity() throws Exception { //then result.andExpect(status().isNoContent()); var wishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 10)); - Assertions.assertThat(wishProducts.size()).isEqualTo(1); - Assertions.assertThat(wishProducts.get(0).quantity()).isEqualTo(30); + Assertions.assertThat(wishProducts.getContent().size()).isEqualTo(1); + Assertions.assertThat(wishProducts.getContent().get(0).quantity()).isEqualTo(30); wishProductService.deleteWishProduct(wishProduct.id()); } @@ -188,7 +183,7 @@ void successUpdateQuantityZero() throws Exception { //then result.andExpect(status().isNoContent()); var wishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 10)); - Assertions.assertThat(wishProducts.size()).isEqualTo(0); + Assertions.assertThat(wishProducts.getContent().size()).isEqualTo(0); } @Test diff --git a/src/test/java/gift/service/WishProductServiceTest.java b/src/test/java/gift/service/WishProductServiceTest.java index d5eba8ae9..1fb6b5df0 100644 --- a/src/test/java/gift/service/WishProductServiceTest.java +++ b/src/test/java/gift/service/WishProductServiceTest.java @@ -23,11 +23,11 @@ class WishProductServiceTest { void successAddWishProduct() { //given var wishProductAddRequest = new WishProductAddRequest(1L, 5); - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(0); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(0); //when var wishProduct = wishProductService.addWishProduct(wishProductAddRequest, 1L); //then - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(1); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(1); wishProductService.deleteWishProduct(wishProduct.id()); } @@ -38,11 +38,11 @@ void successDeleteWishProduct() { //given var wishProductAddRequest = new WishProductAddRequest(1L, 5); var wishProduct = wishProductService.addWishProduct(wishProductAddRequest, 1L); - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(1); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(1); //when wishProductService.deleteWishProduct(wishProduct.id()); //then - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(0); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(0); } @Test @@ -51,12 +51,12 @@ void successUpdateWishProductWithZeroQuantity() { //given var wishProductAddRequest = new WishProductAddRequest(1L, 5); var wishProduct = wishProductService.addWishProduct(wishProductAddRequest, 1L); - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(1); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(1); var wishProductUpdateRequest = new WishProductUpdateRequest(0); //when wishProductService.updateWishProduct(wishProduct.id(), wishProductUpdateRequest); //then - Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).size()).isEqualTo(0); + Assertions.assertThat(wishProductService.getWishProducts(1L, PageRequest.of(0, 10)).getContent().size()).isEqualTo(0); } @Test @@ -70,7 +70,7 @@ void successGetDifferentWishProducts() { //when var memberWishProducts = wishProductService.getWishProducts(2L, PageRequest.of(0, 10)); //then - Assertions.assertThat(memberWishProducts.size()).isEqualTo(0); + Assertions.assertThat(memberWishProducts.getContent().size()).isEqualTo(0); wishProductService.deleteWishProduct(managerWishProduct1.id()); wishProductService.deleteWishProduct(managerWishProduct2.id()); @@ -96,8 +96,8 @@ void successAddWishProductAlreadyExistsWishProduct() { var wishProduct = wishProductService.addWishProduct(wishProduct1AddRequest, 1L); //then var wishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 10)); - Assertions.assertThat(wishProducts.size()).isEqualTo(1); - Assertions.assertThat(wishProducts.get(0).quantity()).isEqualTo(10); + Assertions.assertThat(wishProducts.getContent().size()).isEqualTo(1); + Assertions.assertThat(wishProducts.getContent().get(0).quantity()).isEqualTo(10); wishProductService.deleteWishProduct(wishProduct.id()); } @@ -113,7 +113,7 @@ void successGetProductsWishPageSizeOne() { //when var wishProducts = wishProductService.getWishProducts(1L, PageRequest.of(0, 1)); //then - Assertions.assertThat(wishProducts.size()).isEqualTo(1); + Assertions.assertThat(wishProducts.getContent().size()).isEqualTo(1); wishProductService.deleteWishProduct(wishProduct1.id()); wishProductService.deleteWishProduct(wishProduct2.id());