From 9dfea1f32b6456387c61668775c7a7501707cd07 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 00:28:35 +0900 Subject: [PATCH 01/14] =?UTF-8?q?refactor:=20=EC=82=AC=EC=9A=A9=ED=95=98?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8A=94=20MemberRepository=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapbefine/mapbefine/member/domain/MemberRepository.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java index 16b57c059..f5323fe98 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java @@ -7,10 +7,6 @@ public interface MemberRepository extends JpaRepository { Optional findByMemberInfoEmail(String email); - boolean existsByMemberInfoEmail(String email); - - Optional findByOauthIdOauthServerId(Long oauthServerId); - Optional findByOauthId(OauthId oauthId); } From afc314cbe5c4fc6af6ee3889c35f5bb6fbdaa7fe Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 01:00:59 +0900 Subject: [PATCH 02/14] =?UTF-8?q?refactor:=20=ED=9A=8C=EC=9B=90=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=B6=80=EB=B6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=EC=9C=BC=EB=A1=9C=20=EC=8B=9C=EA=B7=B8?= =?UTF-8?q?=EB=8B=88=EC=B2=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 현재 회원 update에서 변경되는 부분만 인자로 남겨둠 - update 시, Member 에서 MemberInfo.getXX을 하는 대신 MemberInfo에서 부분 변경된 객체를 새로 반환하도록 수정 --- .../mapbefine/member/domain/Member.java | 11 +----- .../mapbefine/member/domain/MemberInfo.java | 6 +++ .../member/domain/MemberInfoTest.java | 38 +++++++++++++++---- 3 files changed, 39 insertions(+), 16 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java index 71de6abfb..244499410 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java @@ -103,16 +103,9 @@ private static String createNicknameSuffix() { } public void update( - String nickName, - String email, - String imageUrl + String nickName ) { - memberInfo = MemberInfo.of( - nickName, - email, - imageUrl, - memberInfo.getRole() - ); + memberInfo = memberInfo.createForPatch(nickName); } public void addTopic(Topic topic) { diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java index c15054c3b..e6149fcda 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java @@ -28,6 +28,7 @@ public class MemberInfo { @Column(nullable = false, length = 20, unique = true) private String nickName; + // TODO 카카오에서 email 선택 동의라 체크 안하고 가입하면 DB에서 터질듯 @Column(nullable = false, unique = true) private String email; @@ -93,6 +94,11 @@ private static void validateRole(Role role) { } } + public MemberInfo createForPatch(String nickName) { + + return MemberInfo.of(nickName, this.email, this.imageUrl.getImageUrl(), this.role); + } + public String getImageUrl() { return imageUrl.getImageUrl(); } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java index 7c4d4a200..07e7be319 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java @@ -2,6 +2,7 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.assertj.core.api.SoftAssertions.assertSoftly; import com.mapbefine.mapbefine.common.exception.BadRequestException.ImageBadRequestException; import com.mapbefine.mapbefine.member.exception.MemberException.MemberBadRequestException; @@ -24,8 +25,8 @@ class Validate { private final Role VALID_ROLE = Role.ADMIN; @Test - @DisplayName("정확한 값을 입력하면 객체가 생성된다") - void success() { + @DisplayName("유효한 정보를 입력했을 때 객체를 생성할 수 있다.") + void create_Success() { //given when MemberInfo memberInfo = MemberInfo.of( VALID_NICK_NAME, @@ -42,11 +43,34 @@ void success() { assertThat(memberInfo.getRole()).isEqualTo(VALID_ROLE); } + @Test + @DisplayName("일부 정보(닉네임)만 변경한 회원 정보를 생성할 수 있다.") + void createForPatch() { + // given + MemberInfo before = MemberInfo.of( + "member", + "member@naver.com", + "https://map-befine-official.github.io/favicon.png", + Role.ADMIN); + + // when + String expected = "newNickName"; + MemberInfo patched = before.createForPatch(expected); + + // then + assertSoftly(softly -> { + assertThat(patched).usingRecursiveComparison() + .ignoringFields("nickName") + .isEqualTo(before); + assertThat(patched.getNickName()).isEqualTo(expected); + }); + } + @ParameterizedTest @NullSource @ValueSource(strings = {"", "aaaaaaaaaaaaaaaaaaaaa"}) - @DisplayName("유효한 이름이 아닌 경우 예외가 발생한다") - void whenNameIsInvalid_thenFail(String invalidNickName) { + @DisplayName("유효한 닉네임이 아닌 경우 예외가 발생한다") + void validateNickName(String invalidNickName) { //given when then assertThatThrownBy(() -> MemberInfo.of( invalidNickName, @@ -61,7 +85,7 @@ void whenNameIsInvalid_thenFail(String invalidNickName) { @EmptySource @ValueSource(strings = "member") @DisplayName("유효한 이메일이 아닌 경우 예외가 발생한다") - void whenEmailIsInvalid_thenFail(String invalidEmail) { + void validateEmail(String invalidEmail) { //given when then assertThatThrownBy(() -> MemberInfo.of( VALID_NICK_NAME, @@ -73,7 +97,7 @@ void whenEmailIsInvalid_thenFail(String invalidEmail) { @Test @DisplayName("올바르지 않은 형식의 Image Url 이 들어오는 경우 예외가 발생한다.") - void whenImageUrlIsInvalid_thenFail() { + void validateImageUrl() { String invalidImageUrl = "image.png"; //given when then @@ -87,7 +111,7 @@ void whenImageUrlIsInvalid_thenFail() { @Test @DisplayName("유효하지 않은 Role 이 들어오는 경우 예외가 발생한다.") - void whenRoleIsInvalid_thenFail() { + void validateRole() { //given when then assertThatThrownBy(() -> MemberInfo.of( VALID_NICK_NAME, From 7be1f7196f27af8e707a584ff2afba1d013306c3 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 11:49:32 +0900 Subject: [PATCH 03/14] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20API=20=EA=B5=AC=ED=98=84=20?= =?UTF-8?q?=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/MemberCommandService.java | 32 ++++++++ .../dto/request/MemberUpdateRequest.java | 6 ++ .../member/presentation/MemberController.java | 16 +++- .../member/MemberIntegrationTest.java | 28 +++++-- .../application/MemberCommandServiceTest.java | 75 +++++++++++++++++++ .../application/MemberQueryServiceTest.java | 4 +- .../presentation/MemberControllerTest.java | 15 ++++ 7 files changed, 166 insertions(+), 10 deletions(-) create mode 100644 backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java create mode 100644 backend/src/main/java/com/mapbefine/mapbefine/member/dto/request/MemberUpdateRequest.java create mode 100644 backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java b/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java new file mode 100644 index 000000000..d8264ae31 --- /dev/null +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java @@ -0,0 +1,32 @@ +package com.mapbefine.mapbefine.member.application; + +import com.mapbefine.mapbefine.auth.domain.AuthMember; +import com.mapbefine.mapbefine.member.domain.Member; +import com.mapbefine.mapbefine.member.domain.MemberRepository; +import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; +import java.util.NoSuchElementException; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Transactional +public class MemberCommandService { + + private final MemberRepository memberRepository; + + public MemberCommandService(MemberRepository memberRepository) { + this.memberRepository = memberRepository; + } + + public void updateInfoById(AuthMember authMember, MemberUpdateRequest request) { + Member member = findMemberById(authMember.getMemberId()); + + member.update(request.nickName()); + } + + private Member findMemberById(Long memberId) { + return memberRepository.findById(memberId) + .orElseThrow(() -> new NoSuchElementException("findMemberById; memberId=" + memberId)); + } + +} diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/dto/request/MemberUpdateRequest.java b/backend/src/main/java/com/mapbefine/mapbefine/member/dto/request/MemberUpdateRequest.java new file mode 100644 index 000000000..bada64c97 --- /dev/null +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/dto/request/MemberUpdateRequest.java @@ -0,0 +1,6 @@ +package com.mapbefine.mapbefine.member.dto.request; + +public record MemberUpdateRequest( + String nickName +) { +} diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java b/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java index 119ab4fd1..2c379a794 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java @@ -2,7 +2,9 @@ import com.mapbefine.mapbefine.auth.domain.AuthMember; import com.mapbefine.mapbefine.common.interceptor.LoginRequired; +import com.mapbefine.mapbefine.member.application.MemberCommandService; import com.mapbefine.mapbefine.member.application.MemberQueryService; +import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; import com.mapbefine.mapbefine.member.dto.response.MemberDetailResponse; import com.mapbefine.mapbefine.member.dto.response.MemberResponse; import com.mapbefine.mapbefine.pin.dto.response.PinResponse; @@ -10,7 +12,9 @@ import java.util.List; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -18,9 +22,11 @@ @RequestMapping("/members") public class MemberController { + private final MemberCommandService memberCommandService; private final MemberQueryService memberQueryService; - public MemberController(MemberQueryService memberQueryService) { + public MemberController(MemberCommandService memberCommandService, MemberQueryService memberQueryService) { + this.memberCommandService = memberCommandService; this.memberQueryService = memberQueryService; } @@ -72,4 +78,12 @@ public ResponseEntity> findAllTopicsInBookmark(AuthMember au return ResponseEntity.ok(responses); } + @LoginRequired + @PatchMapping("/my") + public ResponseEntity updateMyInfo(AuthMember authMember, @RequestBody MemberUpdateRequest request) { + memberCommandService.updateInfoById(authMember, request); + + return ResponseEntity.ok().build(); + } + } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java index afdbad42d..11c4cfeeb 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java @@ -1,7 +1,7 @@ package com.mapbefine.mapbefine.member; import static com.mapbefine.mapbefine.oauth.domain.OauthServerType.KAKAO; -import static io.restassured.RestAssured.given; +import static io.restassured.RestAssured.*; import static org.apache.http.HttpHeaders.AUTHORIZATION; import static org.assertj.core.api.Assertions.assertThat; @@ -10,12 +10,12 @@ import com.mapbefine.mapbefine.member.domain.MemberRepository; import com.mapbefine.mapbefine.member.domain.OauthId; import com.mapbefine.mapbefine.member.domain.Role; +import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; import com.mapbefine.mapbefine.member.dto.response.MemberDetailResponse; import com.mapbefine.mapbefine.member.dto.response.MemberResponse; -import io.restassured.RestAssured; -import io.restassured.common.mapper.TypeRef; -import io.restassured.response.ExtractableResponse; -import io.restassured.response.Response; +import io.restassured.*; +import io.restassured.common.mapper.*; +import io.restassured.response.*; import java.util.List; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; @@ -154,7 +154,6 @@ void findTopicsInBookmarks_Success() { .header(AUTHORIZATION, creatorAuthHeader) .accept(MediaType.APPLICATION_JSON_VALUE) .when().get("/members/my/bookmarks") - .then().log().all() .extract(); @@ -170,7 +169,6 @@ void findTopicsFromAtlas_Success() { .log().all() .header(HttpHeaders.AUTHORIZATION, creatorAuthHeader) .when().get("/members/my/atlas") - .then().log().all() .extract(); @@ -178,5 +176,21 @@ void findTopicsFromAtlas_Success() { assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()); } + @Test + @DisplayName("회원 정보를 정상적으로 수정하면, 200을 반환한다") + void updateMemberInfo_Success() { + // when + ExtractableResponse response = RestAssured.given() + .log().all() + .header(HttpHeaders.AUTHORIZATION, creatorAuthHeader) + .contentType(MediaType.APPLICATION_JSON_VALUE) + .body(new MemberUpdateRequest("new nickname")) + .when().patch("/members/my") + .then().log().all() + .extract(); + // then + assertThat(response.statusCode()).isEqualTo(HttpStatus.OK.value()); + } + } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java new file mode 100644 index 000000000..e5e59fc3c --- /dev/null +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java @@ -0,0 +1,75 @@ +package com.mapbefine.mapbefine.member.application; + +import static java.util.Collections.emptyList; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; + +import com.mapbefine.mapbefine.auth.domain.AuthMember; +import com.mapbefine.mapbefine.auth.domain.member.User; +import com.mapbefine.mapbefine.common.annotation.ServiceTest; +import com.mapbefine.mapbefine.member.MemberFixture; +import com.mapbefine.mapbefine.member.domain.Member; +import com.mapbefine.mapbefine.member.domain.MemberRepository; +import com.mapbefine.mapbefine.member.domain.Role; +import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; +import java.util.NoSuchElementException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +@ServiceTest +class MemberCommandServiceTest { + + @Autowired + private MemberCommandService memberCommandService; + @Autowired + private MemberRepository memberRepository; + private Member member; + private AuthMember authMember; + + @BeforeEach + void setUp() { + member = memberRepository.save(MemberFixture.create("member", "member@gmail.com", Role.USER)); + authMember = new User(member.getId(), emptyList(), emptyList()); + } + + @Test + @DisplayName("회원 정보를 수정한다.") + void updateInfoById_Success() { + // given + String expected = "new nickname"; + MemberUpdateRequest request = new MemberUpdateRequest(expected); + + // when + memberCommandService.updateInfoById(authMember, request); + memberRepository.flush(); + + // then + memberRepository.findById(member.getId()) + .map(Member::getMemberInfo) + .ifPresentOrElse( + actual -> { + assertThat(actual).usingRecursiveComparison() + .ignoringFields("nickName") + .isEqualTo(member.getMemberInfo()); + assertThat(actual.getNickName()).isEqualTo(expected); + }, + Assertions::fail + ); + } + + @Test + @DisplayName("존재하지 않는 회원의 정보를 수정하면 예외가 발생한다.") + void updateInfoById_FailByNotExistingMember() { + // given + MemberUpdateRequest request = new MemberUpdateRequest("new nickname"); + User notExistingMember = new User(100L, emptyList(), emptyList()); + + // when, then + assertThatThrownBy(() -> memberCommandService.updateInfoById(notExistingMember, request)) + .isInstanceOf(NoSuchElementException.class); + } + +} diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java index 7152ad0c5..3a352289d 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java @@ -52,7 +52,6 @@ class MemberQueryServiceTest { @Autowired private LocationRepository locationRepository; - private AuthMember authMember; private Member member; private List topics; @@ -127,7 +126,7 @@ void findMemberById_whenNoneExists_thenFail() { @Test @DisplayName("즐겨찾기 목록에 추가 된 토픽을 조회할 수 있다") - public void findAllTopicsInBookmark_success() { + void findAllTopicsInBookmark_success() { // when List allTopicsInBookmark = memberQueryService.findAllTopicsInBookmark(authMember); @@ -199,4 +198,5 @@ void findMyAllPins_Success() { .isEqualTo(pinIds); } + } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java index 7efbf8c36..8e79b3fd8 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java @@ -7,6 +7,7 @@ import com.mapbefine.mapbefine.common.RestDocsIntegration; import com.mapbefine.mapbefine.location.LocationFixture; import com.mapbefine.mapbefine.member.application.MemberQueryService; +import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; import com.mapbefine.mapbefine.member.dto.response.MemberDetailResponse; import com.mapbefine.mapbefine.member.dto.response.MemberResponse; import com.mapbefine.mapbefine.pin.dto.response.PinResponse; @@ -16,6 +17,7 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; class MemberControllerTest extends RestDocsIntegration { @@ -202,4 +204,17 @@ void findMyAllPins() throws Exception { ).andDo(restDocs.document()); } + @Test + @DisplayName("유저의 정보 수정") + void updateMyInfo() throws Exception { + MemberUpdateRequest request = new MemberUpdateRequest("새로운 닉네임"); + + mockMvc.perform( + MockMvcRequestBuilders.patch("/members/my") + .header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) + .contentType(MediaType.APPLICATION_JSON) + .content(objectMapper.writeValueAsString(request)) + ).andDo(restDocs.document()); + } + } From 1613287073388563eff8c59a642dfb0cc8030855 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 14:17:12 +0900 Subject: [PATCH 04/14] =?UTF-8?q?test:=20JwtTokenProviderTest=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 로컬에서 Postman 테스트 시 이 테스트를 사용하면 쉽게 토큰 발급 후 활용 가능 --- .../infrastructure/JwtTokenProviderTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 backend/src/test/java/com/mapbefine/mapbefine/auth/infrastructure/JwtTokenProviderTest.java diff --git a/backend/src/test/java/com/mapbefine/mapbefine/auth/infrastructure/JwtTokenProviderTest.java b/backend/src/test/java/com/mapbefine/mapbefine/auth/infrastructure/JwtTokenProviderTest.java new file mode 100644 index 000000000..8081cf844 --- /dev/null +++ b/backend/src/test/java/com/mapbefine/mapbefine/auth/infrastructure/JwtTokenProviderTest.java @@ -0,0 +1,29 @@ +package com.mapbefine.mapbefine.auth.infrastructure; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.TestPropertySource; + +@SpringBootTest(classes = JwtTokenProvider.class) +@TestPropertySource(locations = "classpath:application.yml") +class JwtTokenProviderTest { + + @Autowired + private JwtTokenProvider jwtTokenProvider; + + @Test + @DisplayName("payload를 받아 JWT 토큰을 생성한다.") + void createToken() { + String payload = "1"; + + String token = jwtTokenProvider.createToken(payload); + + assertThat(jwtTokenProvider.getPayload(token)) + .isEqualTo(payload); + } + +} From 6d9b30516e2329728ff2a7a65e1bafca91969d4a Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 15:45:43 +0900 Subject: [PATCH 05/14] =?UTF-8?q?chore:=20=EB=A1=9C=EC=BB=AC=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=9A=A9=20=EB=8D=94=EB=AF=B8=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20sql=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/data-default.sql | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 backend/src/main/resources/data-default.sql diff --git a/backend/src/main/resources/data-default.sql b/backend/src/main/resources/data-default.sql new file mode 100644 index 000000000..75f9969c1 --- /dev/null +++ b/backend/src/main/resources/data-default.sql @@ -0,0 +1,16 @@ +INSERT INTO member (nick_name, email, image_url, role, + oauth_server_id, oauth_server_type, + created_at, updated_at) +VALUES ('dummyMember', 'dummy@gmail.com', 'https://map-befine-official.github.io/favicon.png', 'USER', + 1L, 'KAKAO', + now(), now()); + +INSERT INTO topic (name, image_url, description, + permission_type, publicity, + member_id, + created_at, updated_at) +VALUES ('dummyTopic', 'https://map-befine-official.github.io/favicon.png', 'description', + 'ALL_MEMBERS', 'PUBLIC', + 1L, + now(), now()) +; From b90630c7cc49d937add1ef82f6f5644e080ad2ca Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 16:03:21 +0900 Subject: [PATCH 06/14] =?UTF-8?q?chore:=20=EB=A1=9C=EC=BB=AC=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20data.sql=EC=9D=84=20=EC=9C=84=ED=95=9C=20=EC=84=9C?= =?UTF-8?q?=EB=B8=8C=EB=AA=A8=EB=93=88=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/resources/config b/backend/src/main/resources/config index 9842778b9..0b448b778 160000 --- a/backend/src/main/resources/config +++ b/backend/src/main/resources/config @@ -1 +1 @@ -Subproject commit 9842778b9712e4c1eb5c918e2fa254edbafb8a04 +Subproject commit 0b448b7781204387184f5ce47a575a5b2d955128 From 016496f6e0785433923213bc56bb0f8989078dfd Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 16:31:00 +0900 Subject: [PATCH 07/14] =?UTF-8?q?docs:=20=EA=B8=B0=EB=8A=A5=20=EB=AA=85?= =?UTF-8?q?=EC=84=B8=EC=84=9C=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=9A=A9=EC=96=B4=20=EC=A0=95=EB=A6=AC=20?= =?UTF-8?q?(=EC=9C=A0=EC=A0=80,=20=EB=A9=A4=EB=B2=84=20->=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/docs/README.md | 10 +++++----- backend/src/docs/asciidoc/bookmark.adoc | 4 ++-- backend/src/docs/asciidoc/member.adoc | 14 +++++++------- backend/src/docs/asciidoc/permission.adoc | 4 ++-- backend/src/docs/asciidoc/pin.adoc | 2 +- backend/src/docs/asciidoc/topic.adoc | 2 +- .../mapbefine/mapbefine/member/domain/Role.java | 2 +- .../atlas/application/AtlasCommandServiceTest.java | 2 +- .../bookmark/BookmarkIntegrationTest.java | 4 ++-- .../application/BookmarkCommandServiceTest.java | 4 ++-- .../presentation/BookmarkControllerTest.java | 6 +++--- .../mapbefine/member/MemberIntegrationTest.java | 10 +++++----- .../member/application/MemberQueryServiceTest.java | 10 +++++----- .../member/presentation/MemberControllerTest.java | 14 +++++++------- .../oauth/presentation/OauthControllerTest.java | 2 +- .../permission/PermissionIntegrationTest.java | 4 ++-- .../application/PermissionCommandServiceTest.java | 8 ++++---- .../mapbefine/pin/PinIntegrationTest.java | 2 +- .../pin/application/PinQueryServiceTest.java | 2 +- .../pin/presentation/PinControllerTest.java | 2 +- .../mapbefine/mapbefine/topic/TopicFixture.java | 4 ++-- .../mapbefine/topic/TopicIntegrationTest.java | 2 +- .../topic/application/TopicCommandServiceTest.java | 4 ++-- .../topic/application/TopicQueryServiceTest.java | 14 +++++++------- .../mapbefine/topic/domain/TopicStatusTest.java | 2 +- .../topic/presentation/TopicControllerTest.java | 2 +- 26 files changed, 68 insertions(+), 68 deletions(-) diff --git a/backend/docs/README.md b/backend/docs/README.md index 54684f71c..4834bd968 100644 --- a/backend/docs/README.md +++ b/backend/docs/README.md @@ -39,19 +39,19 @@ - 핀 상세 조회 -#### 유저 핀 +#### 회원 핀 -- 유저 핀 생성 +- 회원 핀 생성 -- 유저 핀 정보 수정 +- 회원 핀 정보 수정 - name, description 만 수정 가능하다. - description 은 1000자 까지만 가능하다. -- 유저 핀 삭제 +- 회원 핀 삭제 - Delete 는 Soft Delete --- -- 유저 핀 목록 조회 +- 회원 핀 목록 조회 - 페이지 네이션 (무한 스크롤, 일단 15개) diff --git a/backend/src/docs/asciidoc/bookmark.adoc b/backend/src/docs/asciidoc/bookmark.adoc index d416a87d8..64acd65e7 100644 --- a/backend/src/docs/asciidoc/bookmark.adoc +++ b/backend/src/docs/asciidoc/bookmark.adoc @@ -1,10 +1,10 @@ == 즐겨찾기 -=== 토픽을 유저의 즐겨찾기에 추가 +=== 토픽을 회원의 즐겨찾기에 추가 operation::bookmark-controller-test/add-topic-in-bookmark[snippets='http-request,http-response'] -=== 유저의 토픽 즐겨찾기 삭제 +=== 회원의 토픽 즐겨찾기 삭제 operation::bookmark-controller-test/delete-topic-in-bookmark[snippets='http-request,http-response'] diff --git a/backend/src/docs/asciidoc/member.adoc b/backend/src/docs/asciidoc/member.adoc index 94ffcb6e0..114112e4d 100644 --- a/backend/src/docs/asciidoc/member.adoc +++ b/backend/src/docs/asciidoc/member.adoc @@ -1,25 +1,25 @@ -== 유저 +== 회원 -=== 유저 목록 조회 +=== 회원 목록 조회 operation::member-controller-test/find-all-member[snippets='http-request,http-response'] -=== 유저 단일 조회 +=== 회원 단일 조회 operation::member-controller-test/find-member-by-id[snippets='http-request,http-response'] -=== 유저의 나의 지도 목록 조회 +=== 회원의 나의 지도 목록 조회 operation::member-controller-test/find-my-all-topics[snippets='http-request,http-response'] -=== 유저의 나의 핀 목록 조회 +=== 회원의 나의 핀 목록 조회 operation::member-controller-test/find-my-all-pins[snippets='http-request,http-response'] -=== 유저의 모아보기 조회 +=== 회원의 모아보기 조회 operation::member-controller-test/find-all-topics-in-atlas[snippets='http-request,http-response'] -=== 유저의 즐겨찾기 조회 +=== 회원의 즐겨찾기 조회 operation::member-controller-test/find-all-topics-in-bookmark[snippets='http-request,http-response'] diff --git a/backend/src/docs/asciidoc/permission.adoc b/backend/src/docs/asciidoc/permission.adoc index c704d7ed3..4b232e68c 100644 --- a/backend/src/docs/asciidoc/permission.adoc +++ b/backend/src/docs/asciidoc/permission.adoc @@ -8,10 +8,10 @@ operation::permission-controller-test/add-permission[snippets='http-request,http operation::permission-controller-test/delete-permission[snippets='http-request,http-response'] -=== 토픽에 권한을 가진 유저 목록 조회 +=== 토픽에 권한을 가진 회원 목록 조회 operation::permission-controller-test/find-all-topic-permissions[snippets='http-request,http-response'] -=== 토픽에 권한을 가진 유저 단일 조회 +=== 토픽에 권한을 가진 회원 단일 조회 operation::permission-controller-test/find-permission-by-id[snippets='http-request,http-response'] diff --git a/backend/src/docs/asciidoc/pin.adoc b/backend/src/docs/asciidoc/pin.adoc index 244d156ee..33b15e36b 100644 --- a/backend/src/docs/asciidoc/pin.adoc +++ b/backend/src/docs/asciidoc/pin.adoc @@ -8,7 +8,7 @@ operation::pin-controller-test/find-all[snippets='http-request,http-response'] operation::pin-controller-test/find-by-id[snippets='http-request,http-response'] -=== 멤버별 핀 목록 조회 +=== 회원별 핀 목록 조회 operation::pin-controller-test/find-all-pins-by-member-id[snippets='http-request,http-response'] diff --git a/backend/src/docs/asciidoc/topic.adoc b/backend/src/docs/asciidoc/topic.adoc index 524f94a34..423568377 100644 --- a/backend/src/docs/asciidoc/topic.adoc +++ b/backend/src/docs/asciidoc/topic.adoc @@ -12,7 +12,7 @@ operation::topic-controller-test/find-all-by-order-by-updated-at-desc[snippets=' operation::topic-controller-test/find-all-best-topics[snippets='http-request,http-response'] -=== 멤버별 토픽 목록 조회 +=== 회원별 토픽 목록 조회 operation::topic-controller-test/find-all-topics-by-member-id[snippets='http-request,http-response'] diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Role.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Role.java index 9222f5248..96b749832 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Role.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Role.java @@ -9,7 +9,7 @@ public enum Role { ADMIN("ROLE_ADMIN", "운영자"), - USER("ROLE_USER", "로그인 유저"), + USER("ROLE_USER", "로그인 회원"), GUEST("ROLE_GUEST", "손님"); private final String key; diff --git a/backend/src/test/java/com/mapbefine/mapbefine/atlas/application/AtlasCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/atlas/application/AtlasCommandServiceTest.java index ba20c8b53..28b4975cb 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/atlas/application/AtlasCommandServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/atlas/application/AtlasCommandServiceTest.java @@ -105,7 +105,7 @@ void validateReadPermission_fail() { } @Test - @DisplayName("멤버 ID와 TopicId가 있을 경우, atlas에서 해당 topic을 비운다.") + @DisplayName("회원 ID와 TopicId가 있을 경우, atlas에서 해당 topic을 비운다.") void remove_Success() { Long topicId = topic.getId(); Long memberId = authMember.getMemberId(); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/BookmarkIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/BookmarkIntegrationTest.java index bbe7e6ff1..022fefba2 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/BookmarkIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/BookmarkIntegrationTest.java @@ -33,7 +33,7 @@ public class BookmarkIntegrationTest extends IntegrationTest { private BookmarkRepository bookmarkRepository; @Test - @DisplayName("유저가 토픽을 즐겨찾기 목록에 추가하면, 201을 반환한다.") + @DisplayName("회원이 토픽을 즐겨찾기 목록에 추가하면, 201을 반환한다.") void addTopicInBookmark_Success() { //given Member creator = MemberFixture.create("member", "member@naver.com", Role.USER); @@ -63,7 +63,7 @@ void addTopicInBookmark_Success() { } @Test - @DisplayName("유저의 즐겨찾기 토픽을 삭제하면, 204를 반환한다.") + @DisplayName("회원의 즐겨찾기 토픽을 삭제하면, 204를 반환한다.") void deleteTopicInBookmark_Success() { //given Member creator = MemberFixture.create("member", "member@naver.com", Role.USER); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/application/BookmarkCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/application/BookmarkCommandServiceTest.java index 76429f976..4db118c86 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/application/BookmarkCommandServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/application/BookmarkCommandServiceTest.java @@ -39,7 +39,7 @@ class BookmarkCommandServiceTest { private TestEntityManager testEntityManager; @Test - @DisplayName("다른 유저의 토픽을 즐겨찾기에 추가할 수 있다.") + @DisplayName("다른 회원의 토픽을 즐겨찾기에 추가할 수 있다.") public void addTopicInBookmark_Success() { //given Member creator = MemberFixture.create( @@ -72,7 +72,7 @@ public void addTopicInBookmark_Success() { } @Test - @DisplayName("권한이 없는 다른 유저의 토픽을 즐겨찾기에 추가할 수 없다.") + @DisplayName("권한이 없는 다른 회원의 토픽을 즐겨찾기에 추가할 수 없다.") public void addTopicInBookmark_Fail1() { //given Member creator = MemberFixture.create( diff --git a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/presentation/BookmarkControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/presentation/BookmarkControllerTest.java index ff3e23076..b65443d93 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/bookmark/presentation/BookmarkControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/bookmark/presentation/BookmarkControllerTest.java @@ -19,7 +19,7 @@ class BookmarkControllerTest extends RestDocsIntegration { @Test - @DisplayName("토픽을 유저의 즐겨찾기에 추가") + @DisplayName("토픽을 회원의 즐겨찾기에 추가") public void addTopicInBookmark() throws Exception { given(bookmarkCommandService.addTopicInBookmark(any(), any())).willReturn(1L); @@ -31,7 +31,7 @@ public void addTopicInBookmark() throws Exception { } @Test - @DisplayName("유저의 토픽 즐겨찾기 목록 삭제") + @DisplayName("회원의 토픽 즐겨찾기 목록 삭제") public void deleteTopicInBookmark() throws Exception { doNothing().when(bookmarkCommandService).deleteTopicInBookmark(any(), any()); @@ -42,4 +42,4 @@ public void deleteTopicInBookmark() throws Exception { ).andDo(restDocs.document()); } -} \ No newline at end of file +} diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java index 11c4cfeeb..b4031f5ae 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java @@ -69,7 +69,7 @@ public void setUp() { } @Test - @DisplayName("유저 목록을 조회한다.") + @DisplayName("회원 목록을 조회한다.") void findAllMember() { // given, when ExtractableResponse response = given().log().all() @@ -94,7 +94,7 @@ void findAllMember() { } @Test - @DisplayName("유저를 단일 조회한다.") + @DisplayName("회원을 단일 조회한다.") void findMemberById() { // given, when ExtractableResponse response = given().log().all() @@ -115,7 +115,7 @@ void findMemberById() { } @Test - @DisplayName("로그인 유저가 내 지도 목록을 조회하면, 200을 반환한다.") + @DisplayName("로그인 회원이 내 지도 목록을 조회하면, 200을 반환한다.") void findMyAllTopics_Success() { //when ExtractableResponse response = given().log().all() @@ -131,7 +131,7 @@ void findMyAllTopics_Success() { @Test - @DisplayName("로그인 유저가 내 지도 목록을 조회하면, 200을 반환한다.") + @DisplayName("로그인 회원이 내 지도 목록을 조회하면, 200을 반환한다.") void findMyAllPins_Success() { //when ExtractableResponse response = given().log().all() @@ -147,7 +147,7 @@ void findMyAllPins_Success() { @Test - @DisplayName("유저의 즐겨찾기 토픽 목록을 조회하면, 200을 반환한다.") + @DisplayName("회원의 즐겨찾기 토픽 목록을 조회하면, 200을 반환한다.") void findTopicsInBookmarks_Success() { //when ExtractableResponse response = given().log().all() diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java index 3a352289d..2e0d8a4c3 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberQueryServiceTest.java @@ -77,7 +77,7 @@ private void createTopics(Member member) { } @Test - @DisplayName("유저 목록을 조회한다.") + @DisplayName("회원 목록을 조회한다.") void findAllMember() { // given Member member2 = memberRepository.save( @@ -100,7 +100,7 @@ void findAllMember() { } @Test - @DisplayName("유저를 단일 조회한다.") + @DisplayName("회원을 단일 조회한다.") void findMemberById() { // given Member member = memberRepository.save( @@ -116,7 +116,7 @@ void findMemberById() { } @Test - @DisplayName("조회하려는 유저가 없는 경우 예외를 반환한다.") + @DisplayName("조회하려는 회원이 없는 경우 예외를 반환한다.") void findMemberById_whenNoneExists_thenFail() { // given when then assertThatThrownBy(() -> memberQueryService.findById(Long.MAX_VALUE)) @@ -142,7 +142,7 @@ void findAllTopicsInBookmark_success() { @Test - @DisplayName("멤버 ID를 이용해 모아보기할 모든 Topic들을 가져올 수 있다.") + @DisplayName("회원 ID를 이용해 모아보기할 모든 Topic들을 가져올 수 있다.") void findAtlasByMember_Success() { // when List allTopicsInAtlas = memberQueryService.findAllTopicsInAtlas(authMember); @@ -174,7 +174,7 @@ void findMyAllTopics_Success() { } @Test - @DisplayName("로그인한 유저가 생성한 모든 핀을 가져올 수 있다.") + @DisplayName("로그인한 회원이 생성한 모든 핀을 가져올 수 있다.") void findMyAllPins_Success() { // given Location location = locationRepository.save(LocationFixture.create()); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java index 8e79b3fd8..6454b67b1 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java @@ -26,7 +26,7 @@ class MemberControllerTest extends RestDocsIntegration { private MemberQueryService memberQueryService; @Test - @DisplayName("유저 목록 조회") + @DisplayName("회원 목록 조회") void findAllMember() throws Exception { List memberResponses = List.of( new MemberResponse( @@ -50,7 +50,7 @@ void findAllMember() throws Exception { } @Test - @DisplayName("유저 단일 조회") + @DisplayName("회원 단일 조회") void findMemberById() throws Exception { MemberDetailResponse memberDetailResponse = new MemberDetailResponse( 1L, @@ -69,7 +69,7 @@ void findMemberById() throws Exception { } @Test - @DisplayName("유저의 모아보기 목록 조회") + @DisplayName("회원의 모아보기 목록 조회") void findAllTopicsInAtlas() throws Exception { List responses = List.of( new TopicResponse( @@ -104,7 +104,7 @@ void findAllTopicsInAtlas() throws Exception { } @Test - @DisplayName("유저의 즐겨찾기 목록 조회") + @DisplayName("회원의 즐겨찾기 목록 조회") void findAllTopicsInBookmark() throws Exception { List responses = List.of( new TopicResponse( @@ -139,7 +139,7 @@ void findAllTopicsInBookmark() throws Exception { } @Test - @DisplayName("유저의 지도 목록 조회") + @DisplayName("회원의 지도 목록 조회") void findMyAllTopics() throws Exception { List responses = List.of( new TopicResponse( @@ -174,7 +174,7 @@ void findMyAllTopics() throws Exception { } @Test - @DisplayName("유저의 핀 목록 조회") + @DisplayName("회원의 핀 목록 조회") void findMyAllPins() throws Exception { List responses = List.of( new PinResponse( @@ -205,7 +205,7 @@ void findMyAllPins() throws Exception { } @Test - @DisplayName("유저의 정보 수정") + @DisplayName("회원의 정보 수정") void updateMyInfo() throws Exception { MemberUpdateRequest request = new MemberUpdateRequest("새로운 닉네임"); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/oauth/presentation/OauthControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/oauth/presentation/OauthControllerTest.java index 0ed9e5d1d..60fc1b565 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/oauth/presentation/OauthControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/oauth/presentation/OauthControllerTest.java @@ -37,7 +37,7 @@ void redirection() throws Exception { } @Test - @DisplayName("소셜 로그인 성공시 로그인한 유저 정보 반환") + @DisplayName("소셜 로그인 성공시 로그인한 회원 정보 반환") void login() throws Exception { // given String code = "auth_code"; diff --git a/backend/src/test/java/com/mapbefine/mapbefine/permission/PermissionIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/permission/PermissionIntegrationTest.java index 983dd8e0c..cfa164f3c 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/permission/PermissionIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/permission/PermissionIntegrationTest.java @@ -79,7 +79,7 @@ public void setUp() { } @Test - @DisplayName("Topic 을 만든자가 특정 유저에게 권한을 준다.") + @DisplayName("Topic 을 만든자가 특정 회원에게 권한을 준다.") void addPermission() { // given Topic topic = topicRepository.save(TopicFixture.createByName("topicName", creator)); @@ -100,7 +100,7 @@ void addPermission() { } @Test - @DisplayName("Topic 을 만든자가 특정 유저에게 권한을 삭제한다.") + @DisplayName("Topic 을 만든자가 특정 회원에게 권한을 삭제한다.") void deletePermission() { // given Topic topic = topicRepository.save(TopicFixture.createByName("topicName", creator)); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/permission/application/PermissionCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/permission/application/PermissionCommandServiceTest.java index 9fe7ec610..73a86dc30 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/permission/application/PermissionCommandServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/permission/application/PermissionCommandServiceTest.java @@ -99,7 +99,7 @@ void saveMemberTopicPermissionByCreator() { } @Test - @DisplayName("Creator 가 아닌 유저가 권한을 주려는 경우 예외가 발생한다.") + @DisplayName("Creator 가 아닌 회원이 권한을 주려는 경우 예외가 발생한다.") void saveMemberTopicPermissionByUser() { // given Member creator = memberRepository.save( @@ -127,7 +127,7 @@ void saveMemberTopicPermissionByUser() { } @Test - @DisplayName("Guest 가 유저에게 권한을 주려는 경우 예외가 발생한다.") + @DisplayName("Guest 가 회원에게 권한을 주려는 경우 예외가 발생한다.") void saveMemberTopicPermissionByGuest() { // given Member creator = memberRepository.save( @@ -262,7 +262,7 @@ void deleteMemberTopicPermissionByCreator() { } @Test - @DisplayName("creator 가 아닌 유저가 권한을 삭제하는 경우 예외가 발생한다.") + @DisplayName("creator 가 아닌 회원이 권한을 삭제하는 경우 예외가 발생한다.") void deleteMemberTopicPermissionByUser() { // given Member creator = memberRepository.save( @@ -289,7 +289,7 @@ void deleteMemberTopicPermissionByUser() { } @Test - @DisplayName("존재하지 않는 유저의 권한을 삭제하려 하려는 경우 예외가 발생한다.") + @DisplayName("존재하지 않는 회원의 권한을 삭제하려 하려는 경우 예외가 발생한다.") void deleteMemberTopicPermissionByCreator_whenNoneExistsPermission_thenFail() { // given Member creator = memberRepository.save( diff --git a/backend/src/test/java/com/mapbefine/mapbefine/pin/PinIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/pin/PinIntegrationTest.java index f69a1e2d7..c154156b7 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/pin/PinIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/pin/PinIntegrationTest.java @@ -242,7 +242,7 @@ void removeImage_Success() { @Test - @DisplayName("멤버별 Pin 목록을 조회하면 200을 반환한다") + @DisplayName("회원별 Pin 목록을 조회하면 200을 반환한다") void findAllPinsByMemberId_Success() { //given createPinAndGetId(createRequestDuplicateLocation); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/pin/application/PinQueryServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/pin/application/PinQueryServiceTest.java index d1b3537f9..25d0f59e9 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/pin/application/PinQueryServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/pin/application/PinQueryServiceTest.java @@ -131,7 +131,7 @@ void findDetailById_FailByForbidden() { } @Test - @DisplayName("멤버 Id를 이용하여 그 멤버가 만든 모든 Pin을 확인할 수 있다.") + @DisplayName("회원 Id를 이용하여 그 회원이 만든 모든 Pin을 확인할 수 있다.") void findAllPinsByMemberId_success() { // given List expected = pinRepository.saveAll(List.of( diff --git a/backend/src/test/java/com/mapbefine/mapbefine/pin/presentation/PinControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/pin/presentation/PinControllerTest.java index 88876fbd2..b5c9eafc3 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/pin/presentation/PinControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/pin/presentation/PinControllerTest.java @@ -188,7 +188,7 @@ void removeImage() throws Exception { @Test - @DisplayName("멤버 Id를 입력하면 해당 멤버가 만든 핀 목록을 조회할 수 있다.") + @DisplayName("회원 Id를 입력하면 해당 회원이 만든 핀 목록을 조회할 수 있다.") void findAllPinsByMemberId() throws Exception { List pinResponses = List.of( new PinResponse( diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicFixture.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicFixture.java index ed8a196a4..a8c4d93c3 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicFixture.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicFixture.java @@ -16,8 +16,8 @@ public class TopicFixture { public static Topic createPrivateAndGroupOnlyTopic(Member member) { return Topic.createTopicAssociatedWithCreator( - "토픽 멤버만 읽을 수 있는 토픽", - "토픽 멤버만 읽을 수 있습니다.", + "토픽 회원만 읽을 수 있는 토픽", + "토픽 회원만 읽을 수 있습니다.", IMAGE_URL, Publicity.PRIVATE, PermissionType.GROUP_ONLY, diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicIntegrationTest.java index f344ce9a4..80c13a9f3 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/TopicIntegrationTest.java @@ -404,7 +404,7 @@ void findAllByOrderByUpdatedAtDesc_Success() { } @Test - @DisplayName("멤버별 Topic 목록을 조회하면 200을 반환한다") + @DisplayName("회원별 Topic 목록을 조회하면 200을 반환한다") void findAllTopicsByMemberId_Success() { // when ExtractableResponse response = RestAssured diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicCommandServiceTest.java index be5266088..813ba6e77 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicCommandServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicCommandServiceTest.java @@ -303,8 +303,8 @@ public void updateTopicInfo_Success() { topicRepository.save(topic); //when - assertThat(topic.getTopicInfo().getName()).isEqualTo("토픽 멤버만 읽을 수 있는 토픽"); - assertThat(topic.getTopicInfo().getDescription()).isEqualTo("토픽 멤버만 읽을 수 있습니다."); + assertThat(topic.getTopicInfo().getName()).isEqualTo("토픽 회원만 읽을 수 있는 토픽"); + assertThat(topic.getTopicInfo().getDescription()).isEqualTo("토픽 회원만 읽을 수 있습니다."); AuthMember user = MemberFixture.createUser(member); TopicUpdateRequest request = new TopicUpdateRequest( diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicQueryServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicQueryServiceTest.java index 302d7aac1..5196a7f6c 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicQueryServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/application/TopicQueryServiceTest.java @@ -80,8 +80,8 @@ void findAllReadable_Success1() { assertThat(topics).extractingResultOf("name") .containsExactlyInAnyOrder( "아무나 읽을 수 있는 토픽", - "토픽 멤버만 읽을 수 있는 토픽", - "토픽 멤버만 읽을 수 있는 토픽" + "토픽 회원만 읽을 수 있는 토픽", + "토픽 회원만 읽을 수 있는 토픽" ); } @@ -194,7 +194,7 @@ void findDetailByIds_Success2() { //then assertThat(details).hasSize(2); assertThat(details).extractingResultOf("name") - .containsExactlyInAnyOrder("아무나 읽을 수 있는 토픽", "토픽 멤버만 읽을 수 있는 토픽"); + .containsExactlyInAnyOrder("아무나 읽을 수 있는 토픽", "토픽 회원만 읽을 수 있는 토픽"); } @Test @@ -257,7 +257,7 @@ void findAllReadableWithBookmark_Success() { } @Test - @DisplayName("모든 토픽을 조회할 때, 로그인 유저가 아니면 즐겨찾기 여부가 항상 False다") + @DisplayName("모든 토픽을 조회할 때, 로그인 회원이 아니면 즐겨찾기 여부가 항상 False다") void findAllReadableWithoutBookmark_Success() { //given Topic topic1 = TopicFixture.createPublicAndAllMembersTopic(member); @@ -300,7 +300,7 @@ void findWithBookmarkStatus_Success() { } @Test - @DisplayName("토픽 상세조회시, 로그인 유저가 아니라면 즐겨찾기 여부, 모아보기 여부, 수정 권한 여부가 항상 False다.") + @DisplayName("토픽 상세조회시, 로그인 회원이 아니라면 즐겨찾기 여부, 모아보기 여부, 수정 권한 여부가 항상 False다.") void findWithoutBookmarkStatus_Success() { //given Topic topic = TopicFixture.createPublicAndAllMembersTopic(member); @@ -344,7 +344,7 @@ void findDetailsWithBookmarkStatus_Success() { } @Test - @DisplayName("여러 토픽 조회시, 로그인 유저가 아니라면 즐겨 찾기 여부가 항상 False다.") + @DisplayName("여러 토픽 조회시, 로그인 회원이 아니라면 즐겨 찾기 여부가 항상 False다.") void findDetailsWithoutBookmarkStatus_Success() { //given Topic topic1 = TopicFixture.createPublicAndAllMembersTopic(member); @@ -368,7 +368,7 @@ void findDetailsWithoutBookmarkStatus_Success() { } @Test - @DisplayName("멤버 Id를 이용하여 그 멤버가 만든 모든 Topic을 확인할 수 있다.") + @DisplayName("회원 Id를 이용하여 그 회원이 만든 모든 Topic을 확인할 수 있다.") void findAllTopicsByMemberId_Success() { //given AuthMember authMember = new Admin(member.getId()); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/domain/TopicStatusTest.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/domain/TopicStatusTest.java index 74667963f..bde0c8064 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/domain/TopicStatusTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/domain/TopicStatusTest.java @@ -104,7 +104,7 @@ public void whenPermissionIsNull_Fail() { class Update { @Test - @DisplayName("권한 범위가 모든 멤버이면, 공개 범위를 혼자 볼 지도로 설정할 때 예외가 발생한다") + @DisplayName("권한 범위가 모든 회원이면, 공개 범위를 혼자 볼 지도로 설정할 때 예외가 발생한다") void whenAllMembersAndPrivate_thenFail() { //given TopicStatus topicStatus = TopicStatus.of(Publicity.PUBLIC, PermissionType.ALL_MEMBERS); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/topic/presentation/TopicControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/topic/presentation/TopicControllerTest.java index ba19dc2b5..da72796fe 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/topic/presentation/TopicControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/topic/presentation/TopicControllerTest.java @@ -219,7 +219,7 @@ void findAllByOrderByUpdatedAtDesc() throws Exception { } @Test - @DisplayName("멤버 Id를 입력하면 해당 멤버가 만든 지도 목록을 조회할 수 있다.") + @DisplayName("회원 Id를 입력하면 해당 회원이 만든 지도 목록을 조회할 수 있다.") void findAllTopicsByMemberId() throws Exception { given(topicQueryService.findAllTopicsByMemberId(any(), any())).willReturn(RESPONSES); From 5ffb6cb2c8eed81ddefd2cc82895e49fd14172f2 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Thu, 14 Sep 2023 16:36:52 +0900 Subject: [PATCH 08/14] =?UTF-8?q?chore:=20=EB=A1=9C=EA=B7=B8=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=84=A4=EC=A0=95=20=ED=8C=8C=EC=9D=BC=20=EB=94=94?= =?UTF-8?q?=EB=A0=89=ED=84=B0=EB=A6=AC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/main/resources/{ => logback}/console-appender.xml | 0 backend/src/main/resources/{ => logback}/file-debug-appender.xml | 0 backend/src/main/resources/{ => logback}/file-error-appender.xml | 0 .../src/main/resources/{ => logback}/file-hibernate-appender.xml | 0 backend/src/main/resources/{ => logback}/file-info-appender.xml | 0 backend/src/main/resources/{ => logback}/file-warn-appender.xml | 0 backend/src/main/resources/{ => logback}/logback-spring.xml | 0 backend/src/main/resources/{ => logback}/slack-error-appender.xml | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename backend/src/main/resources/{ => logback}/console-appender.xml (100%) rename backend/src/main/resources/{ => logback}/file-debug-appender.xml (100%) rename backend/src/main/resources/{ => logback}/file-error-appender.xml (100%) rename backend/src/main/resources/{ => logback}/file-hibernate-appender.xml (100%) rename backend/src/main/resources/{ => logback}/file-info-appender.xml (100%) rename backend/src/main/resources/{ => logback}/file-warn-appender.xml (100%) rename backend/src/main/resources/{ => logback}/logback-spring.xml (100%) rename backend/src/main/resources/{ => logback}/slack-error-appender.xml (100%) diff --git a/backend/src/main/resources/console-appender.xml b/backend/src/main/resources/logback/console-appender.xml similarity index 100% rename from backend/src/main/resources/console-appender.xml rename to backend/src/main/resources/logback/console-appender.xml diff --git a/backend/src/main/resources/file-debug-appender.xml b/backend/src/main/resources/logback/file-debug-appender.xml similarity index 100% rename from backend/src/main/resources/file-debug-appender.xml rename to backend/src/main/resources/logback/file-debug-appender.xml diff --git a/backend/src/main/resources/file-error-appender.xml b/backend/src/main/resources/logback/file-error-appender.xml similarity index 100% rename from backend/src/main/resources/file-error-appender.xml rename to backend/src/main/resources/logback/file-error-appender.xml diff --git a/backend/src/main/resources/file-hibernate-appender.xml b/backend/src/main/resources/logback/file-hibernate-appender.xml similarity index 100% rename from backend/src/main/resources/file-hibernate-appender.xml rename to backend/src/main/resources/logback/file-hibernate-appender.xml diff --git a/backend/src/main/resources/file-info-appender.xml b/backend/src/main/resources/logback/file-info-appender.xml similarity index 100% rename from backend/src/main/resources/file-info-appender.xml rename to backend/src/main/resources/logback/file-info-appender.xml diff --git a/backend/src/main/resources/file-warn-appender.xml b/backend/src/main/resources/logback/file-warn-appender.xml similarity index 100% rename from backend/src/main/resources/file-warn-appender.xml rename to backend/src/main/resources/logback/file-warn-appender.xml diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback/logback-spring.xml similarity index 100% rename from backend/src/main/resources/logback-spring.xml rename to backend/src/main/resources/logback/logback-spring.xml diff --git a/backend/src/main/resources/slack-error-appender.xml b/backend/src/main/resources/logback/slack-error-appender.xml similarity index 100% rename from backend/src/main/resources/slack-error-appender.xml rename to backend/src/main/resources/logback/slack-error-appender.xml From 318228f81336f72af51197271ef8f415c98d5a2b Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 00:48:14 +0900 Subject: [PATCH 09/14] =?UTF-8?q?feat:=20=EB=8B=89=EB=84=A4=EC=9E=84=20?= =?UTF-8?q?=EC=A4=91=EB=B3=B5=20=EA=B2=80=EC=A6=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/MemberCommandService.java | 13 ++++++++++++- .../mapbefine/member/domain/MemberInfo.java | 1 - .../mapbefine/member/domain/MemberRepository.java | 2 ++ .../member/exception/MemberErrorCode.java | 1 + .../member/exception/MemberException.java | 7 +++++++ .../application/MemberCommandServiceTest.java | 14 ++++++++++++++ 6 files changed, 36 insertions(+), 2 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java b/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java index d8264ae31..d7c315f4d 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/application/MemberCommandService.java @@ -4,6 +4,8 @@ import com.mapbefine.mapbefine.member.domain.Member; import com.mapbefine.mapbefine.member.domain.MemberRepository; import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; +import com.mapbefine.mapbefine.member.exception.MemberErrorCode; +import com.mapbefine.mapbefine.member.exception.MemberException.MemberConflictException; import java.util.NoSuchElementException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -20,8 +22,11 @@ public MemberCommandService(MemberRepository memberRepository) { public void updateInfoById(AuthMember authMember, MemberUpdateRequest request) { Member member = findMemberById(authMember.getMemberId()); + String nickName = request.nickName(); - member.update(request.nickName()); + validateNicknameDuplicated(nickName); + + member.update(nickName); } private Member findMemberById(Long memberId) { @@ -29,4 +34,10 @@ private Member findMemberById(Long memberId) { .orElseThrow(() -> new NoSuchElementException("findMemberById; memberId=" + memberId)); } + private void validateNicknameDuplicated(String nickName) { + if (memberRepository.existsByMemberInfoNickName(nickName)) { + throw new MemberConflictException(MemberErrorCode.ILLEGAL_NICKNAME_ALREADY_EXISTS, nickName); + } + } + } diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java index e6149fcda..c27afa780 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java @@ -28,7 +28,6 @@ public class MemberInfo { @Column(nullable = false, length = 20, unique = true) private String nickName; - // TODO 카카오에서 email 선택 동의라 체크 안하고 가입하면 DB에서 터질듯 @Column(nullable = false, unique = true) private String email; diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java index f5323fe98..fae26595d 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java @@ -9,4 +9,6 @@ public interface MemberRepository extends JpaRepository { Optional findByOauthId(OauthId oauthId); + boolean existsByMemberInfoNickName(String nickName); + } diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberErrorCode.java b/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberErrorCode.java index c02d2ab15..361e51973 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberErrorCode.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberErrorCode.java @@ -10,6 +10,7 @@ public enum MemberErrorCode { ILLEGAL_EMAIL_NULL("05002", "이메일은 필수로 입력해야합니다."), ILLEGAL_EMAIL_PATTERN("05003", "올바르지 않은 이메일 형식입니다."), MEMBER_NOT_FOUND("05400", "존재하지 않는 회원입니다."), + ILLEGAL_NICKNAME_ALREADY_EXISTS("05900", "이미 존재하는 닉네임입니다."), ; private final String code; diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberException.java b/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberException.java index ec98e9d0f..9a603f8a2 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberException.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/exception/MemberException.java @@ -1,6 +1,7 @@ package com.mapbefine.mapbefine.member.exception; import com.mapbefine.mapbefine.common.exception.BadRequestException; +import com.mapbefine.mapbefine.common.exception.ConflictException; import com.mapbefine.mapbefine.common.exception.ErrorCode; import com.mapbefine.mapbefine.common.exception.NotFoundException; @@ -18,5 +19,11 @@ public MemberNotFoundException(MemberErrorCode errorCode, Long id) { } } + public static class MemberConflictException extends ConflictException { + public MemberConflictException(MemberErrorCode errorCode, String value) { + super(new ErrorCode<>(errorCode.getCode(), errorCode.getMessage(), value)); + } + } + } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java index e5e59fc3c..388a52b93 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/application/MemberCommandServiceTest.java @@ -9,9 +9,11 @@ import com.mapbefine.mapbefine.common.annotation.ServiceTest; import com.mapbefine.mapbefine.member.MemberFixture; import com.mapbefine.mapbefine.member.domain.Member; +import com.mapbefine.mapbefine.member.domain.MemberInfo; import com.mapbefine.mapbefine.member.domain.MemberRepository; import com.mapbefine.mapbefine.member.domain.Role; import com.mapbefine.mapbefine.member.dto.request.MemberUpdateRequest; +import com.mapbefine.mapbefine.member.exception.MemberException.MemberConflictException; import java.util.NoSuchElementException; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -72,4 +74,16 @@ void updateInfoById_FailByNotExistingMember() { .isInstanceOf(NoSuchElementException.class); } + @Test + @DisplayName("회원 정보 수정 시, 이미 존재하는 닉네임을 설정하면 예외가 발생한다.") + void updateInfoById_FailByDuplicatedNickName() { + // given + MemberInfo memberInfo = member.getMemberInfo(); + MemberUpdateRequest request = new MemberUpdateRequest(memberInfo.getNickName()); + + // when, then + assertThatThrownBy(() -> memberCommandService.updateInfoById(authMember, request)) + .isInstanceOf(MemberConflictException.class); + } + } From bec7adf5b58f74b5948d199a14ae60ab23c6e950 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 01:07:07 +0900 Subject: [PATCH 10/14] =?UTF-8?q?refactor:=20=ED=9A=8C=EC=9B=90=EC=9D=98?= =?UTF-8?q?=20=EC=9D=B4=EB=A9=94=EC=9D=BC=20Unique=20=EC=A0=9C=EC=95=BD?= =?UTF-8?q?=EC=A1=B0=EA=B1=B4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 닉네임, OauthId로 회원을 식별할 수 있다. - 같은 이메일로 네이버, 카카오에 가입한 사람이 소셜 로그인으로 두 계정을 만들 경우, 동일한 이메일이 저장될 수도 있다. --- .../java/com/mapbefine/mapbefine/member/domain/MemberInfo.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java index c27afa780..6f94e0000 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java @@ -28,7 +28,7 @@ public class MemberInfo { @Column(nullable = false, length = 20, unique = true) private String nickName; - @Column(nullable = false, unique = true) + @Column(nullable = false) private String email; @Column(nullable = false) From fc6ba2f32b020e124646593509a0e29fd2c5d664 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 01:11:41 +0900 Subject: [PATCH 11/14] =?UTF-8?q?refactor:=20=EB=AA=A8=ED=98=B8=ED=95=9C?= =?UTF-8?q?=20=EB=A9=94=EC=84=9C=EB=93=9C=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mapbefine/mapbefine/member/domain/Member.java | 4 ++-- .../com/mapbefine/mapbefine/member/domain/MemberInfo.java | 2 +- .../com/mapbefine/mapbefine/member/domain/MemberInfoTest.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java index 244499410..894fe2c7d 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/Member.java @@ -98,14 +98,14 @@ private static String createNickname(String nickname) { private static String createNicknameSuffix() { return randomUUID() .toString() - .replaceAll("-", "") + .replace("-", "") .substring(0, DEFAULT_NICKNAME_SUFFIX_LENGTH); } public void update( String nickName ) { - memberInfo = memberInfo.createForPatch(nickName); + memberInfo = memberInfo.createUpdatedMemberInfo(nickName); } public void addTopic(Topic topic) { diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java index 6f94e0000..fcabd9564 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberInfo.java @@ -93,7 +93,7 @@ private static void validateRole(Role role) { } } - public MemberInfo createForPatch(String nickName) { + public MemberInfo createUpdatedMemberInfo(String nickName) { return MemberInfo.of(nickName, this.email, this.imageUrl.getImageUrl(), this.role); } diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java index 07e7be319..7d97cf370 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/domain/MemberInfoTest.java @@ -45,7 +45,7 @@ void create_Success() { @Test @DisplayName("일부 정보(닉네임)만 변경한 회원 정보를 생성할 수 있다.") - void createForPatch() { + void createUpdatedMemberInfo() { // given MemberInfo before = MemberInfo.of( "member", @@ -55,7 +55,7 @@ void createForPatch() { // when String expected = "newNickName"; - MemberInfo patched = before.createForPatch(expected); + MemberInfo patched = before.createUpdatedMemberInfo(expected); // then assertSoftly(softly -> { From 31f1d06471639f033c826fb285de9e8888f94f0b Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 01:17:18 +0900 Subject: [PATCH 12/14] =?UTF-8?q?refactor:=20Email=EC=9D=B4=20Unique?= =?UTF-8?q?=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=8C=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20=ED=85=8C=EC=8A=A4=ED=8A=B8=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EB=8A=94=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EC=BF=BC=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - findByEmail 대신 findById - 기본키가 아닌 유일키로 조회하는 건 테이블 구조 변경 여지가 있으므로 findById 사용 --- .../mapbefine/mapbefine/member/domain/MemberRepository.java | 2 +- .../mapbefine/oauth/application/OauthServiceTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java index fae26595d..b6535afda 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/domain/MemberRepository.java @@ -5,7 +5,7 @@ public interface MemberRepository extends JpaRepository { - Optional findByMemberInfoEmail(String email); + Optional findById(Long id); Optional findByOauthId(OauthId oauthId); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/oauth/application/OauthServiceTest.java b/backend/src/test/java/com/mapbefine/mapbefine/oauth/application/OauthServiceTest.java index 2d5c71227..be752de19 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/oauth/application/OauthServiceTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/oauth/application/OauthServiceTest.java @@ -97,7 +97,7 @@ void getAuthCodeRequestUrl_success() { void loginAndRegister_success() { // when LoginInfoResponse response = oauthService.login(KAKAO, "auth"); - Member savedMember = memberRepository.findByMemberInfoEmail("yshert@naver.com") + Member savedMember = memberRepository.findById(response.member().id()) .orElseThrow(NoSuchElementException::new); // then @@ -114,7 +114,7 @@ void loginAndRegister_success() { void login() { // given LoginInfoResponse firstLogin = oauthService.login(KAKAO, "auth"); - Member savedMember = memberRepository.findByMemberInfoEmail(firstLogin.member().email()) + Member savedMember = memberRepository.findById(firstLogin.member().id()) .orElseThrow(NoSuchElementException::new); // when From 4232fe20115eac227a44df3d6182c3d7dfd9b89a Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 01:31:47 +0900 Subject: [PATCH 13/14] =?UTF-8?q?refactor:=20=EB=82=B4=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=88=98=EC=A0=95=20API=20URI=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapbefine/member/presentation/MemberController.java | 2 +- .../com/mapbefine/mapbefine/member/MemberIntegrationTest.java | 2 +- .../mapbefine/member/presentation/MemberControllerTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java b/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java index 2c379a794..a9e63c5e9 100644 --- a/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java +++ b/backend/src/main/java/com/mapbefine/mapbefine/member/presentation/MemberController.java @@ -79,7 +79,7 @@ public ResponseEntity> findAllTopicsInBookmark(AuthMember au } @LoginRequired - @PatchMapping("/my") + @PatchMapping("/my/profiles") public ResponseEntity updateMyInfo(AuthMember authMember, @RequestBody MemberUpdateRequest request) { memberCommandService.updateInfoById(authMember, request); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java index b4031f5ae..aaf288b23 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/MemberIntegrationTest.java @@ -185,7 +185,7 @@ void updateMemberInfo_Success() { .header(HttpHeaders.AUTHORIZATION, creatorAuthHeader) .contentType(MediaType.APPLICATION_JSON_VALUE) .body(new MemberUpdateRequest("new nickname")) - .when().patch("/members/my") + .when().patch("/members/my/profiles") .then().log().all() .extract(); diff --git a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java index 6454b67b1..df12531d6 100644 --- a/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java +++ b/backend/src/test/java/com/mapbefine/mapbefine/member/presentation/MemberControllerTest.java @@ -210,7 +210,7 @@ void updateMyInfo() throws Exception { MemberUpdateRequest request = new MemberUpdateRequest("새로운 닉네임"); mockMvc.perform( - MockMvcRequestBuilders.patch("/members/my") + MockMvcRequestBuilders.patch("/members/my/profiles") .header(AUTHORIZATION, testAuthHeaderProvider.createAuthHeaderById(1L)) .contentType(MediaType.APPLICATION_JSON) .content(objectMapper.writeValueAsString(request)) From 190255f41dae2e963fe4be7ff630109d13576803 Mon Sep 17 00:00:00 2001 From: yoondgu Date: Fri, 15 Sep 2023 03:15:09 +0900 Subject: [PATCH 14/14] =?UTF-8?q?fix:=20=EB=94=94=EB=A0=89=ED=84=B0?= =?UTF-8?q?=EB=A6=AC=20=EB=B6=84=EB=A6=AC=EC=97=90=20=EB=94=B0=EB=A5=B8=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=84=A4=EC=A0=95=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?appender=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/{logback => }/logback-spring.xml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) rename backend/src/main/resources/{logback => }/logback-spring.xml (71%) diff --git a/backend/src/main/resources/logback/logback-spring.xml b/backend/src/main/resources/logback-spring.xml similarity index 71% rename from backend/src/main/resources/logback/logback-spring.xml rename to backend/src/main/resources/logback-spring.xml index 4bbde1b2d..944c99dd5 100644 --- a/backend/src/main/resources/logback/logback-spring.xml +++ b/backend/src/main/resources/logback-spring.xml @@ -9,7 +9,7 @@ value="%green(%d{yyyy-MM-dd HH:mm:ss.SSS}) [%thread] ${PID} %highlight(%-5level) %cyan(%logger) - %msg%n"/> - + @@ -17,10 +17,10 @@ - - - - + + + + @@ -36,10 +36,10 @@ - - - - + + + +