-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 회원의 기본정보(이름, 전화번호)수정 API 구현 및 테스트 코드 구현
- Loading branch information
Showing
8 changed files
with
74 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
backend/src/main/java/sw_css/member/application/dto/request/ChangePasswordRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/sw_css/member/application/dto/request/MemberChangeInfoRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package sw_css.member.application.dto.request; | ||
|
||
import jakarta.validation.constraints.Pattern; | ||
import sw_css.member.domain.embedded.PhoneNumber; | ||
import sw_css.member.domain.embedded.RealName; | ||
|
||
public record MemberChangeInfoRequest( | ||
@Pattern(regexp = RealName.NAME_REGEX, message = RealName.NAME_INVALID) | ||
String name, | ||
@Pattern(regexp = PhoneNumber.PHONE_NUMBER_REGEX, message = PhoneNumber.PHONE_NUMBER_INVALID) | ||
String phoneNumber) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import org.springframework.restdocs.request.PathParametersSnippet; | ||
import sw_css.member.api.MemberController; | ||
import sw_css.member.application.dto.request.ChangePasswordRequest; | ||
import sw_css.member.application.dto.request.MemberChangeInfoRequest; | ||
import sw_css.member.application.dto.response.StudentMemberResponse; | ||
import sw_css.member.domain.Member; | ||
import sw_css.restdocs.RestDocsTest; | ||
|
@@ -90,4 +91,30 @@ public void changePassword() throws Exception { | |
.andExpect(status().isNoContent()) | ||
.andDo(document("member-change-password", requestFields)); | ||
} | ||
|
||
@Test | ||
@DisplayName("[성공] 회원은 이름과 전화번호를 변경할 수 있다.") | ||
public void changeDefaultInfo() throws Exception { | ||
// given | ||
final RequestFieldsSnippet requestFields = requestFields( | ||
fieldWithPath("name").type(JsonFieldType.STRING).description("회원의 이름"), | ||
fieldWithPath("phoneNumber").type(JsonFieldType.STRING).description("회원의 전화번호") | ||
); | ||
|
||
final Member me = new Member(1L, "[email protected]", "ddang", "qwer1234!", "01012341234"); | ||
final String token = "Bearer AccessToken"; | ||
|
||
final MemberChangeInfoRequest request = new MemberChangeInfoRequest("이다은", "01031315656"); | ||
|
||
// when | ||
doNothing().when(memberCommandService).changePassword(me, request.name(), request.phoneNumber()); | ||
|
||
// then | ||
mockMvc.perform(RestDocumentationRequestBuilders.patch("/members/change-info") | ||
.contentType(APPLICATION_JSON) | ||
.content(objectMapper.writeValueAsString(request)) | ||
.header(HttpHeaders.AUTHORIZATION, token)) | ||
.andExpect(status().isNoContent()) | ||
.andDo(document("member-change-info", requestFields)); | ||
} | ||
} |