From 0a8d8cb388b0d3ed40bad9ea30819964647a6d11 Mon Sep 17 00:00:00 2001 From: eom-tae-in <101633465+eom-tae-in@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:29:11 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=85=80=ED=94=84=20=EC=86=8C=EA=B0=9C?= =?UTF-8?q?=20=EA=B8=B0=EB=8A=A5=EC=9D=84=20=EA=B5=AC=ED=98=84=ED=95=9C?= =?UTF-8?q?=EB=8B=A4=20(#46)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 셀프 소개글 기능에서 발생할 수 있는 예외클래스 지정 - InvalidContentException - SelfIntroNotFoundException - WriterNotEqualsException * feat: 셀프 소개글 기능에서 사용할 request dto 생성 - CityRequest - SelfIntroCreateRequest - SelfIntroFilterRequest - SelfIntroUpdateRequest * feat: 셀프 소개글 기능에서 사용할 response dto 생성 - SelfIntroResponse - SelfIntrosResponse * feat: 셀프 소개글을 저장하고 관리하는 엔티티 구현 - SelfIntro * feat: 셀프 소개글을 저장, 조회, 삭제하기 위한 repository 구현 - SelfIntroRepository - SelfIntroJpaRepository - SelfIntroQueryRepository - SelfIntroRepositoryImpl * feat: 셀프 소개글의 읽기 전용 Service 구현 - SelfIntroQueryService * feat: 셀프 소개글의 쓰기 전용 Service 구현 - SelfIntroService * feat: 셀프 소개글 Controller 구현 - SelfIntroController * feat: 셀프 소개글 기능 이용시 인증을 위한 인터셉터에 url에 추가 * test: 테스트 패키지 구조 변경으로 인한 수정 * test: SelfIntro를 검증하기 위한 테스트 클래스 작성 * test: SelfIntroService를 검증하기 위한 테스트 클래스 작성 * test: SelfIntroQueryService를 검증하기 위한 테스트 클래스 작성 * test: SelfIntroQueryRepository를 검증하기 위한 테스트 클래스 작성 * test: SelfIntroJpaRepository를 검증하기 위한 테스트 클래스 작성 * test: SelfIntro 컨트롤러 단위테스트 작성 * test: SelfIntro 인수테스트 작성 * test: SelfIntro 인수테스트 설정을 하기 위해 helper 작성 * test: SelfIntro 서비스 계층 테스트시 사용할 FakeRepository 작성 * test: 테스트를 편하게 하기 위해 fixture 작 * test: 경로 변경으로 인한 테스트 코드 수정 * refactor: 개행 추가 * refactor: 메서드 구조 변경 * test: test 수정 * refactor: 상수 값 변경 * refactor: 줄바꿈 제거 * refactor: 사용하는 jpa 내장 메서드 가시화 * docs: selfintro api 명세서 작성 --- src/docs/asciidoc/member.adoc | 71 +++++- .../selfintro/SelfIntroQueryService.java | 41 ++++ .../selfintro/SelfIntroService.java | 43 ++++ .../selfintro/dto/CityRequest.java | 10 + .../selfintro/dto/SelfIntroCreateRequest.java | 10 + .../selfintro/dto/SelfIntroFilterRequest.java | 29 +++ .../selfintro/dto/SelfIntroUpdateRequest.java | 10 + .../selfintro/dto/SelfIntrosResponse.java | 35 +++ .../atwoz/member/config/MemberAuthConfig.java | 4 +- .../member/domain/selfintro/SelfIntro.java | 66 ++++++ .../domain/selfintro/SelfIntroRepository.java | 22 ++ .../exception/MemberExceptionHandler.java | 87 ++++---- .../selfintro/InvalidContentException.java | 8 + .../selfintro/SelfIntroNotFoundException.java | 8 + .../selfintro/WriterNotEqualsException.java | 8 + .../selfintro/SelfIntroJpaRepository.java | 14 ++ .../selfintro/SelfIntroQueryRepository.java | 112 ++++++++++ .../selfintro/SelfIntroRepositoryImpl.java | 51 +++++ .../selfintro/dto/SelfIntroResponse.java | 11 + .../ui/selfintro/SelfIntroController.java | 84 +++++++ .../com/atwoz/helper/MockBeanInjection.java | 9 + .../auth/MemberAuthServiceTest.java | 2 +- .../application/auth/OAuth2RequesterTest.java | 2 +- .../member/MemberQueryServiceTest.java | 8 +- .../application/member/MemberServiceTest.java | 10 +- .../selfintro/SelfIntroQueryServiceTest.java | 76 +++++++ .../selfintro/SelfIntroServiceTest.java | 119 ++++++++++ .../{ => member}/MemberProfileTest.java | 3 +- .../domain/{ => member}/MemberRoleTest.java | 2 +- .../domain/{ => member}/MemberTest.java | 17 +- .../profile/MemberHobbiesTest.java | 4 +- .../profile/MemberStylesTest.java | 4 +- .../{ => member}/profile/ProfileTest.java | 7 +- .../profile/physical/PhysicalProfileTest.java | 4 +- .../profile/physical/vo/GenderTest.java | 3 +- .../{ => member}/profile/vo/DrinkTest.java | 3 +- .../{ => member}/profile/vo/GraduateTest.java | 3 +- .../{ => member}/profile/vo/HobbyTest.java | 3 +- .../{ => member}/profile/vo/JobTest.java | 3 +- .../{ => member}/profile/vo/MbtiTest.java | 3 +- .../{ => member}/profile/vo/PositionTest.java | 3 +- .../{ => member}/profile/vo/ReligionTest.java | 3 +- .../{ => member}/profile/vo/SmokeTest.java | 3 +- .../{ => member}/profile/vo/StyleTest.java | 3 +- .../domain/selfintro/SelfIntroTest.java | 90 ++++++++ .../{ => auth}/OAuthProviderFixture.java | 2 +- .../{ => member}/HobbiesResponseFixture.java | 2 +- .../fixture/{ => member}/MemberFixture.java | 18 +- .../{ => member}/MemberProfileDtoFixture.java | 18 +- .../MemberProfileInfoFixture.java | 2 +- .../MemberProfileResponseFixture.java | 2 +- .../{ => member}/MemberRequestFixture.java | 2 +- .../{ => member}/MemberResponseFixture.java | 8 +- .../{ => member}/StylesResponseFixture.java | 2 +- .../fixture/selfintro/SelfIntroFixture.java | 25 +++ .../selfintro/SelfIntroRequestFixture.java | 39 ++++ .../selfintro/SelfIntroResponseFixture.java | 36 +++ .../member/MemberFakeRepository.java | 4 +- .../member/MemberJpaRepositoryTest.java | 2 +- .../member/MemberQueryRepositoryTest.java | 8 +- .../selfintro/SelfIntroFakeRepository.java | 86 ++++++++ .../selfintro/SelfIntroJpaRepositoryTest.java | 71 ++++++ .../SelfIntroQueryRepositoryTest.java | 127 +++++++++++ .../auth/MemberAuthControllerWebMvcTest.java | 2 +- .../MemberControllerAcceptanceFixture.java | 6 +- .../ui/member/MemberControllerWebMvcTest.java | 8 +- .../SelfIntroControllerAcceptanceTest.java | 95 ++++++++ ...fIntroControllerAcceptanceTestFixture.java | 143 ++++++++++++ .../SelfIntroControllerWebMvcTest.java | 208 ++++++++++++++++++ .../MemberLikeQueryRepositoryTest.java | 12 +- ...MemberLikeControllerAcceptanceFixture.java | 2 +- ...erMissionsControllerAcceptanceFixture.java | 2 +- .../ui/ReportControllerAcceptanceFixture.java | 2 +- ...berSurveysControllerAcceptanceFixture.java | 2 +- .../SurveyControllerAcceptanceFixture.java | 2 +- 75 files changed, 1909 insertions(+), 140 deletions(-) create mode 100644 src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/SelfIntroService.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroCreateRequest.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroUpdateRequest.java create mode 100644 src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntrosResponse.java create mode 100644 src/main/java/com/atwoz/member/domain/selfintro/SelfIntro.java create mode 100644 src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java create mode 100644 src/main/java/com/atwoz/member/exception/exceptions/selfintro/InvalidContentException.java create mode 100644 src/main/java/com/atwoz/member/exception/exceptions/selfintro/SelfIntroNotFoundException.java create mode 100644 src/main/java/com/atwoz/member/exception/exceptions/selfintro/WriterNotEqualsException.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepository.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java create mode 100644 src/main/java/com/atwoz/member/infrastructure/selfintro/dto/SelfIntroResponse.java create mode 100644 src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java create mode 100644 src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java create mode 100644 src/test/java/com/atwoz/member/application/selfintro/SelfIntroServiceTest.java rename src/test/java/com/atwoz/member/domain/{ => member}/MemberProfileTest.java (96%) rename src/test/java/com/atwoz/member/domain/{ => member}/MemberRoleTest.java (96%) rename src/test/java/com/atwoz/member/domain/{ => member}/MemberTest.java (86%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/MemberHobbiesTest.java (94%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/MemberStylesTest.java (94%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/ProfileTest.java (95%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/physical/PhysicalProfileTest.java (93%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/physical/vo/GenderTest.java (91%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/DrinkTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/GraduateTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/HobbyTest.java (95%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/JobTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/MbtiTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/PositionTest.java (95%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/ReligionTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/SmokeTest.java (92%) rename src/test/java/com/atwoz/member/domain/{ => member}/profile/vo/StyleTest.java (95%) create mode 100644 src/test/java/com/atwoz/member/domain/selfintro/SelfIntroTest.java rename src/test/java/com/atwoz/member/fixture/{ => auth}/OAuthProviderFixture.java (93%) rename src/test/java/com/atwoz/member/fixture/{ => member}/HobbiesResponseFixture.java (95%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberFixture.java (74%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberProfileDtoFixture.java (59%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberProfileInfoFixture.java (95%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberProfileResponseFixture.java (97%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberRequestFixture.java (99%) rename src/test/java/com/atwoz/member/fixture/{ => member}/MemberResponseFixture.java (56%) rename src/test/java/com/atwoz/member/fixture/{ => member}/StylesResponseFixture.java (95%) create mode 100644 src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java create mode 100644 src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroResponseFixture.java create mode 100644 src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java create mode 100644 src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepositoryTest.java create mode 100644 src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepositoryTest.java create mode 100644 src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java create mode 100644 src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java create mode 100644 src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java diff --git a/src/docs/asciidoc/member.adoc b/src/docs/asciidoc/member.adoc index b0bab758..391a00ae 100644 --- a/src/docs/asciidoc/member.adoc +++ b/src/docs/asciidoc/member.adoc @@ -5,7 +5,11 @@ :sectlinks: :sectnums: -== Member += Member + + +== Auth + === 로그인 (POST api/members/auth/login) @@ -18,6 +22,9 @@ include::{snippets}/member-auth-controller-web-mvc-test/유저_로그인/http-re include::{snippets}/member-auth-controller-web-mvc-test/유저_로그인/request-fields.adoc[] +== Member + + === 닉네임 중복 확인 (GET /api/members/nickname/existence) ==== 요청 @@ -41,6 +48,7 @@ include::{snippets}/member-controller-web-mvc-test/회원_정보_초기화/http- === 회원 정보 조회(GET /api/members) + ==== 요청 include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/request-headers.adoc[] include::{snippets}/member-controller-web-mvc-test/회원_정보_조회/http-request.adoc[] @@ -69,3 +77,64 @@ include::{snippets}/member-controller-web-mvc-test/회원_삭제/http-request.ad ==== 응답 include::{snippets}/member-controller-web-mvc-test/회원_삭제/http-response.adoc[] + + +== SelfIntro + + +=== 셀프 소개글 저장 (POST /api/members/self-intros/me) + +==== 요청 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/http-request.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/request-headers.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/request-fields.adoc[] + +==== 응답 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_저장/http-response.adoc[] + + +=== 셀프 소개글 페이징 조회 (GET /api/members/self-intros) + +==== 요청 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/http-request.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/request-headers.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/request-parts.adoc[] + +==== 응답 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/http-response.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회/response-fields.adoc[] + + +=== 셀프 소개글 페이징 조회 (필터 적용) (Get /api/members/self-intros/filter) + +==== 요청 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회(필터_적용)/http-request.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회(필터_적용)/request-headers.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회(필터_적용)/request-parts.adoc[] + +==== 응답 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회(필터_적용)/http-response.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_페이징_조회(필터_적용)/response-fields.adoc[] + + +=== 셀프 소개글 변경 (Patch /api/members/self-intros/{id}) + +==== 요청 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_변경/http-request.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_변경/request-headers.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_변경/path-parameters.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_변경/request-fields.adoc[] + +==== 응답 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_변경/http-response.adoc[] + + +=== 셀프 소개글 삭제 (Delete /api/members/self-intros/{id}) + +==== 요청 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_삭제/http-request.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_삭제/request-headers.adoc[] +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_삭제/path-parameters.adoc[] + +==== 응답 +include::{snippets}/self-intro-controller-web-mvc-test/셀프_소개글_삭제/http-response.adoc[] diff --git a/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java new file mode 100644 index 00000000..a5c6b66f --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroQueryService.java @@ -0,0 +1,41 @@ +package com.atwoz.member.application.selfintro; + +import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntrosResponse; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +@Service +@Transactional(readOnly = true) +public class SelfIntroQueryService { + + private final SelfIntroRepository selfIntroRepository; + + public SelfIntrosResponse findAllSelfIntrosWithPaging(final Pageable pageable, + final Long memberId) { + Page selfIntroResponses = selfIntroRepository.findAllSelfIntrosWithPaging(pageable, memberId); + + return SelfIntrosResponse.of(selfIntroResponses, pageable); + } + + public SelfIntrosResponse findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, + final SelfIntroFilterRequest selfIntroFilterRequest, + final Long memberId) { + Page selfIntroResponses = selfIntroRepository.findAllSelfIntrosWithPagingAndFiltering( + pageable, + selfIntroFilterRequest.minAge(), + selfIntroFilterRequest.maxAge(), + selfIntroFilterRequest.isOnlyOppositeGender(), + selfIntroFilterRequest.getCities(), + memberId + ); + + return SelfIntrosResponse.of(selfIntroResponses, pageable); + } +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/SelfIntroService.java b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroService.java new file mode 100644 index 00000000..4a405926 --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/SelfIntroService.java @@ -0,0 +1,43 @@ +package com.atwoz.member.application.selfintro; + +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.exception.exceptions.selfintro.SelfIntroNotFoundException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@RequiredArgsConstructor +@Service +@Transactional +public class SelfIntroService { + + private final SelfIntroRepository selfIntroRepository; + + public void saveSelfIntro(final SelfIntroCreateRequest selfIntroCreateRequest, + final Long memberId) { + SelfIntro selfIntro = SelfIntro.createWith(memberId, selfIntroCreateRequest.content()); + selfIntroRepository.save(selfIntro); + } + + public void updateSelfIntro(final SelfIntroUpdateRequest selfIntroUpdateRequest, + final Long selfIntroId, + final Long memberId) { + SelfIntro foundSelfIntro = findSelfIntroById(selfIntroId); + foundSelfIntro.validateSameWriter(memberId); + foundSelfIntro.update(selfIntroUpdateRequest.content()); + } + + public void deleteSelfIntro(final Long selfIntroId, final Long memberId) { + SelfIntro foundSelfIntro = findSelfIntroById(selfIntroId); + foundSelfIntro.validateSameWriter(memberId); + selfIntroRepository.deleteById(foundSelfIntro.getId()); + } + + private SelfIntro findSelfIntroById(final Long selfIntroId) { + return selfIntroRepository.findById(selfIntroId) + .orElseThrow(SelfIntroNotFoundException::new); + } +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java new file mode 100644 index 00000000..99c22587 --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/CityRequest.java @@ -0,0 +1,10 @@ +package com.atwoz.member.application.selfintro.dto; + +import jakarta.validation.constraints.NotBlank; + +public record CityRequest( + + @NotBlank(message = "선호하는 지역 정보를 입력해주세요.") + String city +) { +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroCreateRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroCreateRequest.java new file mode 100644 index 00000000..e79db73c --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroCreateRequest.java @@ -0,0 +1,10 @@ +package com.atwoz.member.application.selfintro.dto; + +import jakarta.validation.constraints.NotBlank; + +public record SelfIntroCreateRequest( + + @NotBlank(message = "소개글을 입력해주세요") + String content +) { +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java new file mode 100644 index 00000000..c133541f --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroFilterRequest.java @@ -0,0 +1,29 @@ +package com.atwoz.member.application.selfintro.dto; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import java.util.List; + +public record SelfIntroFilterRequest( + + @NotNull(message = "최소 나이를 입력해주세요") + Integer minAge, + + @NotNull(message = "최대 나이를 입력해주세요") + Integer maxAge, + + @NotNull(message = "성별을 선택해주세요") + Boolean isOnlyOppositeGender, + + @Valid + @NotEmpty(message = "선호 지역을 하나 이상 입력해주세요.") + List cityRequests +) { + + public List getCities() { + return cityRequests.stream() + .map(CityRequest::city) + .toList(); + } +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroUpdateRequest.java b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroUpdateRequest.java new file mode 100644 index 00000000..29bff727 --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntroUpdateRequest.java @@ -0,0 +1,10 @@ +package com.atwoz.member.application.selfintro.dto; + +import jakarta.validation.constraints.NotBlank; + +public record SelfIntroUpdateRequest( + + @NotBlank(message = "소개글을 입력해주세요") + String content +) { +} diff --git a/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntrosResponse.java b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntrosResponse.java new file mode 100644 index 00000000..1f8c95e1 --- /dev/null +++ b/src/main/java/com/atwoz/member/application/selfintro/dto/SelfIntrosResponse.java @@ -0,0 +1,35 @@ +package com.atwoz.member.application.selfintro.dto; + +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import java.util.List; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public record SelfIntrosResponse( + List selfIntros, + int nowPage, + int nextPage, + int totalPages +) { + + private static final int NEXT_PAGE_INDEX = 1; + private static final int NO_MORE_PAGE = -1; + + public static SelfIntrosResponse of(final Page selfIntros, + final Pageable pageable) { + return new SelfIntrosResponse( + selfIntros.getContent(), + pageable.getPageNumber(), + getNextPage(pageable.getPageNumber(), selfIntros), + selfIntros.getTotalPages() + ); + } + + private static int getNextPage(final int pageNumber, final Page selfIntros) { + if (selfIntros.hasNext()) { + return pageNumber + NEXT_PAGE_INDEX; + } + + return NO_MORE_PAGE; + } +} diff --git a/src/main/java/com/atwoz/member/config/MemberAuthConfig.java b/src/main/java/com/atwoz/member/config/MemberAuthConfig.java index 8dac265f..703a4c97 100644 --- a/src/main/java/com/atwoz/member/config/MemberAuthConfig.java +++ b/src/main/java/com/atwoz/member/config/MemberAuthConfig.java @@ -37,11 +37,13 @@ private HandlerInterceptor loginValidCheckerInterceptor() { .excludePathPattern("/**", OPTIONS) .excludePathPattern("/api/missions/**", GET, POST, PATCH, DELETE) .excludePathPattern("/api/surveys/**", GET, POST) + .excludePathPattern("/api/members/auth/**", POST) .addPathPatterns("/api/members/**", GET, POST, PATCH, DELETE) .addPathPatterns("/api/reports/**", POST) .addPathPatterns("/api/surveys/**", GET, POST) .addPathPatterns("/api/members/me/missions/**", GET, POST, PATCH) - .addPathPatterns("/api/members/me/surveys/**", GET, POST); + .addPathPatterns("/api/members/me/surveys/**", GET, POST) + .addPathPatterns("/api/members/self-intros/**", GET, POST, PATCH, DELETE); } @Override diff --git a/src/main/java/com/atwoz/member/domain/selfintro/SelfIntro.java b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntro.java new file mode 100644 index 00000000..8b27499e --- /dev/null +++ b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntro.java @@ -0,0 +1,66 @@ +package com.atwoz.member.domain.selfintro; + +import com.atwoz.global.domain.BaseEntity; +import com.atwoz.member.exception.exceptions.selfintro.InvalidContentException; +import com.atwoz.member.exception.exceptions.selfintro.WriterNotEqualsException; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import java.util.Objects; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Getter +@Builder +@EqualsAndHashCode(of = "id", callSuper = false) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Entity +public class SelfIntro extends BaseEntity { + + private static final int MIN_LENGTH = 1; + private static final int MAX_LENGTH = 30; + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false) + private Long memberId; + + @Column(length = MAX_LENGTH, nullable = false) + private String content; + + public static SelfIntro createWith(final Long memberId, + final String content) { + validateContent(content); + return SelfIntro.builder() + .memberId(memberId) + .content(content) + .build(); + } + + private static void validateContent(final String content) { + int contentLength = content.length(); + if (contentLength < MIN_LENGTH || MAX_LENGTH < contentLength) { + throw new InvalidContentException(); + } + } + + public void validateSameWriter(final Long memberId) { + if (!Objects.equals(this.memberId, memberId)) { + throw new WriterNotEqualsException(); + } + } + + public void update(final String content) { + validateContent(content); + this.content = content; + } +} diff --git a/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java new file mode 100644 index 00000000..6f8b9b33 --- /dev/null +++ b/src/main/java/com/atwoz/member/domain/selfintro/SelfIntroRepository.java @@ -0,0 +1,22 @@ +package com.atwoz.member.domain.selfintro; + +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import java.util.List; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; + +public interface SelfIntroRepository { + + SelfIntro save(SelfIntro selfIntro); + + Optional findById(Long id); + + void deleteById(Long id); + + Page findAllSelfIntrosWithPaging(Pageable pageable, Long memberId); + + Page findAllSelfIntrosWithPagingAndFiltering(Pageable pageable, int minAge, int maxAge, + boolean isOnlyOppositeGender, List cities, + Long memberId); +} diff --git a/src/main/java/com/atwoz/member/exception/MemberExceptionHandler.java b/src/main/java/com/atwoz/member/exception/MemberExceptionHandler.java index cd13c9e0..258d6017 100644 --- a/src/main/java/com/atwoz/member/exception/MemberExceptionHandler.java +++ b/src/main/java/com/atwoz/member/exception/MemberExceptionHandler.java @@ -31,6 +31,9 @@ import com.atwoz.member.exception.exceptions.member.profile.StyleSizeException; import com.atwoz.member.exception.exceptions.member.profile.physical.AgeRangeException; import com.atwoz.member.exception.exceptions.member.profile.physical.HeightRangeException; +import com.atwoz.member.exception.exceptions.selfintro.InvalidContentException; +import com.atwoz.member.exception.exceptions.selfintro.SelfIntroNotFoundException; +import com.atwoz.member.exception.exceptions.selfintro.WriterNotEqualsException; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; @@ -41,177 +44,177 @@ public class MemberExceptionHandler { @ExceptionHandler(RoleNotFoundException.class) public ResponseEntity handleRoleNotFoundException(final RoleNotFoundException e) { - return getNotFoundResponse(e); + return getErrorMessageWithStatus(e, HttpStatus.NOT_FOUND); } @ExceptionHandler(MemberNicknameAlreadyExistedException.class) public ResponseEntity handleMemberNicknameAlreadyExistedException( final MemberNicknameAlreadyExistedException e) { - return getConflicted(e); + return getErrorMessageWithStatus(e, HttpStatus.CONFLICT); } @ExceptionHandler(MemberAlreadyExistedException.class) public ResponseEntity handleMemberAlreadyExistedException(final MemberAlreadyExistedException e) { - return getConflicted(e); + return getErrorMessageWithStatus(e, HttpStatus.CONFLICT); } @ExceptionHandler(MemberNotFoundException.class) public ResponseEntity handleMemberNotFoundException(final MemberNotFoundException e) { - return getNotFoundResponse(e); + return getErrorMessageWithStatus(e, HttpStatus.NOT_FOUND); } @ExceptionHandler(SignatureInvalidException.class) public ResponseEntity handleSignatureInvalidException(final SignatureInvalidException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(TokenFormInvalidException.class) public ResponseEntity handleTokenFormInvalidException(final TokenFormInvalidException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(ExpiredTokenException.class) public ResponseEntity handleExpiredTokenException(final ExpiredTokenException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(UnsupportedTokenException.class) public ResponseEntity handleUnsupportedTokenException(final UnsupportedTokenException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(TokenInvalidException.class) public ResponseEntity handleTokenInvalidException(final TokenInvalidException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(MemberLoginInvalidException.class) public ResponseEntity handleLoginInvalidException(final MemberLoginInvalidException e) { - return getUnauthorized(e); + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } @ExceptionHandler(JsonDataInvalidException.class) public ResponseEntity handleJsonDataInvalidException(final JsonDataInvalidException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(OAuthPlatformNotFountException.class) public ResponseEntity handleOAuthPlatformNotFountException(final OAuthPlatformNotFountException e) { - return getNotFoundResponse(e); + return getErrorMessageWithStatus(e, HttpStatus.NOT_FOUND); } @ExceptionHandler(InvalidHobbyException.class) public ResponseEntity handleHobbyInvalidException(final InvalidHobbyException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(HobbySizeException.class) public ResponseEntity handleHobbySizeException(final HobbySizeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(HobbyDuplicateException.class) public ResponseEntity handleHobbyDuplicationException(final HobbyDuplicateException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidStyleException.class) public ResponseEntity handleStyleInvalidException(final InvalidStyleException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(StyleSizeException.class) public ResponseEntity handleStyleSizeException(final StyleSizeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(StyleDuplicateException.class) public ResponseEntity handleStyleDuplicateException(final StyleDuplicateException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(AgeRangeException.class) public ResponseEntity handleAgeRangeException(final AgeRangeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(HeightRangeException.class) public ResponseEntity handleHeightRangeException(final HeightRangeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidGenderException.class) public ResponseEntity handleGenderInvalidException(final InvalidGenderException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(LatitudeRangeException.class) public ResponseEntity handleLatitudeRangeException(final LatitudeRangeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(LongitudeRangeException.class) public ResponseEntity handleLongitudeRangeException(final LongitudeRangeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidJobException.class) public ResponseEntity handleJobInvalidException(final InvalidJobException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidDrinkException.class) public ResponseEntity handleDrinkNInvalidException(final InvalidDrinkException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidGraduateException.class) public ResponseEntity handleGraduateInvalidException(final InvalidGraduateException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidMbtiException.class) public ResponseEntity handleMbtiInvalidException(final InvalidMbtiException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidSmokeException.class) public ResponseEntity handleSmokeInvalidException(final InvalidSmokeException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidReligionException.class) public ResponseEntity handleReligionInvalidException(final InvalidReligionException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidProfileAccessStatusException.class) public ResponseEntity handleProfileInvalidException(final InvalidProfileAccessStatusException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } @ExceptionHandler(InvalidJsonKeyException.class) public ResponseEntity handleJsonKeyInvalidException(final InvalidJsonKeyException e) { - return getBadRequest(e); + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } - private ResponseEntity getNotFoundResponse(final Exception e) { - return ResponseEntity.status(HttpStatus.NOT_FOUND) - .body(e.getMessage()); + @ExceptionHandler(InvalidContentException.class) + public ResponseEntity handleContentInvalidException(final InvalidContentException e) { + return getErrorMessageWithStatus(e, HttpStatus.BAD_REQUEST); } - private ResponseEntity getUnauthorized(final Exception e) { - return ResponseEntity.status(HttpStatus.UNAUTHORIZED) - .body(e.getMessage()); + @ExceptionHandler(SelfIntroNotFoundException.class) + public ResponseEntity handleSelfIntroNotFoundException(final SelfIntroNotFoundException e) { + return getErrorMessageWithStatus(e, HttpStatus.NOT_FOUND); } - private ResponseEntity getConflicted(final Exception e) { - return ResponseEntity.status(HttpStatus.CONFLICT) - .body(e.getMessage()); + @ExceptionHandler(WriterNotEqualsException.class) + public ResponseEntity handleWriterNotEqualsException(final WriterNotEqualsException e) { + return getErrorMessageWithStatus(e, HttpStatus.UNAUTHORIZED); } - private ResponseEntity getBadRequest(final Exception e) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST) + private ResponseEntity getErrorMessageWithStatus(final Exception e, final HttpStatus status) { + return ResponseEntity.status(status) .body(e.getMessage()); } } diff --git a/src/main/java/com/atwoz/member/exception/exceptions/selfintro/InvalidContentException.java b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/InvalidContentException.java new file mode 100644 index 00000000..e74ca3fb --- /dev/null +++ b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/InvalidContentException.java @@ -0,0 +1,8 @@ +package com.atwoz.member.exception.exceptions.selfintro; + +public class InvalidContentException extends RuntimeException { + + public InvalidContentException() { + super("소개글 입력이 올바르지 않습니다."); + } +} diff --git a/src/main/java/com/atwoz/member/exception/exceptions/selfintro/SelfIntroNotFoundException.java b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/SelfIntroNotFoundException.java new file mode 100644 index 00000000..2e21d99b --- /dev/null +++ b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/SelfIntroNotFoundException.java @@ -0,0 +1,8 @@ +package com.atwoz.member.exception.exceptions.selfintro; + +public class SelfIntroNotFoundException extends RuntimeException { + + public SelfIntroNotFoundException() { + super("셀프 소개글을 찾을 수 없습니다."); + } +} diff --git a/src/main/java/com/atwoz/member/exception/exceptions/selfintro/WriterNotEqualsException.java b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/WriterNotEqualsException.java new file mode 100644 index 00000000..37defe77 --- /dev/null +++ b/src/main/java/com/atwoz/member/exception/exceptions/selfintro/WriterNotEqualsException.java @@ -0,0 +1,8 @@ +package com.atwoz.member.exception.exceptions.selfintro; + +public class WriterNotEqualsException extends RuntimeException { + + public WriterNotEqualsException() { + super("글쓴이가 일치하지 않습니다"); + } +} diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepository.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepository.java new file mode 100644 index 00000000..637ee89e --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepository.java @@ -0,0 +1,14 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.member.domain.selfintro.SelfIntro; +import java.util.Optional; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SelfIntroJpaRepository extends JpaRepository { + + SelfIntro save(SelfIntro selfIntro); + + Optional findById(Long selfIntroId); + + void deleteById(Long selfIntroId); +} diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java new file mode 100644 index 00000000..22987cd9 --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepository.java @@ -0,0 +1,112 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.member.domain.member.profile.physical.vo.Gender; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import com.querydsl.core.QueryResults; +import com.querydsl.core.types.dsl.BooleanExpression; +import com.querydsl.jpa.impl.JPAQuery; +import com.querydsl.jpa.impl.JPAQueryFactory; +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +import static com.atwoz.member.domain.member.QMember.member; +import static com.atwoz.member.domain.member.QMemberProfile.memberProfile; +import static com.atwoz.member.domain.member.profile.QProfile.profile; +import static com.atwoz.member.domain.member.profile.physical.QPhysicalProfile.physicalProfile; +import static com.atwoz.member.domain.selfintro.QSelfIntro.selfIntro; +import static com.querydsl.core.types.Projections.constructor; + +@RequiredArgsConstructor +@Repository +public class SelfIntroQueryRepository { + + private final JPAQueryFactory jpaQueryFactory; + + public Page findAllSelfIntroWithPaging(final Pageable pageable, + final Long memberId) { + QueryResults result = selectSelfIntroResponse() + .from(member) + .leftJoin(member.memberProfile, memberProfile) + .leftJoin(memberProfile.profile, profile) + .leftJoin(profile.physicalProfile, physicalProfile) + .leftJoin(selfIntro).on(member.id.eq(selfIntro.memberId)) + .orderBy(selfIntro.createdAt.desc()) + .where(selfIntro.memberId.eq(memberId)) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetchResults(); + + return new PageImpl<>(result.getResults(), pageable, result.getTotal()); + } + + private JPAQuery selectSelfIntroResponse() { + return jpaQueryFactory.select( + constructor(SelfIntroResponse.class, + selfIntro.id, + selfIntro.content, + member.nickname, + profile.location.city, + physicalProfile.age, + physicalProfile.height + ) + ); + } + + private Gender findMemberGender(final Long memberId) { + return jpaQueryFactory.select(physicalProfile.gender) + .from(member) + .leftJoin(member.memberProfile, memberProfile) + .leftJoin(memberProfile.profile, profile) + .leftJoin(profile.physicalProfile, physicalProfile) + .where(member.id.eq(memberId)) + .fetchFirst(); + } + + public Page findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, + final int minAge, + final int maxAge, + final boolean isOnlyOppositeGender, + final List cities, + final Long memberId) { + Gender memberGender = findMemberGender(memberId); + QueryResults result = selectSelfIntroResponse() + .from(member) + .leftJoin(member.memberProfile, memberProfile) + .leftJoin(memberProfile.profile, profile) + .leftJoin(profile.physicalProfile, physicalProfile) + .leftJoin(selfIntro).on(member.id.eq(selfIntro.memberId)) + .orderBy(selfIntro.createdAt.desc()) + .where( + applyGenderCondition(isOnlyOppositeGender, memberGender), + ageBetween(minAge, maxAge), + locationIn(cities), + selfIntro.memberId.eq(memberId) + ) + .offset(pageable.getOffset()) + .limit(pageable.getPageSize()) + .fetchResults(); + + return new PageImpl<>(result.getResults(), pageable, result.getTotal()); + } + + private BooleanExpression applyGenderCondition(final boolean isOnlyOppositeGender, final Gender gender) { + if (!isOnlyOppositeGender) { + return null; + } + + return physicalProfile.gender.ne(gender); + } + + private BooleanExpression ageBetween(final int minAge, final int maxAge) { + return physicalProfile.age.goe(minAge) + .and(physicalProfile.age.loe(maxAge)); + } + + private BooleanExpression locationIn(final List cities) { + return profile.location.city.in(cities); + } +} diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java new file mode 100644 index 00000000..9dbaf270 --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/SelfIntroRepositoryImpl.java @@ -0,0 +1,51 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import java.util.List; +import java.util.Optional; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Repository; + +@RequiredArgsConstructor +@Repository +public class SelfIntroRepositoryImpl implements SelfIntroRepository { + + private final SelfIntroJpaRepository selfIntroJpaRepository; + private final SelfIntroQueryRepository selfIntroQueryRepository; + + @Override + public SelfIntro save(final SelfIntro selfIntro) { + return selfIntroJpaRepository.save(selfIntro); + } + + @Override + public Optional findById(final Long id) { + return selfIntroJpaRepository.findById(id); + } + + @Override + public void deleteById(final Long id) { + selfIntroJpaRepository.deleteById(id); + } + + @Override + public Page findAllSelfIntrosWithPaging(final Pageable pageable, + final Long memberId) { + return selfIntroQueryRepository.findAllSelfIntroWithPaging(pageable, memberId); + } + + @Override + public Page findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, + final int minAge, + final int maxAge, + final boolean isOnlyOppositeGender, + final List cities, + final Long memberId) { + return selfIntroQueryRepository.findAllSelfIntrosWithPagingAndFiltering(pageable, minAge, maxAge, + isOnlyOppositeGender, cities, memberId); + } +} diff --git a/src/main/java/com/atwoz/member/infrastructure/selfintro/dto/SelfIntroResponse.java b/src/main/java/com/atwoz/member/infrastructure/selfintro/dto/SelfIntroResponse.java new file mode 100644 index 00000000..46ea0a3e --- /dev/null +++ b/src/main/java/com/atwoz/member/infrastructure/selfintro/dto/SelfIntroResponse.java @@ -0,0 +1,11 @@ +package com.atwoz.member.infrastructure.selfintro.dto; + +public record SelfIntroResponse( + Long selfIntroId, + String selfIntroContent, + String nickname, + String city, + int age, + int height +) { +} diff --git a/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java b/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java new file mode 100644 index 00000000..a814ce94 --- /dev/null +++ b/src/main/java/com/atwoz/member/ui/selfintro/SelfIntroController.java @@ -0,0 +1,84 @@ +package com.atwoz.member.ui.selfintro; + + +import com.atwoz.member.application.selfintro.SelfIntroQueryService; +import com.atwoz.member.application.selfintro.SelfIntroService; +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntrosResponse; +import com.atwoz.member.ui.auth.support.AuthMember; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/api/members/self-intros") +public class SelfIntroController { + + private static final String CREATION_TIME = "createdAt"; + + private final SelfIntroService selfIntroService; + private final SelfIntroQueryService selfIntroQueryService; + + @PostMapping("/me") + public ResponseEntity saveSelfIntro(@RequestBody @Valid final SelfIntroCreateRequest selfIntroCreateRequest, + @AuthMember final Long memberId) { + selfIntroService.saveSelfIntro(selfIntroCreateRequest, memberId); + + return ResponseEntity.ok() + .build(); + } + + @GetMapping + public ResponseEntity findAllSelfIntrosWithPaging( + @PageableDefault(sort = CREATION_TIME, direction = Direction.DESC) final Pageable pageable, + @AuthMember final Long memberId + ) { + return ResponseEntity.ok(selfIntroQueryService.findAllSelfIntrosWithPaging(pageable, memberId)); + } + + @GetMapping("/filter") + public ResponseEntity findAllSelfIntrosWithPagingAndFiltering( + @PageableDefault(sort = CREATION_TIME, direction = Direction.DESC) final Pageable pageable, + @ModelAttribute @Valid final SelfIntroFilterRequest selfIntroFilterRequest, + @AuthMember final Long memberId + ) { + return ResponseEntity.ok( + selfIntroQueryService.findAllSelfIntrosWithPagingAndFiltering(pageable, selfIntroFilterRequest, + memberId)); + } + + @PatchMapping("/{id}") + public ResponseEntity updateSelfIntro(@PathVariable("id") final Long selfIntroId, + @RequestBody @Valid final SelfIntroUpdateRequest selfIntroUpdateRequest, + @AuthMember final Long memberId + ) { + selfIntroService.updateSelfIntro(selfIntroUpdateRequest, selfIntroId, memberId); + + return ResponseEntity.ok() + .build(); + } + + @DeleteMapping("/{id}") + public ResponseEntity deleteSelfIntro(@PathVariable("id") final Long selfIntroId, + @AuthMember final Long memberId) { + selfIntroService.deleteSelfIntro(selfIntroId, memberId); + + return ResponseEntity.noContent() + .build(); + } +} diff --git a/src/test/java/com/atwoz/helper/MockBeanInjection.java b/src/test/java/com/atwoz/helper/MockBeanInjection.java index bfdb248c..511eba7f 100644 --- a/src/test/java/com/atwoz/helper/MockBeanInjection.java +++ b/src/test/java/com/atwoz/helper/MockBeanInjection.java @@ -9,6 +9,8 @@ import com.atwoz.member.application.auth.MemberAuthService; import com.atwoz.member.application.member.MemberQueryService; import com.atwoz.member.application.member.MemberService; +import com.atwoz.member.application.selfintro.SelfIntroQueryService; +import com.atwoz.member.application.selfintro.SelfIntroService; import com.atwoz.member.domain.auth.JsonMapper; import com.atwoz.member.domain.auth.MemberTokenProvider; import com.atwoz.member.domain.member.MemberRepository; @@ -122,4 +124,11 @@ public class MockBeanInjection { @MockBean protected MemberLikeService memberLikeService; + + // SelfIntro + @MockBean + protected SelfIntroQueryService selfIntroQueryService; + + @MockBean + protected SelfIntroService selfIntroService; } diff --git a/src/test/java/com/atwoz/member/application/auth/MemberAuthServiceTest.java b/src/test/java/com/atwoz/member/application/auth/MemberAuthServiceTest.java index 2c7bf9ec..963ab7d6 100644 --- a/src/test/java/com/atwoz/member/application/auth/MemberAuthServiceTest.java +++ b/src/test/java/com/atwoz/member/application/auth/MemberAuthServiceTest.java @@ -12,7 +12,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import static com.atwoz.member.fixture.OAuthProviderFixture.인증_기관_생성; +import static com.atwoz.member.fixture.auth.OAuthProviderFixture.인증_기관_생성; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import static org.mockito.ArgumentMatchers.any; diff --git a/src/test/java/com/atwoz/member/application/auth/OAuth2RequesterTest.java b/src/test/java/com/atwoz/member/application/auth/OAuth2RequesterTest.java index a97935bb..46b011b3 100644 --- a/src/test/java/com/atwoz/member/application/auth/OAuth2RequesterTest.java +++ b/src/test/java/com/atwoz/member/application/auth/OAuth2RequesterTest.java @@ -13,7 +13,7 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import static com.atwoz.member.fixture.OAuthProviderFixture.인증_기관_생성; +import static com.atwoz.member.fixture.auth.OAuthProviderFixture.인증_기관_생성; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.anyString; diff --git a/src/test/java/com/atwoz/member/application/member/MemberQueryServiceTest.java b/src/test/java/com/atwoz/member/application/member/MemberQueryServiceTest.java index 8c2c333f..1a9e55ce 100644 --- a/src/test/java/com/atwoz/member/application/member/MemberQueryServiceTest.java +++ b/src/test/java/com/atwoz/member/application/member/MemberQueryServiceTest.java @@ -11,10 +11,10 @@ import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; -import static com.atwoz.member.fixture.HobbiesResponseFixture.취미_응답서_요청; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberProfileResponseFixture.회원_프로필_응답서_요청; -import static com.atwoz.member.fixture.StylesResponseFixture.스타일_응답서_요청; +import static com.atwoz.member.fixture.member.HobbiesResponseFixture.취미_응답서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberProfileResponseFixture.회원_프로필_응답서_요청; +import static com.atwoz.member.fixture.member.StylesResponseFixture.스타일_응답서_요청; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; diff --git a/src/test/java/com/atwoz/member/application/member/MemberServiceTest.java b/src/test/java/com/atwoz/member/application/member/MemberServiceTest.java index 51c57dc6..700152f4 100644 --- a/src/test/java/com/atwoz/member/application/member/MemberServiceTest.java +++ b/src/test/java/com/atwoz/member/application/member/MemberServiceTest.java @@ -7,7 +7,7 @@ import com.atwoz.member.exception.exceptions.member.MemberAlreadyExistedException; import com.atwoz.member.exception.exceptions.member.MemberNicknameAlreadyExistedException; import com.atwoz.member.exception.exceptions.member.MemberNotFoundException; -import com.atwoz.member.fixture.MemberRequestFixture; +import com.atwoz.member.fixture.member.MemberRequestFixture; import com.atwoz.member.infrastructure.member.MemberFakeRepository; import com.atwoz.member.infrastructure.member.physical.FakeYearManager; import java.util.Optional; @@ -19,10 +19,10 @@ import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.junit.jupiter.MockitoExtension; -import static com.atwoz.member.fixture.MemberFixture.PASS_인증만_완료한_유저_생성; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_수정_요청서_요청; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_초기화_요청서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.PASS_인증만_완료한_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_수정_요청서_요청; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_초기화_요청서_요청; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java new file mode 100644 index 00000000..f75ae22d --- /dev/null +++ b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroQueryServiceTest.java @@ -0,0 +1,76 @@ +package com.atwoz.member.application.selfintro; + +import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntrosResponse; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.infrastructure.selfintro.SelfIntroFakeRepository; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Test; +import org.springframework.data.domain.PageRequest; + +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_있음; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_필터_요청서; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroQueryServiceTest { + + private SelfIntroQueryService selfIntroQueryService; + private SelfIntroRepository selfIntroRepository; + + @BeforeEach + void setup() { + selfIntroRepository = new SelfIntroFakeRepository(); + selfIntroQueryService = new SelfIntroQueryService(selfIntroRepository); + } + + @Test + void 셀프_소개글을_페이징으로_조회한다() { + // given + SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); + PageRequest pageRequest = PageRequest.of(0, 10); + selfIntroRepository.save(selfIntro); + + // when + SelfIntrosResponse result = selfIntroQueryService.findAllSelfIntrosWithPaging(pageRequest, + selfIntro.getMemberId()); + + // then + assertSoftly(softly -> { + softly.assertThat(result.nowPage()).isEqualTo(0); + softly.assertThat(result.nextPage()).isEqualTo(-1); + softly.assertThat(result.totalPages()).isEqualTo(1); + SelfIntroResponse selfIntroResponse = result.selfIntros().get(0); + softly.assertThat(selfIntroResponse.selfIntroId()).isEqualTo(selfIntro.getId()); + softly.assertThat(selfIntroResponse.selfIntroContent()).isEqualTo(selfIntro.getContent()); + }); + } + + @Test + void 필터를_적용한_셀프_소개글을_페이징으로_조회한다() { + // given + SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); + SelfIntroFilterRequest selfIntroFilterRequest = 셀프_소개글_필터_요청서(); + PageRequest pageRequest = PageRequest.of(0, 10); + selfIntroRepository.save(selfIntro); + + // when + SelfIntrosResponse result = selfIntroQueryService.findAllSelfIntrosWithPagingAndFiltering(pageRequest, + selfIntroFilterRequest, selfIntro.getMemberId()); + + // then + assertSoftly(softly -> { + softly.assertThat(result.nowPage()).isEqualTo(0); + softly.assertThat(result.nextPage()).isEqualTo(-1); + softly.assertThat(result.totalPages()).isEqualTo(1); + SelfIntroResponse selfIntroResponse = result.selfIntros().get(0); + softly.assertThat(selfIntroResponse.selfIntroId()).isEqualTo(selfIntro.getId()); + softly.assertThat(selfIntroResponse.selfIntroContent()).isEqualTo(selfIntro.getContent()); + }); + } +} diff --git a/src/test/java/com/atwoz/member/application/selfintro/SelfIntroServiceTest.java b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroServiceTest.java new file mode 100644 index 00000000..778a1730 --- /dev/null +++ b/src/test/java/com/atwoz/member/application/selfintro/SelfIntroServiceTest.java @@ -0,0 +1,119 @@ +package com.atwoz.member.application.selfintro; + +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.exception.exceptions.selfintro.SelfIntroNotFoundException; +import com.atwoz.member.infrastructure.selfintro.SelfIntroFakeRepository; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_있음; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_생성_요청서; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_수정_요청서; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroServiceTest { + + private SelfIntroService selfIntroService; + private SelfIntroRepository selfIntroRepository; + + @BeforeEach + void setup() { + selfIntroRepository = new SelfIntroFakeRepository(); + selfIntroService = new SelfIntroService(selfIntroRepository); + } + + @Test + void 셀프_소개글을_저장한다() { + // given + SelfIntroCreateRequest selfIntroCreateRequest = 셀프_소개글_생성_요청서(); + Long memberId = 1L; + + // when + selfIntroService.saveSelfIntro(selfIntroCreateRequest, memberId); + Optional foundSelfIntro = selfIntroRepository.findById(1L); + + // then + assertSoftly(softly -> { + softly.assertThat(foundSelfIntro).isNotEmpty(); + SelfIntro selfIntro = foundSelfIntro.get(); + softly.assertThat(selfIntro.getContent()).isEqualTo(selfIntroCreateRequest.content()); + }); + } + + @Nested + class 셀프_소개글_수정 { + + @Test + void 셀프_소개글을_수정한다() { + // given + SelfIntro createdSelfIntro = 셀프_소개글_생성_id_있음(1L); + selfIntroRepository.save(createdSelfIntro); + SelfIntroUpdateRequest selfIntroUpdateRequest = 셀프_소개글_수정_요청서(); + + // when + selfIntroService.updateSelfIntro(selfIntroUpdateRequest, createdSelfIntro.getId(), + createdSelfIntro.getMemberId()); + Optional foundSelfIntro = selfIntroRepository.findById(createdSelfIntro.getId()); + + // then + assertSoftly(softly -> { + softly.assertThat(foundSelfIntro).isNotEmpty(); + SelfIntro selfIntro = foundSelfIntro.get(); + softly.assertThat(selfIntro).usingRecursiveComparison() + .isEqualTo(selfIntro); + }); + } + + @Test + void 수정하려는_셀프_소개글이_존재하지_않으면_예외가_발생한다() { + // given + SelfIntro createdSelfIntro = 셀프_소개글_생성_id_있음(1L); + selfIntroRepository.save(createdSelfIntro); + SelfIntroUpdateRequest selfIntroUpdateRequest = 셀프_소개글_수정_요청서(); + Long inValidSelfIntroId = 2L; + + // when & then + assertThatThrownBy(() -> selfIntroService.updateSelfIntro(selfIntroUpdateRequest, inValidSelfIntroId, + createdSelfIntro.getMemberId())).isInstanceOf(SelfIntroNotFoundException.class); + } + } + + @Nested + class 셀프_소개글_삭제 { + + @Test + void 셀프_소개글을_삭제한다() { + // given + SelfIntro createdSelfIntro = 셀프_소개글_생성_id_있음(1L); + selfIntroRepository.save(createdSelfIntro); + + // when + selfIntroService.deleteSelfIntro(createdSelfIntro.getId(), createdSelfIntro.getMemberId()); + + // then + assertThat(selfIntroRepository.findById(createdSelfIntro.getId())).isEmpty(); + } + + @Test + void 삭제하려는_셀프_소개글이_존재하지_않으면_예외가_발생한다() { + SelfIntro createdSelfIntro = 셀프_소개글_생성_id_있음(1L); + selfIntroRepository.save(createdSelfIntro); + Long inValidSelfIntroId = 2L; + + // when & then + assertThatThrownBy(() -> selfIntroService.deleteSelfIntro(inValidSelfIntroId, createdSelfIntro.getId())) + .isInstanceOf(SelfIntroNotFoundException.class); + } + } +} diff --git a/src/test/java/com/atwoz/member/domain/MemberProfileTest.java b/src/test/java/com/atwoz/member/domain/member/MemberProfileTest.java similarity index 96% rename from src/test/java/com/atwoz/member/domain/MemberProfileTest.java rename to src/test/java/com/atwoz/member/domain/member/MemberProfileTest.java index 932a230d..950701ec 100644 --- a/src/test/java/com/atwoz/member/domain/MemberProfileTest.java +++ b/src/test/java/com/atwoz/member/domain/member/MemberProfileTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain; +package com.atwoz.member.domain.member; -import com.atwoz.member.domain.member.MemberProfile; import com.atwoz.member.domain.member.profile.vo.ProfileAccessStatus; import com.atwoz.member.exception.exceptions.member.profile.InvalidProfileAccessStatusException; import org.junit.jupiter.api.DisplayNameGeneration; diff --git a/src/test/java/com/atwoz/member/domain/MemberRoleTest.java b/src/test/java/com/atwoz/member/domain/member/MemberRoleTest.java similarity index 96% rename from src/test/java/com/atwoz/member/domain/MemberRoleTest.java rename to src/test/java/com/atwoz/member/domain/member/MemberRoleTest.java index 7401bbe7..1c7259d0 100644 --- a/src/test/java/com/atwoz/member/domain/MemberRoleTest.java +++ b/src/test/java/com/atwoz/member/domain/member/MemberRoleTest.java @@ -1,4 +1,4 @@ -package com.atwoz.member.domain; +package com.atwoz.member.domain.member; import com.atwoz.member.domain.member.vo.MemberRole; import com.atwoz.member.exception.exceptions.member.RoleNotFoundException; diff --git a/src/test/java/com/atwoz/member/domain/MemberTest.java b/src/test/java/com/atwoz/member/domain/member/MemberTest.java similarity index 86% rename from src/test/java/com/atwoz/member/domain/MemberTest.java rename to src/test/java/com/atwoz/member/domain/member/MemberTest.java index b55e8a44..0e56b84a 100644 --- a/src/test/java/com/atwoz/member/domain/MemberTest.java +++ b/src/test/java/com/atwoz/member/domain/member/MemberTest.java @@ -1,8 +1,7 @@ -package com.atwoz.member.domain; +package com.atwoz.member.domain.member; import com.atwoz.member.application.member.dto.MemberInitializeRequest; import com.atwoz.member.application.member.dto.MemberUpdateRequest; -import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.profile.vo.ProfileAccessStatus; import com.atwoz.member.domain.member.vo.MemberGrade; import com.atwoz.member.domain.member.vo.MemberRole; @@ -11,13 +10,13 @@ import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; import org.junit.jupiter.api.Test; -import static com.atwoz.member.fixture.MemberFixture.OAuth_인증만_완료한_유저_생성; -import static com.atwoz.member.fixture.MemberFixture.PASS_인증만_완료한_유저_생성; -import static com.atwoz.member.fixture.MemberFixture.어드민_유저_생성; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberProfileInfoFixture.회원_프로필_정보_생성; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_수정_요청서_요청; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_초기화_요청서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.OAuth_인증만_완료한_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.PASS_인증만_완료한_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.어드민_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberProfileInfoFixture.회원_프로필_정보_생성; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_수정_요청서_요청; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_초기화_요청서_요청; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/member/domain/profile/MemberHobbiesTest.java b/src/test/java/com/atwoz/member/domain/member/profile/MemberHobbiesTest.java similarity index 94% rename from src/test/java/com/atwoz/member/domain/profile/MemberHobbiesTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/MemberHobbiesTest.java index c89bfee9..66095d3d 100644 --- a/src/test/java/com/atwoz/member/domain/profile/MemberHobbiesTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/MemberHobbiesTest.java @@ -1,7 +1,5 @@ -package com.atwoz.member.domain.profile; +package com.atwoz.member.domain.member.profile; -import com.atwoz.member.domain.member.profile.MemberHobbies; -import com.atwoz.member.domain.member.profile.MemberHobby; import com.atwoz.member.domain.member.profile.vo.Hobby; import com.atwoz.member.exception.exceptions.member.profile.HobbyDuplicateException; import com.atwoz.member.exception.exceptions.member.profile.HobbySizeException; diff --git a/src/test/java/com/atwoz/member/domain/profile/MemberStylesTest.java b/src/test/java/com/atwoz/member/domain/member/profile/MemberStylesTest.java similarity index 94% rename from src/test/java/com/atwoz/member/domain/profile/MemberStylesTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/MemberStylesTest.java index 3aebd9c7..f6fdc369 100644 --- a/src/test/java/com/atwoz/member/domain/profile/MemberStylesTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/MemberStylesTest.java @@ -1,7 +1,5 @@ -package com.atwoz.member.domain.profile; +package com.atwoz.member.domain.member.profile; -import com.atwoz.member.domain.member.profile.MemberStyle; -import com.atwoz.member.domain.member.profile.MemberStyles; import com.atwoz.member.domain.member.profile.vo.Style; import com.atwoz.member.exception.exceptions.member.profile.InvalidStyleException; import com.atwoz.member.exception.exceptions.member.profile.StyleDuplicateException; diff --git a/src/test/java/com/atwoz/member/domain/profile/ProfileTest.java b/src/test/java/com/atwoz/member/domain/member/profile/ProfileTest.java similarity index 95% rename from src/test/java/com/atwoz/member/domain/profile/ProfileTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/ProfileTest.java index e471f502..f47eba03 100644 --- a/src/test/java/com/atwoz/member/domain/profile/ProfileTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/ProfileTest.java @@ -1,10 +1,7 @@ -package com.atwoz.member.domain.profile; +package com.atwoz.member.domain.member.profile; import com.atwoz.member.application.member.dto.MemberUpdateRequest; import com.atwoz.member.domain.member.dto.MemberProfileDto; -import com.atwoz.member.domain.member.profile.MemberHobby; -import com.atwoz.member.domain.member.profile.MemberStyle; -import com.atwoz.member.domain.member.profile.Profile; import com.atwoz.member.domain.member.profile.physical.YearManager; import com.atwoz.member.domain.member.profile.vo.Hobby; import com.atwoz.member.domain.member.profile.vo.Style; @@ -26,7 +23,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_수정_요청서_요청; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_수정_요청서_요청; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/member/domain/profile/physical/PhysicalProfileTest.java b/src/test/java/com/atwoz/member/domain/member/profile/physical/PhysicalProfileTest.java similarity index 93% rename from src/test/java/com/atwoz/member/domain/profile/physical/PhysicalProfileTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/physical/PhysicalProfileTest.java index 6fd3f9ab..a74bf143 100644 --- a/src/test/java/com/atwoz/member/domain/profile/physical/PhysicalProfileTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/physical/PhysicalProfileTest.java @@ -1,8 +1,6 @@ -package com.atwoz.member.domain.profile.physical; +package com.atwoz.member.domain.member.profile.physical; import com.atwoz.member.domain.member.dto.PhysicalProfileDto; -import com.atwoz.member.domain.member.profile.physical.PhysicalProfile; -import com.atwoz.member.domain.member.profile.physical.YearManager; import com.atwoz.member.exception.exceptions.member.profile.physical.AgeRangeException; import com.atwoz.member.exception.exceptions.member.profile.physical.HeightRangeException; import com.atwoz.member.infrastructure.member.physical.FakeYearManager; diff --git a/src/test/java/com/atwoz/member/domain/profile/physical/vo/GenderTest.java b/src/test/java/com/atwoz/member/domain/member/profile/physical/vo/GenderTest.java similarity index 91% rename from src/test/java/com/atwoz/member/domain/profile/physical/vo/GenderTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/physical/vo/GenderTest.java index 37a7091b..9490bab1 100644 --- a/src/test/java/com/atwoz/member/domain/profile/physical/vo/GenderTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/physical/vo/GenderTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.physical.vo; +package com.atwoz.member.domain.member.profile.physical.vo; -import com.atwoz.member.domain.member.profile.physical.vo.Gender; import com.atwoz.member.exception.exceptions.member.profile.InvalidGenderException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/DrinkTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/DrinkTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/DrinkTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/DrinkTest.java index ea436c85..212f80f2 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/DrinkTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/DrinkTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Drink; import com.atwoz.member.exception.exceptions.member.profile.InvalidDrinkException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/GraduateTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/GraduateTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/GraduateTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/GraduateTest.java index 7720f336..c55c4dbf 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/GraduateTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/GraduateTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Graduate; import com.atwoz.member.exception.exceptions.member.profile.InvalidGraduateException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/HobbyTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/HobbyTest.java similarity index 95% rename from src/test/java/com/atwoz/member/domain/profile/vo/HobbyTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/HobbyTest.java index fe2c8280..848f1ce4 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/HobbyTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/HobbyTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Hobby; import com.atwoz.member.exception.exceptions.member.profile.InvalidHobbyException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/JobTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/JobTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/JobTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/JobTest.java index 70be3380..4711072e 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/JobTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/JobTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Job; import com.atwoz.member.exception.exceptions.member.profile.InvalidJobException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/MbtiTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/MbtiTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/MbtiTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/MbtiTest.java index f5aabab1..fd96c68b 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/MbtiTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/MbtiTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Mbti; import com.atwoz.member.exception.exceptions.member.profile.InvalidMbtiException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/PositionTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/PositionTest.java similarity index 95% rename from src/test/java/com/atwoz/member/domain/profile/vo/PositionTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/PositionTest.java index 62491338..a01203a7 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/PositionTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/PositionTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Position; import com.atwoz.member.exception.exceptions.member.profile.LatitudeRangeException; import com.atwoz.member.exception.exceptions.member.profile.LongitudeRangeException; import java.math.BigDecimal; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/ReligionTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/ReligionTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/ReligionTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/ReligionTest.java index e9a32820..30d978a3 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/ReligionTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/ReligionTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Religion; import com.atwoz.member.exception.exceptions.member.profile.InvalidReligionException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/SmokeTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/SmokeTest.java similarity index 92% rename from src/test/java/com/atwoz/member/domain/profile/vo/SmokeTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/SmokeTest.java index 40e202ac..ac70e30a 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/SmokeTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/SmokeTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Smoke; import com.atwoz.member.exception.exceptions.member.profile.InvalidSmokeException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/profile/vo/StyleTest.java b/src/test/java/com/atwoz/member/domain/member/profile/vo/StyleTest.java similarity index 95% rename from src/test/java/com/atwoz/member/domain/profile/vo/StyleTest.java rename to src/test/java/com/atwoz/member/domain/member/profile/vo/StyleTest.java index 254557c3..dafae826 100644 --- a/src/test/java/com/atwoz/member/domain/profile/vo/StyleTest.java +++ b/src/test/java/com/atwoz/member/domain/member/profile/vo/StyleTest.java @@ -1,6 +1,5 @@ -package com.atwoz.member.domain.profile.vo; +package com.atwoz.member.domain.member.profile.vo; -import com.atwoz.member.domain.member.profile.vo.Style; import com.atwoz.member.exception.exceptions.member.profile.InvalidStyleException; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; diff --git a/src/test/java/com/atwoz/member/domain/selfintro/SelfIntroTest.java b/src/test/java/com/atwoz/member/domain/selfintro/SelfIntroTest.java new file mode 100644 index 00000000..12215b2a --- /dev/null +++ b/src/test/java/com/atwoz/member/domain/selfintro/SelfIntroTest.java @@ -0,0 +1,90 @@ +package com.atwoz.member.domain.selfintro; + +import com.atwoz.member.exception.exceptions.selfintro.InvalidContentException; +import com.atwoz.member.exception.exceptions.selfintro.WriterNotEqualsException; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_있음; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroTest { + + @Nested + class 셀프_소개글_생성 { + + @Test + void 셀프_소개글을_생성한다() { + // given + Long memberId = 1L; + String content = "안녕하세요~"; + + // when + SelfIntro selfIntro = SelfIntro.createWith(memberId, content); + + // then + assertSoftly(softly -> { + softly.assertThat(selfIntro.getMemberId()).isEqualTo(memberId); + softly.assertThat(selfIntro.getContent()).isEqualTo(content); + }); + } + + @Test + void 소개글이_올바르게_입력되지_않으면_예외가_발생한다() { + // given + Long memberId = 1L; + String invalidContent = ""; + + // when & then + assertThatThrownBy(() -> SelfIntro.createWith(memberId, invalidContent)) + .isInstanceOf(InvalidContentException.class); + } + } + + @Nested + class 셀프_소개글_수정 { + + @Test + void 셀프_소개글을_수정한다() { + // given + SelfIntro selfIntro = SelfIntro.createWith(1L, "안녕하세요~"); + String updateContent = "반가워요~"; + + // when + selfIntro.update(updateContent); + + // then + assertSoftly(softly -> { + softly.assertThat(selfIntro.getMemberId()).isEqualTo(1L); + softly.assertThat(selfIntro.getContent()).isEqualTo(updateContent); + }); + } + + @Test + void 소개글이_올바르게_입력되지_않으면_예외가_발생한다() { + // given + SelfIntro selfIntro = SelfIntro.createWith(1L, "안녕하세요~"); + String invalidUpdateContent = ""; + + // when & then + assertThatThrownBy(() -> selfIntro.update(invalidUpdateContent)) + .isInstanceOf(InvalidContentException.class); + } + } + + @Test + void 소개글_작성자와_요청을_보낸_요청자_id가_다르면_예외가_발생한다() { + // given + SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); + Long anotherMemberId = 2L; + + // when & then + assertThatThrownBy(() -> selfIntro.validateSameWriter(anotherMemberId)) + .isInstanceOf(WriterNotEqualsException.class); + } +} diff --git a/src/test/java/com/atwoz/member/fixture/OAuthProviderFixture.java b/src/test/java/com/atwoz/member/fixture/auth/OAuthProviderFixture.java similarity index 93% rename from src/test/java/com/atwoz/member/fixture/OAuthProviderFixture.java rename to src/test/java/com/atwoz/member/fixture/auth/OAuthProviderFixture.java index 3d3ec03c..1a33dc7c 100644 --- a/src/test/java/com/atwoz/member/fixture/OAuthProviderFixture.java +++ b/src/test/java/com/atwoz/member/fixture/auth/OAuthProviderFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.auth; import com.atwoz.member.infrastructure.auth.dto.MemberInfoKeyWordRequest; import com.atwoz.member.infrastructure.auth.dto.OAuthProviderRequest; diff --git a/src/test/java/com/atwoz/member/fixture/HobbiesResponseFixture.java b/src/test/java/com/atwoz/member/fixture/member/HobbiesResponseFixture.java similarity index 95% rename from src/test/java/com/atwoz/member/fixture/HobbiesResponseFixture.java rename to src/test/java/com/atwoz/member/fixture/member/HobbiesResponseFixture.java index b5f8acfe..085518f6 100644 --- a/src/test/java/com/atwoz/member/fixture/HobbiesResponseFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/HobbiesResponseFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.profile.MemberHobby; diff --git a/src/test/java/com/atwoz/member/fixture/MemberFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberFixture.java similarity index 74% rename from src/test/java/com/atwoz/member/fixture/MemberFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberFixture.java index bb4c94f4..1c499a73 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.MemberProfile; @@ -6,7 +6,7 @@ import com.atwoz.member.domain.member.vo.MemberRole; import com.atwoz.member.domain.member.vo.MemberStatus; -import static com.atwoz.member.fixture.MemberProfileDtoFixture.회원_프로필_DTO_요청; +import static com.atwoz.member.fixture.member.MemberProfileDtoFixture.회원_프로필_DTO_요청; @SuppressWarnings("NonAsciiCharacters") public class MemberFixture { @@ -25,6 +25,20 @@ public class MemberFixture { return member; } + public static Member 일반_유저_생성(final int birthYear, final String phoneNumber) { + Member member = Member.builder() + .nickname("nickname") + .phoneNumber(phoneNumber) + .memberStatus(MemberStatus.ACTIVE) + .memberGrade(MemberGrade.SILVER) + .memberRole(MemberRole.MEMBER) + .memberProfile(MemberProfile.createWith("남성")) + .build(); + + member.initializeWith(member.getNickname(), member.getRecommenderId(), 회원_프로필_DTO_요청(birthYear)); + return member; + } + public static Member 일반_유저_생성(final String nickname, final String phoneNumber) { Member member = Member.builder() .nickname(nickname) diff --git a/src/test/java/com/atwoz/member/fixture/MemberProfileDtoFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberProfileDtoFixture.java similarity index 59% rename from src/test/java/com/atwoz/member/fixture/MemberProfileDtoFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberProfileDtoFixture.java index d756185c..6e89d476 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberProfileDtoFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberProfileDtoFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.dto.HobbiesDto; import com.atwoz.member.domain.member.dto.MemberProfileDto; @@ -25,4 +25,20 @@ public class MemberProfileDtoFixture { .mbti("INFP") .build(); } + + public static MemberProfileDto 회원_프로필_DTO_요청(final int birthYear) { + return MemberProfileDto.builder() + .physicalProfileDto(new PhysicalProfileDto(birthYear, 170, new FakeYearManager())) + .hobbiesdto(new HobbiesDto(List.of("B001", "B002"))) + .stylesDto(new StylesDto(List.of("C001", "C002"))) + .city("서울시") + .sector("강남구") + .job("A001") + .graduate("서울 4년제") + .smoke("비흡연") + .drink("전혀 마시지 않음") + .religion("기독교") + .mbti("INFP") + .build(); + } } diff --git a/src/test/java/com/atwoz/member/fixture/MemberProfileInfoFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberProfileInfoFixture.java similarity index 95% rename from src/test/java/com/atwoz/member/fixture/MemberProfileInfoFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberProfileInfoFixture.java index ff084e05..85f941c7 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberProfileInfoFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberProfileInfoFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.application.member.dto.ProfileInitializeRequest; import com.atwoz.member.application.member.dto.ProfileUpdateRequest; diff --git a/src/test/java/com/atwoz/member/fixture/MemberProfileResponseFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberProfileResponseFixture.java similarity index 97% rename from src/test/java/com/atwoz/member/fixture/MemberProfileResponseFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberProfileResponseFixture.java index 55c92d88..c88a5792 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberProfileResponseFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberProfileResponseFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.profile.Profile; diff --git a/src/test/java/com/atwoz/member/fixture/MemberRequestFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberRequestFixture.java similarity index 99% rename from src/test/java/com/atwoz/member/fixture/MemberRequestFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberRequestFixture.java index 3affe87e..135618e5 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberRequestFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberRequestFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.application.member.dto.HobbiesRequest; import com.atwoz.member.application.member.dto.MemberInitializeRequest; diff --git a/src/test/java/com/atwoz/member/fixture/MemberResponseFixture.java b/src/test/java/com/atwoz/member/fixture/member/MemberResponseFixture.java similarity index 56% rename from src/test/java/com/atwoz/member/fixture/MemberResponseFixture.java rename to src/test/java/com/atwoz/member/fixture/member/MemberResponseFixture.java index b579a63f..6b739613 100644 --- a/src/test/java/com/atwoz/member/fixture/MemberResponseFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/MemberResponseFixture.java @@ -1,11 +1,11 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.Member; import com.atwoz.member.infrastructure.member.dto.MemberResponse; -import static com.atwoz.member.fixture.HobbiesResponseFixture.취미_응답서_요청; -import static com.atwoz.member.fixture.MemberProfileResponseFixture.회원_프로필_응답서_요청; -import static com.atwoz.member.fixture.StylesResponseFixture.스타일_응답서_요청; +import static com.atwoz.member.fixture.member.HobbiesResponseFixture.취미_응답서_요청; +import static com.atwoz.member.fixture.member.MemberProfileResponseFixture.회원_프로필_응답서_요청; +import static com.atwoz.member.fixture.member.StylesResponseFixture.스타일_응답서_요청; @SuppressWarnings("NonAsciiCharacters") public class MemberResponseFixture { diff --git a/src/test/java/com/atwoz/member/fixture/StylesResponseFixture.java b/src/test/java/com/atwoz/member/fixture/member/StylesResponseFixture.java similarity index 95% rename from src/test/java/com/atwoz/member/fixture/StylesResponseFixture.java rename to src/test/java/com/atwoz/member/fixture/member/StylesResponseFixture.java index a88e27db..f6d949de 100644 --- a/src/test/java/com/atwoz/member/fixture/StylesResponseFixture.java +++ b/src/test/java/com/atwoz/member/fixture/member/StylesResponseFixture.java @@ -1,4 +1,4 @@ -package com.atwoz.member.fixture; +package com.atwoz.member.fixture.member; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.profile.MemberStyle; diff --git a/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroFixture.java b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroFixture.java new file mode 100644 index 00000000..c05c60cc --- /dev/null +++ b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroFixture.java @@ -0,0 +1,25 @@ +package com.atwoz.member.fixture.selfintro; + +import com.atwoz.member.domain.selfintro.SelfIntro; + +public class SelfIntroFixture { + + private static final Long DEFAULT_MEMBER_ID = 1L; + private static final String DEFAULT_CONTENT = "안녕하세요~"; + + public static SelfIntro 셀프_소개글_생성_id_없음() { + return SelfIntro.createWith(DEFAULT_MEMBER_ID, DEFAULT_CONTENT); + } + + public static SelfIntro 셀프_소개글_생성_id_없음(final Long memberId) { + return SelfIntro.createWith(memberId, DEFAULT_CONTENT); + } + + public static SelfIntro 셀프_소개글_생성_id_있음(final Long id) { + return SelfIntro.builder() + .id(id) + .memberId(DEFAULT_MEMBER_ID) + .content(DEFAULT_CONTENT) + .build(); + } +} diff --git a/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java new file mode 100644 index 00000000..213b95b4 --- /dev/null +++ b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroRequestFixture.java @@ -0,0 +1,39 @@ +package com.atwoz.member.fixture.selfintro; + +import com.atwoz.member.application.selfintro.dto.CityRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import java.util.List; + +@SuppressWarnings("NonAsciiCharacters") +public class SelfIntroRequestFixture { + + private static final String CREATE_CONTENT = "안녕하세요~"; + private static final String UPDATE_CONTENT = "반가워요~"; + private static final int MIN_AGE = 20; + private static final int MAX_AGE = 30; + private static final String CITY = "서울시"; + private static final boolean IS_ONLY_OPPOSITE_GENDER = false; + + public static SelfIntroCreateRequest 셀프_소개글_생성_요청서() { + return new SelfIntroCreateRequest(CREATE_CONTENT); + } + + public static SelfIntroFilterRequest 셀프_소개글_필터_요청서() { + return new SelfIntroFilterRequest( + MIN_AGE, + MAX_AGE, + IS_ONLY_OPPOSITE_GENDER, + List.of(new CityRequest(CITY)) + ); + } + + public static SelfIntroUpdateRequest 셀프_소개글_수정_요청서() { + return new SelfIntroUpdateRequest(UPDATE_CONTENT); + } + + public static SelfIntroUpdateRequest 셀프_소개글_수정_요청서(final String content) { + return new SelfIntroUpdateRequest(content); + } +} diff --git a/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroResponseFixture.java b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroResponseFixture.java new file mode 100644 index 00000000..91871c69 --- /dev/null +++ b/src/test/java/com/atwoz/member/fixture/selfintro/SelfIntroResponseFixture.java @@ -0,0 +1,36 @@ +package com.atwoz.member.fixture.selfintro; + +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; + +public class SelfIntroResponseFixture { + + private static final Long SELF_INTRO_ID = 1L; + private static final String CONTENT = "안녕하세요~"; + private static final String NICKNAME = "nickname"; + private static final String CITY = "서울시"; + private static final int AGE = 30; + private static final int HEIGHT = 170; + + public static SelfIntroResponse 셀프_소개글_응답() { + return new SelfIntroResponse( + SELF_INTRO_ID, + CONTENT, + NICKNAME, + CITY, + AGE, + HEIGHT + ); + } + + public static SelfIntroResponse 셀프_소개글_응답(final Long selfIntroId, + final String selfContent) { + return new SelfIntroResponse( + selfIntroId, + selfContent, + NICKNAME, + CITY, + AGE, + HEIGHT + ); + } +} diff --git a/src/test/java/com/atwoz/member/infrastructure/member/MemberFakeRepository.java b/src/test/java/com/atwoz/member/infrastructure/member/MemberFakeRepository.java index ddacf3a7..e1e9ff4f 100644 --- a/src/test/java/com/atwoz/member/infrastructure/member/MemberFakeRepository.java +++ b/src/test/java/com/atwoz/member/infrastructure/member/MemberFakeRepository.java @@ -9,8 +9,8 @@ import java.util.Map; import java.util.Optional; -import static com.atwoz.member.fixture.MemberProfileDtoFixture.회원_프로필_DTO_요청; -import static com.atwoz.member.fixture.MemberResponseFixture.회원_정보_응답서_요청; +import static com.atwoz.member.fixture.member.MemberProfileDtoFixture.회원_프로필_DTO_요청; +import static com.atwoz.member.fixture.member.MemberResponseFixture.회원_정보_응답서_요청; @SuppressWarnings("NonAsciiCharacters") public class MemberFakeRepository implements MemberRepository { diff --git a/src/test/java/com/atwoz/member/infrastructure/member/MemberJpaRepositoryTest.java b/src/test/java/com/atwoz/member/infrastructure/member/MemberJpaRepositoryTest.java index b4d5788b..feeb6524 100644 --- a/src/test/java/com/atwoz/member/infrastructure/member/MemberJpaRepositoryTest.java +++ b/src/test/java/com/atwoz/member/infrastructure/member/MemberJpaRepositoryTest.java @@ -10,7 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/member/infrastructure/member/MemberQueryRepositoryTest.java b/src/test/java/com/atwoz/member/infrastructure/member/MemberQueryRepositoryTest.java index abd3406d..22394eb3 100644 --- a/src/test/java/com/atwoz/member/infrastructure/member/MemberQueryRepositoryTest.java +++ b/src/test/java/com/atwoz/member/infrastructure/member/MemberQueryRepositoryTest.java @@ -9,10 +9,10 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; -import static com.atwoz.member.fixture.HobbiesResponseFixture.취미_응답서_요청; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberProfileResponseFixture.회원_프로필_응답서_요청; -import static com.atwoz.member.fixture.StylesResponseFixture.스타일_응답서_요청; +import static com.atwoz.member.fixture.member.HobbiesResponseFixture.취미_응답서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberProfileResponseFixture.회원_프로필_응답서_요청; +import static com.atwoz.member.fixture.member.StylesResponseFixture.스타일_응답서_요청; import static org.assertj.core.api.SoftAssertions.assertSoftly; @DisplayNameGeneration(ReplaceUnderscores.class) diff --git a/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java new file mode 100644 index 00000000..7b2afaef --- /dev/null +++ b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroFakeRepository.java @@ -0,0 +1,86 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; + +import static com.atwoz.member.fixture.selfintro.SelfIntroResponseFixture.셀프_소개글_응답; + +@SuppressWarnings("NonAsciiCharacters") +public class SelfIntroFakeRepository implements SelfIntroRepository { + + private static final int AGE = 30; + private static final String CITY = "서울시"; + private static final int SIZE_PER_PAGE = 10; + + private final Map map = new HashMap<>(); + private Long id = 1L; + + @Override + public SelfIntro save(final SelfIntro selfIntro) { + SelfIntro savedSelfIntro = SelfIntro.builder() + .id(id) + .memberId(selfIntro.getMemberId()) + .content(selfIntro.getContent()) + .build(); + map.put(id++, savedSelfIntro); + + return savedSelfIntro; + } + + @Override + public Optional findById(final Long id) { + return Optional.ofNullable(map.get(id)); + } + + @Override + public void deleteById(final Long id) { + map.remove(id); + } + + @Override + public Page findAllSelfIntrosWithPaging(final Pageable pageable, + final Long memberId) { + List introResponses = map.values().stream() + .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) + .limit(SIZE_PER_PAGE) + .map(selfIntro -> 셀프_소개글_응답(selfIntro.getId(), selfIntro.getContent() + )).toList(); + + return new PageImpl<>(introResponses); + } + + @Override + public Page findAllSelfIntrosWithPagingAndFiltering(final Pageable pageable, + final int minAge, + final int maxAge, + final boolean isOnlyOppositeGender, + final List cities, + final Long memberId) { + List introResponses = map.values().stream() + .filter(selfIntro -> isBetween(minAge, maxAge)) + .filter(selfIntro -> isBelongTo(cities)) + .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) + .limit(SIZE_PER_PAGE) + .map(selfIntro -> 셀프_소개글_응답(selfIntro.getId(), selfIntro.getContent() + )).toList(); + + return new PageImpl<>(introResponses); + } + + private boolean isBetween(final int minAge, final int maxAge) { + return minAge <= AGE && AGE <= maxAge; + } + + private boolean isBelongTo(final List cities) { + return cities.contains(CITY); + } +} diff --git a/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepositoryTest.java b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepositoryTest.java new file mode 100644 index 00000000..397f9917 --- /dev/null +++ b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroJpaRepositoryTest.java @@ -0,0 +1,71 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.fixture.selfintro.SelfIntroFixture; +import java.util.Optional; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +@DataJpaTest +class SelfIntroJpaRepositoryTest { + + @Autowired + private SelfIntroJpaRepository selfIntroJpaRepository; + + private SelfIntro selfIntro; + + @BeforeEach + void setup() { + selfIntro = SelfIntroFixture.셀프_소개글_생성_id_없음(); + } + + @Test + void 셀프_소개글을_저장한다() { + // when + SelfIntro savedSelfIntro = selfIntroJpaRepository.save(selfIntro); + + // then + assertThat(savedSelfIntro).usingRecursiveComparison() + .ignoringFields("id") + .isEqualTo(selfIntro); + } + + @Test + void 셀프_소개글을_id로_조회한다() { + // given + SelfIntro savedSelfIntro = selfIntroJpaRepository.save(selfIntro); + + // when + Optional foundSelfIntro = selfIntroJpaRepository.findById(savedSelfIntro.getId()); + + // then + assertSoftly(softly -> { + softly.assertThat(foundSelfIntro).isPresent(); + SelfIntro result = foundSelfIntro.get(); + softly.assertThat(result).usingRecursiveComparison() + .ignoringFields("id") + .isEqualTo(selfIntro); + }); + } + + @Test + void 셀프_소개글을_id로_삭제한다() { + // given + SelfIntro savedSelfIntro = selfIntroJpaRepository.save(selfIntro); + + // when + selfIntroJpaRepository.deleteById(savedSelfIntro.getId()); + + // then + assertThat(selfIntroJpaRepository.findById(1L)).isEmpty(); + } +} diff --git a/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepositoryTest.java b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepositoryTest.java new file mode 100644 index 00000000..11996fbb --- /dev/null +++ b/src/test/java/com/atwoz/member/infrastructure/selfintro/SelfIntroQueryRepositoryTest.java @@ -0,0 +1,127 @@ +package com.atwoz.member.infrastructure.selfintro; + +import com.atwoz.helper.IntegrationHelper; +import com.atwoz.member.domain.member.Member; +import com.atwoz.member.domain.member.MemberRepository; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.stream.IntStream; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; + +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_없음; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroQueryRepositoryTest extends IntegrationHelper { + + @Autowired + private SelfIntroQueryRepository selfIntroQueryRepository; + + @Autowired + private SelfIntroRepository selfIntroRepository; + + @Autowired + private MemberRepository memberRepository; + + private Member member; + + @BeforeEach + void setup() { + member = memberRepository.save(일반_유저_생성()); + } + + @Test + void 셀프_소개글을_최근_생성된_기준으로_10개_페이징해서_조회한다() { + // given + List selfIntros = new ArrayList<>(); + saveSelfIntros(25, selfIntros, member.getId()); + PageRequest pageRequest = PageRequest.of(0, 10); + + // when + Page selfIntroResponses = selfIntroQueryRepository.findAllSelfIntroWithPaging( + pageRequest, member.getId()); + + // then + List results = selfIntroResponses.getContent(); + List expectedResults = selfIntros.stream() + .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) + .limit(10) + .toList(); + + assertSoftly(softly -> { + softly.assertThat(selfIntroResponses.hasNext()).isTrue(); + softly.assertThat(selfIntroResponses.getTotalElements()).isEqualTo(25); + softly.assertThat(selfIntroResponses.getTotalPages()).isEqualTo(3); + softly.assertThat(selfIntroResponses).hasSize(10); + IntStream.range(0, 10) + .forEach(index -> { + SelfIntro expectResult = expectedResults.get(index); + SelfIntroResponse result = results.get(index); + softly.assertThat(expectResult.getId()).isEqualTo(result.selfIntroId()); + softly.assertThat(expectResult.getContent()).isEqualTo(result.selfIntroContent()); + }); + }); + } + + @Test + void 셀프_소개글을_여러가지_기준으로_필터링한_후_10개씩_페이징해서_조회한다() { + // given + Member member1 = 일반_유저_생성(1990, "01022222222"); + Member member2 = 일반_유저_생성(2000, "01033333333"); + memberRepository.save(member1); + memberRepository.save(member2); + List selfIntros = new ArrayList<>(); + saveSelfIntros(15, selfIntros, member1.getId()); + saveSelfIntros(25, selfIntros, member2.getId()); + int minAge = 30; + int maxAge = 40; + boolean isOnlyOppositeGender = false; + List cities = List.of("서울시"); + PageRequest pageRequest = PageRequest.of(0, 10); + + // when + Page selfIntroResponses = selfIntroQueryRepository.findAllSelfIntrosWithPagingAndFiltering( + pageRequest, minAge, maxAge, isOnlyOppositeGender, cities, member1.getId()); + + // then + List results = selfIntroResponses.getContent(); + List expectedResults = selfIntros.stream() + .filter(selfIntro -> selfIntro.getMemberId().equals(member1.getId())) + .sorted(Comparator.comparing(SelfIntro::getCreatedAt).reversed()) + .limit(10) + .toList(); + + assertSoftly(softly -> { + softly.assertThat(selfIntroResponses.hasNext()).isTrue(); + softly.assertThat(selfIntroResponses.getTotalElements()).isEqualTo(15); + softly.assertThat(selfIntroResponses.getTotalPages()).isEqualTo(2); + softly.assertThat(selfIntroResponses).hasSize(10); + IntStream.range(0, 10) + .forEach(index -> { + SelfIntro expectResult = expectedResults.get(index); + SelfIntroResponse result = results.get(index); + softly.assertThat(expectResult.getId()).isEqualTo(result.selfIntroId()); + softly.assertThat(expectResult.getContent()).isEqualTo(result.selfIntroContent()); + }); + }); + } + + private void saveSelfIntros(final int endExclusive, + final List selfIntros, + final Long memberId) { + IntStream.range(0, endExclusive) + .forEach(i -> selfIntros.add(selfIntroRepository.save(셀프_소개글_생성_id_없음(memberId)))); + } +} diff --git a/src/test/java/com/atwoz/member/ui/auth/MemberAuthControllerWebMvcTest.java b/src/test/java/com/atwoz/member/ui/auth/MemberAuthControllerWebMvcTest.java index 84ee1e17..ad190291 100644 --- a/src/test/java/com/atwoz/member/ui/auth/MemberAuthControllerWebMvcTest.java +++ b/src/test/java/com/atwoz/member/ui/auth/MemberAuthControllerWebMvcTest.java @@ -14,7 +14,7 @@ import org.springframework.test.web.servlet.MockMvc; import static com.atwoz.helper.RestDocsHelper.customDocument; -import static com.atwoz.member.fixture.OAuthProviderFixture.인증_기관_생성; +import static com.atwoz.member.fixture.auth.OAuthProviderFixture.인증_기관_생성; import static org.mockito.Mockito.when; import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; diff --git a/src/test/java/com/atwoz/member/ui/member/MemberControllerAcceptanceFixture.java b/src/test/java/com/atwoz/member/ui/member/MemberControllerAcceptanceFixture.java index 4af22e8e..86b4d8b6 100644 --- a/src/test/java/com/atwoz/member/ui/member/MemberControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/member/ui/member/MemberControllerAcceptanceFixture.java @@ -6,7 +6,7 @@ import com.atwoz.member.domain.auth.MemberTokenProvider; import com.atwoz.member.domain.member.Member; import com.atwoz.member.domain.member.MemberRepository; -import com.atwoz.member.fixture.MemberRequestFixture; +import com.atwoz.member.fixture.member.MemberRequestFixture; import com.atwoz.member.infrastructure.member.dto.MemberResponse; import io.restassured.RestAssured; import io.restassured.response.ExtractableResponse; @@ -16,8 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_초기화_요청서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_초기화_요청서_요청; import static io.restassured.http.ContentType.JSON; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/member/ui/member/MemberControllerWebMvcTest.java b/src/test/java/com/atwoz/member/ui/member/MemberControllerWebMvcTest.java index f6e7b412..0d0b96f9 100644 --- a/src/test/java/com/atwoz/member/ui/member/MemberControllerWebMvcTest.java +++ b/src/test/java/com/atwoz/member/ui/member/MemberControllerWebMvcTest.java @@ -3,7 +3,7 @@ import com.atwoz.helper.MockBeanInjection; import com.atwoz.member.application.member.dto.MemberInitializeRequest; import com.atwoz.member.application.member.dto.MemberUpdateRequest; -import com.atwoz.member.fixture.MemberRequestFixture; +import com.atwoz.member.fixture.member.MemberRequestFixture; import com.atwoz.member.infrastructure.member.dto.MemberResponse; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.jupiter.api.DisplayNameGeneration; @@ -15,9 +15,9 @@ import org.springframework.test.web.servlet.MockMvc; import static com.atwoz.helper.RestDocsHelper.customDocument; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberRequestFixture.회원_정보_초기화_요청서_요청; -import static com.atwoz.member.fixture.MemberResponseFixture.회원_정보_응답서_요청; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberRequestFixture.회원_정보_초기화_요청서_요청; +import static com.atwoz.member.fixture.member.MemberResponseFixture.회원_정보_응답서_요청; import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.given; import static org.springframework.http.HttpHeaders.AUTHORIZATION; diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java new file mode 100644 index 00000000..2b9047b2 --- /dev/null +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTest.java @@ -0,0 +1,95 @@ +package com.atwoz.member.ui.selfintro; + +import com.atwoz.member.domain.member.Member; +import com.atwoz.member.domain.selfintro.SelfIntro; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Test; + +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_없음; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_생성_요청서; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_수정_요청서; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroControllerAcceptanceTest extends SelfIntroControllerAcceptanceTestFixture { + + private static final String 셀프_소개글_생성_URL = "/api/members/self-intros/me"; + private static final String 셀프_소개글_조회_URL = "/api/members/self-intros"; + private static final String 필터_적용한_셀프_소개글_조회_URL = "/api/members/self-intros/filter"; + private static final String 셀프_소개글_수정_URL = "/api/members/self-intros/1"; + private static final String 셀프_소개글_삭제_URI = "/api/members/self-intros/1"; + + private Member 회원; + private String 토큰; + private SelfIntro 셀프_소개글; + + @BeforeEach + void setup() { + 셀프_소개글 = 셀프_소개글_생성_id_없음(); + 회원 = 회원_저장(); + 토큰 = 토큰_생성(회원); + } + + @Test + void 셀프_소개글_저장() { + // given + var 셀프_소개글_요청서 = 셀프_소개글_생성_요청서(); + + // when + var 셀프_소개글_저장_요청_결과 = 셀프_소개글_저장_요청(셀프_소개글_요청서, 셀프_소개글_생성_URL, 토큰); + + // then + 셀프_소개글_저장_검증(셀프_소개글_저장_요청_결과); + } + + @Test + void 셀프_소개글_페이징_조회() { + // given + 셀프_소개글_저장(셀프_소개글); + + // when + var 셀프_소개글_페이징_조회_요청_결과 = 셀프_소개글_페이징_조회_요청(셀프_소개글_조회_URL, 토큰); + + // then + 셀프_소개글_페이징_조회_요청_검증(셀프_소개글_페이징_조회_요청_결과); + } + + @Test + void 필터_적용한_셀프_소개글_페이징_조회() { + // given + 셀프_소개글_저장(셀프_소개글); + + // when + var 필터_적용한_셀프_소개글_페이징_조회_요청_결과 = 필터_적용한_셀프_소개글_페이징_조회_요청(필터_적용한_셀프_소개글_조회_URL, 토큰); + + // then + 필터_적용한_셀프_소개글_페이징_조회_요청_검증(필터_적용한_셀프_소개글_페이징_조회_요청_결과); + } + + @Test + void 셀프_소개글_수정() { + // given + 셀프_소개글_저장(셀프_소개글); + var 셀프_소개글_수정_요청서 = 셀프_소개글_수정_요청서(); + + // when + var 셀프_소개글_수정_요청_결과 = 셀프_소개글_수정_요청(셀프_소개글_수정_요청서, 셀프_소개글_수정_URL, 토큰); + + // then + 셀프_소개글_수정_요청_검증(셀프_소개글_수정_요청_결과); + } + + @Test + void 셀프_소개글_삭제() { + // given + 셀프_소개글_저장(셀프_소개글); + + // when + var 셀프_소개글_삭제_요청_결과 = 셀프_소개글_삭제_요청(셀프_소개글_삭제_URI, 토큰); + + // then + 셀프_소개글_삭제_요청_검증(셀프_소개글_삭제_요청_결과); + } +} diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java new file mode 100644 index 00000000..ce5fdb8c --- /dev/null +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerAcceptanceTestFixture.java @@ -0,0 +1,143 @@ +package com.atwoz.member.ui.selfintro; + +import com.atwoz.helper.IntegrationHelper; +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntrosResponse; +import com.atwoz.member.domain.auth.MemberTokenProvider; +import com.atwoz.member.domain.member.Member; +import com.atwoz.member.domain.member.MemberRepository; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.domain.selfintro.SelfIntroRepository; +import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import io.restassured.response.ExtractableResponse; +import io.restassured.response.Response; +import org.apache.http.HttpStatus; +import org.springframework.beans.factory.annotation.Autowired; + +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static org.apache.http.HttpHeaders.AUTHORIZATION; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.SoftAssertions.assertSoftly; + +@SuppressWarnings("NonAsciiCharacters") +class SelfIntroControllerAcceptanceTestFixture extends IntegrationHelper { + + @Autowired + private SelfIntroRepository selfIntroRepository; + + @Autowired + private MemberRepository memberRepository; + + @Autowired + private MemberTokenProvider memberTokenProvider; + + protected Member 회원_저장() { + return memberRepository.save(일반_유저_생성()); + } + + protected SelfIntro 셀프_소개글_저장(final SelfIntro selfIntro) { + return selfIntroRepository.save(selfIntro); + } + + protected String 토큰_생성(final Member member) { + return memberTokenProvider.createAccessToken(member.getId()); + } + + protected ExtractableResponse 셀프_소개글_저장_요청(final SelfIntroCreateRequest selfIntroCreateRequest, + final String url, + final String token) { + return RestAssured.given().log().all() + .header(AUTHORIZATION, "Bearer " + token) + .contentType(ContentType.JSON) + .body(selfIntroCreateRequest) + .when() + .post(url) + .then().log().all() + .extract(); + } + + protected void 셀프_소개글_저장_검증(final ExtractableResponse response) { + assertThat(response.statusCode()).isEqualTo(HttpStatus.SC_OK); + } + + protected ExtractableResponse 셀프_소개글_페이징_조회_요청(final String url, + final String token) { + return RestAssured.given().log().all() + .header(AUTHORIZATION, "Bearer " + token) + .param("page", "0") + .param("size", "10") + .when() + .get(url) + .then().log().all() + .extract(); + } + + protected void 셀프_소개글_페이징_조회_요청_검증(final ExtractableResponse response) { + SelfIntrosResponse selfIntrosResponse = response.as(SelfIntrosResponse.class); + assertSoftly(softly -> { + softly.assertThat(selfIntrosResponse.selfIntros().size()).isEqualTo(1); + softly.assertThat(selfIntrosResponse.nowPage()).isEqualTo(0); + softly.assertThat(selfIntrosResponse.nextPage()).isEqualTo(-1); + softly.assertThat(selfIntrosResponse.totalPages()).isEqualTo(1); + }); + } + + protected ExtractableResponse 필터_적용한_셀프_소개글_페이징_조회_요청(final String url, + final String token) { + return RestAssured.given().log().all() + .header(AUTHORIZATION, "Bearer " + token) + .param("page", "0") + .param("size", "10") + .param("minAge", "20") + .param("maxAge", "30") + .param("isOnlyOppositeGender", "false") + .param("cityRequests", "서울시,경기도") + .when() + .get(url) + .then().log().all() + .extract(); + } + + protected void 필터_적용한_셀프_소개글_페이징_조회_요청_검증(final ExtractableResponse response) { + SelfIntrosResponse selfIntrosResponse = response.as(SelfIntrosResponse.class); + assertSoftly(softly -> { + softly.assertThat(selfIntrosResponse.selfIntros().size()).isEqualTo(1); + softly.assertThat(selfIntrosResponse.nowPage()).isEqualTo(0); + softly.assertThat(selfIntrosResponse.nextPage()).isEqualTo(-1); + softly.assertThat(selfIntrosResponse.totalPages()).isEqualTo(1); + }); + } + + protected ExtractableResponse 셀프_소개글_수정_요청(final SelfIntroUpdateRequest selfIntroUpdateRequest, + final String url, + final String token) { + return RestAssured.given().log().all() + .header(AUTHORIZATION, "Bearer " + token) + .contentType(ContentType.JSON) + .body(selfIntroUpdateRequest) + .when() + .patch(url) + .then().log().all() + .extract(); + } + + protected void 셀프_소개글_수정_요청_검증(final ExtractableResponse response) { + assertThat(response.statusCode()).isEqualTo(HttpStatus.SC_OK); + } + + protected ExtractableResponse 셀프_소개글_삭제_요청(final String url, final String token) { + return RestAssured.given().log().all() + .header(AUTHORIZATION, "Bearer " + token) + .contentType(ContentType.JSON) + .when() + .delete(url) + .then().log().all() + .extract(); + } + + protected void 셀프_소개글_삭제_요청_검증(final ExtractableResponse response) { + assertThat(response.statusCode()).isEqualTo(HttpStatus.SC_NO_CONTENT); + } +} diff --git a/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java new file mode 100644 index 00000000..5387bdcc --- /dev/null +++ b/src/test/java/com/atwoz/member/ui/selfintro/SelfIntroControllerWebMvcTest.java @@ -0,0 +1,208 @@ +package com.atwoz.member.ui.selfintro; + +import com.atwoz.helper.MockBeanInjection; +import com.atwoz.member.application.selfintro.dto.SelfIntroCreateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroFilterRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntroUpdateRequest; +import com.atwoz.member.application.selfintro.dto.SelfIntrosResponse; +import com.atwoz.member.domain.selfintro.SelfIntro; +import com.atwoz.member.infrastructure.selfintro.dto.SelfIntroResponse; +import com.fasterxml.jackson.databind.ObjectMapper; +import java.util.List; +import org.junit.jupiter.api.DisplayNameGeneration; +import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.restdocs.AutoConfigureRestDocs; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.data.domain.Pageable; +import org.springframework.test.web.servlet.MockMvc; + +import static com.atwoz.helper.RestDocsHelper.customDocument; +import static com.atwoz.member.fixture.selfintro.SelfIntroFixture.셀프_소개글_생성_id_있음; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_생성_요청서; +import static com.atwoz.member.fixture.selfintro.SelfIntroRequestFixture.셀프_소개글_수정_요청서; +import static com.atwoz.member.fixture.selfintro.SelfIntroResponseFixture.셀프_소개글_응답; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.http.HttpHeaders.AUTHORIZATION; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.restdocs.headers.HeaderDocumentation.headerWithName; +import static org.springframework.restdocs.headers.HeaderDocumentation.requestHeaders; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.delete; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.get; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.patch; +import static org.springframework.restdocs.mockmvc.RestDocumentationRequestBuilders.post; +import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath; +import static org.springframework.restdocs.payload.PayloadDocumentation.requestFields; +import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields; +import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName; +import static org.springframework.restdocs.request.RequestDocumentation.partWithName; +import static org.springframework.restdocs.request.RequestDocumentation.pathParameters; +import static org.springframework.restdocs.request.RequestDocumentation.requestParts; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@DisplayNameGeneration(ReplaceUnderscores.class) +@SuppressWarnings("NonAsciiCharacters") +@AutoConfigureRestDocs +@WebMvcTest(SelfIntroController.class) +class SelfIntroControllerWebMvcTest extends MockBeanInjection { + + private static final String BEARER_TOKEN = "Bearer token"; + + @Autowired + private MockMvc mockMvc; + + @Autowired + private ObjectMapper objectMapper; + + @Test + void 셀프_소개글을_저장한다() throws Exception { + // given + SelfIntroCreateRequest selfIntroCreateRequest = 셀프_소개글_생성_요청서(); + + // when & then + mockMvc.perform(post("/api/members/self-intros/me") + .header(AUTHORIZATION, BEARER_TOKEN) + .contentType(APPLICATION_JSON) + .content(objectMapper.writeValueAsString(selfIntroCreateRequest))) + .andExpect(status().isOk()) + .andDo(customDocument("셀프_소개글_저장", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + requestFields( + fieldWithPath("content").description("셀프 소개글") + ) + )); + } + + @Test + void 셀프_소개글을_페이징으로_조회한다() throws Exception { + // given + List selfIntroResponses = List.of(셀프_소개글_응답()); + when(selfIntroQueryService.findAllSelfIntrosWithPaging(any(Pageable.class), any())) + .thenReturn(new SelfIntrosResponse(selfIntroResponses, 0, 1, 2)); + + // when & then + mockMvc.perform(get("/api/members/self-intros") + .param("page", "0") + .param("size", "10") + .header(AUTHORIZATION, BEARER_TOKEN)) + .andExpect(status().isOk()) + .andDo(print()) + .andDo(customDocument("셀프_소개글_페이징_조회", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + requestParts( + partWithName("page").description("페이지 번호").optional(), + partWithName("size").description("조회되는 데이터 수, 한 페이지당 조회되는 데이터 수입니다.").optional() + ), + responseFields( + fieldWithPath("selfIntros[].selfIntroId").description("셀프 소개글 id"), + fieldWithPath("selfIntros[].selfIntroContent").description("셀프 소개글"), + fieldWithPath("selfIntros[].nickname").description("작성자 닉네임"), + fieldWithPath("selfIntros[].city").description("작성자가 사는 도시"), + fieldWithPath("selfIntros[].age").description("작성자의 나이"), + fieldWithPath("selfIntros[].height").description("작성자의 키"), + fieldWithPath("nowPage").description("현재 페이지"), + fieldWithPath("nextPage").description("다음 페이지, 다음 페이지가 없을 경우 -1을 반환합니다."), + fieldWithPath("totalPages").description("전체 페이지 수") + ) + )); + } + + @Test + void 셀프_소개글을_필터와_페이징으로_조회한다() throws Exception { + // given + List selfIntroResponses = List.of(셀프_소개글_응답()); + when(selfIntroQueryService.findAllSelfIntrosWithPagingAndFiltering( + any(Pageable.class), any(SelfIntroFilterRequest.class), any()) + ).thenReturn(new SelfIntrosResponse(selfIntroResponses, 0, 1, 2)); + + // when & then + mockMvc.perform(get("/api/members/self-intros/filter") + .param("page", "0") + .param("size", "10") + .param("minAge", "20") + .param("maxAge", "30") + .param("isOnlyOppositeGender", "false") + .param("cityRequests", "서울시,경기도") + .header(AUTHORIZATION, BEARER_TOKEN)) + .andExpect(status().isOk()) + .andDo(print()) + .andDo(customDocument("셀프_소개글_페이징_조회(필터_적용)", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + requestParts( + partWithName("page").description("페이지 번호").optional(), + partWithName("size").description("조회되는 데이터 수, 한 페이지당 조회되는 데이터 수입니다.").optional(), + partWithName("minAge").description("최소 나이(필터)").optional(), + partWithName("maxAge").description("최대 나이(필터)").optional(), + partWithName("isOnlyOppositeGender").description("성별 설정(필터), 이 값이 true일 경우 이성만 조회됩니다.").optional(), + partWithName("cityRequests").description("선호 지역(필터), 지역명을 문자열로 제공해주시면 됩니다.").optional() + ), + responseFields( + fieldWithPath("selfIntros[].selfIntroId").description("셀프 소개글 id"), + fieldWithPath("selfIntros[].selfIntroContent").description("셀프 소개글"), + fieldWithPath("selfIntros[].nickname").description("작성자 닉네임"), + fieldWithPath("selfIntros[].city").description("작성자가 사는 도시"), + fieldWithPath("selfIntros[].age").description("작성자의 나이"), + fieldWithPath("selfIntros[].height").description("작성자의 키"), + fieldWithPath("nowPage").description("현재 페이지"), + fieldWithPath("nextPage").description("다음 페이지, 다음 페이지가 없을 경우 -1을 반환합니다."), + fieldWithPath("totalPages").description("전체 페이지 수") + ) + )); + } + + @Test + void 셀프_소개글을_변경한다() throws Exception { + // given + SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); + SelfIntroUpdateRequest selfIntroUpdateRequest = 셀프_소개글_수정_요청서(); + doNothing().when(selfIntroService) + .updateSelfIntro(selfIntroUpdateRequest, selfIntro.getId(), selfIntro.getMemberId()); + + // when & then + mockMvc.perform(patch("/api/members/self-intros/{id}", selfIntro.getId()) + .header(AUTHORIZATION, BEARER_TOKEN) + .contentType(APPLICATION_JSON) + .content(objectMapper.writeValueAsString(selfIntroUpdateRequest))) + .andExpect(status().isOk()) + .andDo(customDocument("셀프_소개글_변경", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + pathParameters( + parameterWithName("id").description("셀프 소개글 id") + ), + requestFields( + fieldWithPath("content").description("수정한 소개글") + ) + )); + } + + @Test + void 셀프_소개글을_삭제한다() throws Exception { + // given + SelfIntro selfIntro = 셀프_소개글_생성_id_있음(1L); + + // when & then + mockMvc.perform(delete("/api/members/self-intros/{id}", selfIntro.getId()) + .header(AUTHORIZATION, BEARER_TOKEN)) + .andExpect(status().isNoContent()) + .andDo(customDocument("셀프_소개글_삭제", + requestHeaders( + headerWithName(AUTHORIZATION).description("유저 토큰 정보") + ), + pathParameters( + parameterWithName("id").description("셀프 소개글 id") + ) + )); + } +} diff --git a/src/test/java/com/atwoz/memberlike/infrastructure/MemberLikeQueryRepositoryTest.java b/src/test/java/com/atwoz/memberlike/infrastructure/MemberLikeQueryRepositoryTest.java index ee19a57f..384bab3c 100644 --- a/src/test/java/com/atwoz/memberlike/infrastructure/MemberLikeQueryRepositoryTest.java +++ b/src/test/java/com/atwoz/memberlike/infrastructure/MemberLikeQueryRepositoryTest.java @@ -6,6 +6,10 @@ import com.atwoz.memberlike.domain.MemberLike; import com.atwoz.memberlike.domain.MemberLikeRepository; import com.atwoz.memberlike.infrastructure.dto.MemberLikeSimpleResponse; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; @@ -14,12 +18,8 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.stream.Collectors; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; -import static com.atwoz.member.fixture.MemberProfileDtoFixture.회원_프로필_DTO_요청; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberProfileDtoFixture.회원_프로필_DTO_요청; import static com.atwoz.memberlike.fixture.MemberLikeFixture.호감_생성_id_날짜_주입; import static org.assertj.core.api.SoftAssertions.assertSoftly; diff --git a/src/test/java/com/atwoz/memberlike/ui/MemberLikeControllerAcceptanceFixture.java b/src/test/java/com/atwoz/memberlike/ui/MemberLikeControllerAcceptanceFixture.java index 214c1ee4..39793e8d 100644 --- a/src/test/java/com/atwoz/memberlike/ui/MemberLikeControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/memberlike/ui/MemberLikeControllerAcceptanceFixture.java @@ -16,7 +16,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static com.atwoz.memberlike.fixture.MemberLikeFixture.호감_생성_id_주입; import static io.restassured.http.ContentType.JSON; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/atwoz/mission/ui/membermission/MemberMissionsControllerAcceptanceFixture.java b/src/test/java/com/atwoz/mission/ui/membermission/MemberMissionsControllerAcceptanceFixture.java index 2655c117..ce3d958f 100644 --- a/src/test/java/com/atwoz/mission/ui/membermission/MemberMissionsControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/mission/ui/membermission/MemberMissionsControllerAcceptanceFixture.java @@ -20,7 +20,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static com.atwoz.mission.fixture.MemberMissionFixture.멤버_미션_생성_완료_보상_수령_안함_데일리_미션_시간있음; import static com.atwoz.mission.fixture.MissionFixture.미션_생성_리워드_100_데일리_공개_id없음; import static com.atwoz.mission.fixture.MissionFixture.미션_생성_리워드_200_챌린지_id없음; diff --git a/src/test/java/com/atwoz/report/ui/ReportControllerAcceptanceFixture.java b/src/test/java/com/atwoz/report/ui/ReportControllerAcceptanceFixture.java index e49455a3..34c9aa03 100644 --- a/src/test/java/com/atwoz/report/ui/ReportControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/report/ui/ReportControllerAcceptanceFixture.java @@ -13,7 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static com.atwoz.report.domain.vo.ReportType.FAKE_PROFILE; import static io.restassured.http.ContentType.JSON; import static org.assertj.core.api.Assertions.assertThat; diff --git a/src/test/java/com/atwoz/survey/ui/membersurvey/MemberSurveysControllerAcceptanceFixture.java b/src/test/java/com/atwoz/survey/ui/membersurvey/MemberSurveysControllerAcceptanceFixture.java index d0a2d0ea..e0c78b46 100644 --- a/src/test/java/com/atwoz/survey/ui/membersurvey/MemberSurveysControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/survey/ui/membersurvey/MemberSurveysControllerAcceptanceFixture.java @@ -17,7 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static com.atwoz.survey.fixture.SurveyFixture.연애고사_선택_과목_질문_두개씩; import static com.atwoz.survey.fixture.SurveyFixture.연애고사_필수_과목_질문_30개씩; import static io.restassured.http.ContentType.JSON; diff --git a/src/test/java/com/atwoz/survey/ui/survey/SurveyControllerAcceptanceFixture.java b/src/test/java/com/atwoz/survey/ui/survey/SurveyControllerAcceptanceFixture.java index a60fa50a..4d17f0b2 100644 --- a/src/test/java/com/atwoz/survey/ui/survey/SurveyControllerAcceptanceFixture.java +++ b/src/test/java/com/atwoz/survey/ui/survey/SurveyControllerAcceptanceFixture.java @@ -14,7 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; -import static com.atwoz.member.fixture.MemberFixture.일반_유저_생성; +import static com.atwoz.member.fixture.member.MemberFixture.일반_유저_생성; import static io.restassured.http.ContentType.JSON; import static org.assertj.core.api.SoftAssertions.assertSoftly; import static org.springframework.http.HttpHeaders.AUTHORIZATION;