From fc8493e3ca260d22c27c81338f99bbf69e02cc1e Mon Sep 17 00:00:00 2001 From: 70825 Date: Tue, 1 Aug 2023 13:24:05 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=8B=89=EB=84=A4=EC=9E=84?= =?UTF-8?q?=EA=B3=BC=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=A3=BC=EC=86=8C?= =?UTF-8?q?=EB=A5=BC=20=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/application/MemberService.java | 6 ++-- .../java/com/funeat/member/domain/Member.java | 5 +-- .../com/funeat/member/domain/MemberTest.java | 33 +++++++------------ 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/com/funeat/member/application/MemberService.java b/backend/src/main/java/com/funeat/member/application/MemberService.java index 6ac06698b..01b3f460f 100644 --- a/backend/src/main/java/com/funeat/member/application/MemberService.java +++ b/backend/src/main/java/com/funeat/member/application/MemberService.java @@ -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); } } diff --git a/backend/src/main/java/com/funeat/member/domain/Member.java b/backend/src/main/java/com/funeat/member/domain/Member.java index 87541d4c9..1f79b8ac8 100644 --- a/backend/src/main/java/com/funeat/member/domain/Member.java +++ b/backend/src/main/java/com/funeat/member/domain/Member.java @@ -78,11 +78,8 @@ public List 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; } } diff --git a/backend/src/test/java/com/funeat/member/domain/MemberTest.java b/backend/src/test/java/com/funeat/member/domain/MemberTest.java index 455b34dbc..327a17c4b 100644 --- a/backend/src/test/java/com/funeat/member/domain/MemberTest.java +++ b/backend/src/test/java/com/funeat/member/domain/MemberTest.java @@ -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; @@ -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); + }); } }