Skip to content

Commit

Permalink
refactor: 닉네임과 이미지 주소를 변경하는 메서드 로직 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
70825 committed Aug 1, 2023
1 parent 4058c6b commit fc8493e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ public void modify(final Long memberId, final MemberRequest request) {
final Member findMember = memberRepository.findById(memberId)
.orElseThrow(IllegalArgumentException::new);

findMember.modifyNickname(request.getNickname());
findMember.modifyProfileImage(request.getProfileImage());
final String nickname = request.getNickname();
final String profileImage = request.getProfileImage();

findMember.modifyProfile(nickname, profileImage);
}
}
5 changes: 1 addition & 4 deletions backend/src/main/java/com/funeat/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,8 @@ public List<RecipeBookmark> getRecipeBookmarks() {
return recipeBookmarks;
}

public void modifyNickname(final String nickname) {
public void modifyProfile(final String nickname, final String profileImage) {
this.nickname = nickname;
}

public void modifyProfileImage(final String profileImage) {
this.profileImage = profileImage;
}
}
33 changes: 12 additions & 21 deletions backend/src/test/java/com/funeat/member/domain/MemberTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.funeat.member.domain;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.SoftAssertions.assertSoftly;

import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
Expand All @@ -11,30 +11,21 @@
public class MemberTest {

@Test
void 사용자의_닉네임을_변경할__있다() {
void 사용자의_닉네임과_이미지_주소를_변경할__있다() {
// given
final var member = new Member("test", "http://www.test.com", "1");
final var expected = "hello";
final var member = new Member("before", "http://www.before.com", "1");
final var expectedNickname = "after";
final var expectedProfileImage = "http://www.after.com";

// when
member.modifyNickname(expected);
final var actual = member.getNickname();
member.modifyProfile(expectedNickname, expectedProfileImage);
final var actualNickname = member.getNickname();
final var actualProfileImage = member.getProfileImage();

// then
assertThat(actual).isEqualTo(expected);
}

@Test
void 사용자의_프로필_이미지_주소를_변경할__있다() {
// given
final var member = new Member("test", "http://www.test.com", "1");
final var expected = "http://www.hello.com";

// when
member.modifyProfileImage(expected);
final var actual = member.getProfileImage();

// then
assertThat(actual).isEqualTo(expected);
assertSoftly(softAssertions -> {
softAssertions.assertThat(actualNickname).isEqualTo(expectedNickname);
softAssertions.assertThat(actualProfileImage).isEqualTo(expectedProfileImage);
});
}
}

0 comments on commit fc8493e

Please sign in to comment.