Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

내 비밀번호 변경 API 구현 #94

Merged
merged 5 commits into from
Mar 27, 2024
Merged

Conversation

tinon1004
Copy link
Contributor

🔥 Related Issue

🏃‍ Task

  • 내 비밀번호 변경 API 구현

📄 Reference

  • None

@tinon1004 tinon1004 self-assigned this Mar 26, 2024
@tinon1004 tinon1004 added the enhancement New feature or request label Mar 26, 2024
Comment on lines 112 to 115
public void changePassword(String password) {
this.password = password;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 어떨까요?

Suggested change
public void changePassword(String password) {
this.password = password;
}
public void changePassword(String encodedPassword) {
this.password = encodedPassword;
}

Comment on lines 167 to 168
UserDto userUpdated = userCommandService.updatePassword(userPrincipal.getUserId(),
updatePasswordRequest.getPassword());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

요거 줄 정리 좀 해주시면 이쁠 거 같아요? 아니면 말구요 ㅎ;

Suggested change
UserDto userUpdated = userCommandService.updatePassword(userPrincipal.getUserId(),
updatePasswordRequest.getPassword());
UserDto userUpdated = userCommandService.updatePassword(
userPrincipal.getUserId(),
updatePasswordRequest.getPassword()
);

@tinon1004 tinon1004 requested a review from Wo-ogie March 26, 2024 16:43
Comment on lines 261 to 276
@Test
void 주어진_유저_ID와_새로운_비밀번호로_유저의_비밀번호를_변경한다_존재하지_않는_유저라면_예외가_발생한다() throws Exception {
// given
Long userId = 1L;
String newPassword = "newPwd1234!!";
given(userQueryService.getById(userId)).willThrow(UserNotFoundByIdException.class);

// when
Throwable t = catchThrowable(() -> sut.updatePassword(userId, newPassword));

// then
then(userQueryService).should().getById(userId);
verifyEveryMocksShouldHaveNoMoreInteractions();
assertThat(t).isInstanceOf(UserNotFoundByIdException.class);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 아까 리뷰했던거랑 비슷한데요.
경우에 따라 조금씩 다를 수는 있는데 unit test에서 중점적인 것들 중 하나는 "테스트 대상의 역할만을 검증"하는 거라고 생각해요.
지금 이 케이스 같은 경우, 유저를 조회했는데 없는 경우 에러를 발생시키는 건 getById method의 책임이자 역할이라고 보기 때문에 굳이? 작성 안해도 되지 않나 싶습니다.

@Wo-ogie Wo-ogie merged commit ba748bc into main Mar 27, 2024
1 check passed
@Wo-ogie Wo-ogie deleted the feature/#24-edit-password branch March 27, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Development

Successfully merging this pull request may close these issues.

비밀번호 변경 API 구현
2 participants