From cbd19a1ed41cc95d405b7da9cfd3ab6cecf2b8de Mon Sep 17 00:00:00 2001 From: Jeong Wonju Date: Thu, 2 Jan 2025 13:08:28 +0900 Subject: [PATCH] =?UTF-8?q?Mate-135=20:=20[FEAT]=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=9E=91=EC=84=B1=EA=B8=80=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=95=20=EC=A1=B0=ED=9A=8C=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EA=B5=AC=ED=98=84=20(#119)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * MATE-135 : [FEAT] 마이페이지 작성한 굿즈 거래글 페이징 조회 기능 구현 * MATE-135 : [TEST] 마이페이지 작성한 굿즈 거래글 페이징 조회 기능 테스트 * MATE-135 : [FEAT] 마이페이지 작성한 메이트 구인글 페이징 조회 기능 구현 * MATE-135 : [TEST] 마이페이지 작성한 메이트 구인글 페이징 조회 기능 테스트 --- .../repository/GoodsPostRepository.java | 8 + .../mate/repository/MateRepository.java | 9 ++ .../member/controller/ProfileController.java | 22 +++ .../domain/member/service/ProfileService.java | 36 ++++- .../controller/ProfileControllerTest.java | 138 ++++++++++++++++-- .../integration/ProfileIntegrationTest.java | 95 +++++++++++- .../member/service/ProfileServiceTest.java | 102 ++++++++++++- 7 files changed, 386 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/example/mate/domain/goodsPost/repository/GoodsPostRepository.java b/src/main/java/com/example/mate/domain/goodsPost/repository/GoodsPostRepository.java index dc970a9b..28f0b846 100644 --- a/src/main/java/com/example/mate/domain/goodsPost/repository/GoodsPostRepository.java +++ b/src/main/java/com/example/mate/domain/goodsPost/repository/GoodsPostRepository.java @@ -58,4 +58,12 @@ Page findGoodsPostsBySellerId(@Param("memberId") Long memberId, @Para """) Page findGoodsPostsByBuyerId(@Param("memberId") Long memberId, @Param("status") Status status, Pageable pageable); + + @Query(""" + SELECT gp + FROM GoodsPost gp + WHERE gp.seller.id = :memberId + ORDER BY gp.createdAt DESC + """) + Page findMyGoodsPosts(@Param("memberId") Long memberId, Pageable pageable); } \ No newline at end of file diff --git a/src/main/java/com/example/mate/domain/mate/repository/MateRepository.java b/src/main/java/com/example/mate/domain/mate/repository/MateRepository.java index 6937d4c1..7687b256 100644 --- a/src/main/java/com/example/mate/domain/mate/repository/MateRepository.java +++ b/src/main/java/com/example/mate/domain/mate/repository/MateRepository.java @@ -2,6 +2,7 @@ import com.example.mate.domain.mate.entity.MatePost; import com.example.mate.domain.mate.entity.Status; +import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -21,4 +22,12 @@ public interface MateRepository extends JpaRepository, MateRepos """) List findMainPagePosts(@Param("teamId") Long teamId, @Param("now") LocalDateTime now, @Param("statuses") List statuses, Pageable pageable); + + @Query(""" + SELECT mp + FROM MatePost mp + WHERE mp.author.id = :memberId + ORDER BY mp.createdAt DESC + """) + Page findMyMatePosts(@Param("memberId") Long memberId, Pageable pageable); } diff --git a/src/main/java/com/example/mate/domain/member/controller/ProfileController.java b/src/main/java/com/example/mate/domain/member/controller/ProfileController.java index c2140ba6..a2b226c6 100644 --- a/src/main/java/com/example/mate/domain/member/controller/ProfileController.java +++ b/src/main/java/com/example/mate/domain/member/controller/ProfileController.java @@ -6,6 +6,8 @@ import com.example.mate.common.response.PageResponse; import com.example.mate.common.security.auth.AuthMember; import com.example.mate.common.validator.ValidPageable; +import com.example.mate.domain.goodsPost.dto.response.GoodsPostSummaryResponse; +import com.example.mate.domain.mate.dto.response.MatePostSummaryResponse; import com.example.mate.domain.member.dto.response.MyGoodsRecordResponse; import com.example.mate.domain.member.dto.response.MyReviewResponse; import com.example.mate.domain.member.dto.response.MyVisitResponse; @@ -83,4 +85,24 @@ public ResponseEntity>> getBough PageResponse response = profileService.getBoughtGoodsPage(memberId, pageable); return ResponseEntity.ok(ApiResponse.success(response)); } + + @Operation(summary = "작성한 굿즈 거래글 모아보기 페이징 조회") + @GetMapping("/posts/goods") + public ResponseEntity>> getGoodsPosts( + @Parameter(description = "회원 로그인 정보") @AuthenticationPrincipal AuthMember authMember, + @Parameter(description = "페이지 요청 정보") @ValidPageable Pageable pageable + ) { + PageResponse response = profileService.getGoodsPostsPage(authMember.getMemberId(), pageable); + return ResponseEntity.ok(ApiResponse.success(response)); + } + + @Operation(summary = "작성한 메이트 구인글 모아보기 페이징 조회") + @GetMapping("/posts/mate") + public ResponseEntity>> getMatePosts( + @Parameter(description = "회원 로그인 정보") @AuthenticationPrincipal AuthMember authMember, + @Parameter(description = "페이지 요청 정보") @ValidPageable Pageable pageable + ) { + PageResponse response = profileService.getMatePostsPage(authMember.getMemberId(), pageable); + return ResponseEntity.ok(ApiResponse.success(response)); + } } \ No newline at end of file diff --git a/src/main/java/com/example/mate/domain/member/service/ProfileService.java b/src/main/java/com/example/mate/domain/member/service/ProfileService.java index a91165d8..c4d67d62 100644 --- a/src/main/java/com/example/mate/domain/member/service/ProfileService.java +++ b/src/main/java/com/example/mate/domain/member/service/ProfileService.java @@ -7,12 +7,12 @@ import com.example.mate.domain.goodsPost.entity.Status; import com.example.mate.domain.goodsPost.repository.GoodsPostRepository; import com.example.mate.domain.goodsReview.repository.GoodsReviewRepositoryCustom; +import com.example.mate.domain.goodsPost.dto.response.GoodsPostSummaryResponse; import com.example.mate.domain.match.entity.Match; +import com.example.mate.domain.mate.dto.response.MatePostSummaryResponse; +import com.example.mate.domain.mate.entity.MatePost; import com.example.mate.domain.mate.entity.MateReview; -import com.example.mate.domain.mate.repository.MateReviewRepository; -import com.example.mate.domain.mate.repository.MateReviewRepositoryCustom; -import com.example.mate.domain.mate.repository.VisitPartRepository; -import com.example.mate.domain.mate.repository.VisitRepository; +import com.example.mate.domain.mate.repository.*; import com.example.mate.domain.member.dto.response.MyGoodsRecordResponse; import com.example.mate.domain.member.dto.response.MyReviewResponse; import com.example.mate.domain.member.dto.response.MyTimelineResponse; @@ -38,6 +38,7 @@ public class ProfileService { private final MemberRepository memberRepository; private final GoodsPostRepository goodsPostRepository; + private final MateRepository mateRepository; private final MateReviewRepositoryCustom mateReviewRepositoryCustom; private final GoodsReviewRepositoryCustom goodsReviewRepositoryCustom; private final VisitPartRepository visitPartRepository; @@ -174,4 +175,31 @@ private PageResponse createPageResponse(Page getGoodsPostsPage(Long memberId, Pageable pageable) { + Page goodsPostsPage = goodsPostRepository.findMyGoodsPosts(memberId, pageable); + List content = goodsPostsPage.getContent().stream() + .map(this::convertToGoodsPostResponse) + .toList(); + + return PageResponse.from(goodsPostsPage, content); + } + + private GoodsPostSummaryResponse convertToGoodsPostResponse(GoodsPost goodsPost) { + String mainImageUrl = goodsPost.getMainImageUrl(); + return GoodsPostSummaryResponse.of(goodsPost, mainImageUrl); + } + + // 작성한 메이트 구인글 페이징 조회 + @Transactional(readOnly = true) + public PageResponse getMatePostsPage(Long memberId, Pageable pageable) { + Page matePostsPage = mateRepository.findMyMatePosts(memberId, pageable); + List content = matePostsPage.getContent().stream() + .map(MatePostSummaryResponse::from) + .toList(); + + return PageResponse.from(matePostsPage, content); + } } \ No newline at end of file diff --git a/src/test/java/com/example/mate/domain/member/controller/ProfileControllerTest.java b/src/test/java/com/example/mate/domain/member/controller/ProfileControllerTest.java index b674faaa..1ed15109 100644 --- a/src/test/java/com/example/mate/domain/member/controller/ProfileControllerTest.java +++ b/src/test/java/com/example/mate/domain/member/controller/ProfileControllerTest.java @@ -1,27 +1,22 @@ package com.example.mate.domain.member.controller; -import static org.mockito.BDDMockito.given; -import static org.mockito.BDDMockito.willThrow; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - import com.example.mate.common.error.CustomException; import com.example.mate.common.error.ErrorCode; import com.example.mate.common.response.PageResponse; import com.example.mate.common.security.filter.JwtCheckFilter; import com.example.mate.config.WithAuthMember; +import com.example.mate.domain.constant.Gender; +import com.example.mate.domain.goodsPost.dto.response.GoodsPostSummaryResponse; +import com.example.mate.domain.mate.dto.response.MatePostSummaryResponse; +import com.example.mate.domain.mate.entity.Age; +import com.example.mate.domain.mate.entity.Status; +import com.example.mate.domain.mate.entity.TransportType; import com.example.mate.domain.member.dto.response.MyGoodsRecordResponse; import com.example.mate.domain.member.dto.response.MyReviewResponse; import com.example.mate.domain.member.dto.response.MyVisitResponse; import com.example.mate.domain.member.dto.response.MyVisitResponse.MateReviewResponse; import com.example.mate.domain.member.service.ProfileService; import com.fasterxml.jackson.databind.ObjectMapper; -import java.time.LocalDateTime; -import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -35,6 +30,18 @@ import org.springframework.data.jpa.mapping.JpaMetamodelMappingContext; import org.springframework.test.web.servlet.MockMvc; +import java.time.LocalDateTime; +import java.util.List; + +import static org.mockito.BDDMockito.given; +import static org.mockito.BDDMockito.willThrow; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + @WebMvcTest(ProfileController.class) @MockBean(JpaMetamodelMappingContext.class) @AutoConfigureMockMvc(addFilters = false) @@ -404,4 +411,113 @@ void get_my_visit_page_fail_invalid_member_id() throws Exception { verify(profileService, times(1)).getMyVisitPage(memberId, pageable); } } + + @Nested + @DisplayName("작성한 굿즈 거래글 페이징 조회") + class ProfileGoodsPostsPage { + + @Test + @DisplayName("작성한 굿즈 거래글 페이징 조회 성공") + void get_my_goods_posts_page_success() throws Exception { + // given + Long memberId = 1L; + Pageable pageable = PageRequest.of(0, 10); + + GoodsPostSummaryResponse responseDTO = GoodsPostSummaryResponse.builder() + .id(1L) + .teamName("KIA") + .title("test title") + .category("유니폼") + .price(10000) + .imageUrl("test.png") + .build(); + List content = List.of(responseDTO); + PageImpl goodsPostPage = new PageImpl<>(content); + + PageResponse response = PageResponse.builder() + .content(content) + .totalPages(goodsPostPage.getTotalPages()) + .totalElements(goodsPostPage.getTotalElements()) + .hasNext(goodsPostPage.hasNext()) + .pageNumber(goodsPostPage.getNumber()) + .pageSize(goodsPostPage.getSize()) + .build(); + + given(profileService.getGoodsPostsPage(memberId, pageable)).willReturn(response); + + // when & then + mockMvc.perform(get("/api/profile/posts/goods") + .param("page", String.valueOf(pageable.getPageNumber())) + .param("size", String.valueOf(pageable.getPageSize()))) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("SUCCESS")) + .andExpect(jsonPath("$.data.content.size()").value(content.size())) + .andExpect(jsonPath("$.data.content[0].title").value(responseDTO.getTitle())) + .andExpect(jsonPath("$.data.content[0].price").value(responseDTO.getPrice())) + .andExpect(jsonPath("$.data.totalPages").value(response.getTotalPages())) + .andExpect(jsonPath("$.data.totalElements").value(response.getTotalElements())) + .andExpect(jsonPath("$.data.pageNumber").value(response.getPageNumber())) + .andExpect(jsonPath("$.data.pageSize").value(response.getPageSize())) + .andExpect(jsonPath("$.code").value(200)); + } + } + + @Nested + @DisplayName("작성한 메이트 구인글 페이징 조회") + class ProfileMatePostsPage { + + @Test + @DisplayName("작성한 메이트 구인글 페이징 조회 성공") + void get_my_mate_posts_page_success() throws Exception { + // given + Long memberId = 1L; + Pageable pageable = PageRequest.of(0, 10); + + MatePostSummaryResponse responseDTO = MatePostSummaryResponse.builder() + .imageUrl("test.png") + .title("test title") + .status(Status.CLOSED) + .myTeamName("KIA") + .rivalTeamName("LG") + .matchTime(LocalDateTime.now().minusDays(7)) + .location("광주-기아 챔피언스 필드") + .maxParticipants(10) + .age(Age.ALL) + .gender(Gender.ANY) + .transportType(TransportType.ANY) + .postId(1L) + .build(); + + List content = List.of(responseDTO); + PageImpl matePostPage = new PageImpl<>(content); + + PageResponse response = PageResponse.builder() + .content(content) + .totalPages(matePostPage.getTotalPages()) + .totalElements(matePostPage.getTotalElements()) + .hasNext(matePostPage.hasNext()) + .pageNumber(matePostPage.getNumber()) + .pageSize(matePostPage.getSize()) + .build(); + + given(profileService.getMatePostsPage(memberId, pageable)).willReturn(response); + + // when & then + mockMvc.perform(get("/api/profile/posts/mate") + .param("page", String.valueOf(pageable.getPageNumber())) + .param("size", String.valueOf(pageable.getPageSize()))) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("SUCCESS")) + .andExpect(jsonPath("$.data.content.size()").value(content.size())) + .andExpect(jsonPath("$.data.content[0].title").value(responseDTO.getTitle())) + .andExpect(jsonPath("$.data.content[0].location").value(responseDTO.getLocation())) + .andExpect(jsonPath("$.data.totalPages").value(response.getTotalPages())) + .andExpect(jsonPath("$.data.totalElements").value(response.getTotalElements())) + .andExpect(jsonPath("$.data.pageNumber").value(response.getPageNumber())) + .andExpect(jsonPath("$.data.pageSize").value(response.getPageSize())) + .andExpect(jsonPath("$.code").value(200)); + } + } } \ No newline at end of file diff --git a/src/test/java/com/example/mate/domain/member/integration/ProfileIntegrationTest.java b/src/test/java/com/example/mate/domain/member/integration/ProfileIntegrationTest.java index 14d6b41f..8575b1cf 100644 --- a/src/test/java/com/example/mate/domain/member/integration/ProfileIntegrationTest.java +++ b/src/test/java/com/example/mate/domain/member/integration/ProfileIntegrationTest.java @@ -35,8 +35,6 @@ import com.example.mate.domain.member.repository.MemberRepository; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.transaction.Transactional; -import java.time.LocalDateTime; -import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -44,12 +42,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.test.web.servlet.MockMvc; +import java.time.LocalDateTime; +import java.util.List; + @SpringBootTest @AutoConfigureMockMvc(addFilters = false) @Transactional @@ -497,6 +497,95 @@ void get_my_visit_page_success() throws Exception { .andExpect(jsonPath("$.data.content.length()").value(1)) .andExpect(jsonPath("$.code").value(200)); } + } + + @Nested + @DisplayName("작성한 굿즈 거래글 페이징 조회") + class ProfileGoodsPostsPage { + + @Test + @DisplayName("작성한 굿즈 거래글 페이징 조회 성공") + @WithAuthMember(userId = "customUser", memberId = 1L) + void get_my_goods_posts_page_success() throws Exception { + // given + int page = 0; + int size = 10; + + GoodsPost post = GoodsPost.builder() + .seller(member1) + .teamId(10L) + .title("Test Title ") + .content("Test Content ") + .price(1000) + .category(Category.ACCESSORY) + .location(LocationInfo.toEntity(createLocationInfo())) + .status(Status.CLOSED) + .build(); + + GoodsPostImage image = GoodsPostImage.builder() + .imageUrl("upload/test_img_url ") + .post(post) + .build(); + + post.changeImages(List.of(image)); + goodsPostRepository.save(post); + + // when & then + mockMvc.perform(get("/api/profile/posts/goods") + .param("page", String.valueOf(page)) + .param("size", String.valueOf(size))) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("SUCCESS")) + .andExpect(jsonPath("$.data.content").isArray()) + .andExpect(jsonPath("$.data.content.length()").value(3)) + .andExpect(jsonPath("$.code").value(200)); + } + } + + @Nested + @DisplayName("작성한 메이트 구인글 페이징 조회") + class ProfileMatePostsPage { + @Test + @DisplayName("작성한 메이트 구인글 페이징 조회 성공") + @WithAuthMember(userId = "customUser", memberId = 1L) + void get_my_mate_posts_page_success() throws Exception { + // given + int page = 0; + int size = 10; + + MatePost post = MatePost.builder() + .author(member1) + .teamId(1L) + .match(matchRepository.save(Match.builder() + .homeTeamId(1L) + .awayTeamId(2L) + .stadiumId(1L) + .status(SCHEDULED) + .matchTime(LocalDateTime.now().plusDays(7)) + .build())) + .title("new title") + .content("new content") + .status(com.example.mate.domain.mate.entity.Status.OPEN) + .maxParticipants(10) + .age(Age.ALL) + .gender(Gender.ANY) + .transport(TransportType.ANY) + .build(); + + mateRepository.save(post); + + // when & then + mockMvc.perform(get("/api/profile/posts/mate") + .param("page", String.valueOf(page)) + .param("size", String.valueOf(size))) + .andDo(print()) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.status").value("SUCCESS")) + .andExpect(jsonPath("$.data.content").isArray()) + .andExpect(jsonPath("$.data.content.length()").value(2)) + .andExpect(jsonPath("$.code").value(200)); + } } } \ No newline at end of file diff --git a/src/test/java/com/example/mate/domain/member/service/ProfileServiceTest.java b/src/test/java/com/example/mate/domain/member/service/ProfileServiceTest.java index c32b1b94..6a6e41d6 100644 --- a/src/test/java/com/example/mate/domain/member/service/ProfileServiceTest.java +++ b/src/test/java/com/example/mate/domain/member/service/ProfileServiceTest.java @@ -5,6 +5,7 @@ import com.example.mate.domain.constant.Gender; import com.example.mate.domain.constant.Rating; import com.example.mate.domain.constant.TeamInfo; +import com.example.mate.domain.goodsPost.dto.response.GoodsPostSummaryResponse; import com.example.mate.domain.goodsPost.dto.response.LocationInfo; import com.example.mate.domain.goodsPost.entity.Category; import com.example.mate.domain.goodsPost.entity.GoodsPost; @@ -13,12 +14,9 @@ import com.example.mate.domain.goodsPost.repository.GoodsPostRepository; import com.example.mate.domain.goodsReview.repository.GoodsReviewRepositoryCustom; import com.example.mate.domain.match.entity.Match; -import com.example.mate.domain.mate.entity.MateReview; -import com.example.mate.domain.mate.entity.Visit; -import com.example.mate.domain.mate.repository.MateReviewRepository; -import com.example.mate.domain.mate.repository.MateReviewRepositoryCustom; -import com.example.mate.domain.mate.repository.VisitPartRepository; -import com.example.mate.domain.mate.repository.VisitRepository; +import com.example.mate.domain.mate.dto.response.MatePostSummaryResponse; +import com.example.mate.domain.mate.entity.*; +import com.example.mate.domain.mate.repository.*; import com.example.mate.domain.member.dto.response.MyGoodsRecordResponse; import com.example.mate.domain.member.dto.response.MyReviewResponse; import com.example.mate.domain.member.dto.response.MyTimelineResponse; @@ -61,6 +59,9 @@ class ProfileServiceTest { @Mock private GoodsPostRepository goodsPostRepository; + @Mock + private MateRepository mateRepository; + @Mock private MateReviewRepositoryCustom mateReviewRepositoryCustom; @@ -80,6 +81,7 @@ class ProfileServiceTest { private Member member2; private Member member3; private GoodsPost goodsPost; + private MatePost matePost; private GoodsPostImage goodsPostImage; private MateReview mateReview; @@ -88,6 +90,7 @@ void setUp() { createTestMember(); createGoodsPost(); createGoodsPostImage(goodsPost); + createMatePost(); createMateReview(); } @@ -135,6 +138,28 @@ private void createGoodsPost() { .build(); } + private void createMatePost() { + matePost = MatePost.builder() + .id(1L) + .author(member1) + .teamId(1L) + .match(Match.builder() + .homeTeamId(1L) + .awayTeamId(2L) + .stadiumId(1L) + .matchTime(LocalDateTime.now().plusDays(1)) + .build()) + .title("test title") + .content("test content") + .imageUrl(goodsPostImage.getImageUrl()) + .status(com.example.mate.domain.mate.entity.Status.OPEN) + .maxParticipants(4) + .age(Age.TWENTIES) + .gender(Gender.FEMALE) + .transport(TransportType.PUBLIC) + .build(); + } + private LocationInfo createLocationInfo() { return LocationInfo.builder() .placeName("Stadium Plaza") @@ -481,4 +506,69 @@ void get_my_visit_page_fail_invalid_member_id() { verify(memberRepository).findById(invalidMemberId); } } + + @Nested + @DisplayName("작성한 굿즈 거래글 페이징 조회") + class ProfileGoodsPostsPage { + + @Test + @DisplayName("작성한 굿즈 거래글 페이징 조회 성공") + void get_my_goods_posts_page_success() { + // given + Long memberId = 1L; + PageImpl goodsPostsPage = new PageImpl<>(List.of(goodsPost)); + Pageable pageable = PageRequest.of(0, 10); + + given(goodsPostRepository.findMyGoodsPosts(memberId, pageable)) + .willReturn(goodsPostsPage); + + // when + PageResponse response = profileService.getGoodsPostsPage(memberId, pageable); + + // then + assertThat(response).isNotNull(); + assertThat(response.getContent()).isNotEmpty(); + assertThat(response.getTotalElements()).isEqualTo(goodsPostsPage.getTotalElements()); + assertThat(response.getContent().size()).isEqualTo(goodsPostsPage.getContent().size()); + + GoodsPostSummaryResponse postResponse = response.getContent().get(0); + assertThat(postResponse.getTitle()).isEqualTo(goodsPost.getTitle()); + assertThat(postResponse.getPrice()).isEqualTo(goodsPost.getPrice()); + assertThat(postResponse.getImageUrl()).isEqualTo(goodsPostImage.getImageUrl()); + + verify(goodsPostRepository).findMyGoodsPosts(memberId, pageable); + } + } + + @Nested + @DisplayName("작성한 메이트 구인글 페이징 조회") + class ProfileMatePostsPage { + + @Test + @DisplayName("작성한 메이트 구인글 페이징 조회 성공") + void get_my_mate_posts_page_success() { + // given + Long memberId = 1L; + PageImpl matePostsPage = new PageImpl<>(List.of(matePost)); + Pageable pageable = PageRequest.of(0, 10); + + given(mateRepository.findMyMatePosts(memberId, pageable)) + .willReturn(matePostsPage); + + // when + PageResponse response = profileService.getMatePostsPage(memberId, pageable); + + // then + assertThat(response).isNotNull(); + assertThat(response.getContent()).isNotEmpty(); + assertThat(response.getTotalElements()).isEqualTo(matePostsPage.getTotalElements()); + assertThat(response.getContent().size()).isEqualTo(matePostsPage.getContent().size()); + + MatePostSummaryResponse postResponse = response.getContent().get(0); + assertThat(postResponse.getTitle()).isEqualTo(matePost.getTitle()); + assertThat(postResponse.getImageUrl()).isEqualTo(goodsPostImage.getImageUrl()); + + verify(mateRepository).findMyMatePosts(memberId, pageable); + } + } } \ No newline at end of file