From 8a73a1b20ca3f18fe4c7cbddd7c479ff09116b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=B0=EC=9E=AC?= <kwj1270@naver.com> Date: Fri, 26 Nov 2021 03:48:15 +0900 Subject: [PATCH] =?UTF-8?q?test:=20Follow,=20FollowCommandService=20?= =?UTF-8?q?=EC=96=B8=ED=8C=94=EB=A1=9C=EC=9A=B0=20=EB=8B=A8=EC=9C=84=20?= =?UTF-8?q?=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/FollowCommandServiceTest.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/test/java/com/study/realworld/domain/follow/application/FollowCommandServiceTest.java b/src/test/java/com/study/realworld/domain/follow/application/FollowCommandServiceTest.java index ec242874..25f3b342 100644 --- a/src/test/java/com/study/realworld/domain/follow/application/FollowCommandServiceTest.java +++ b/src/test/java/com/study/realworld/domain/follow/application/FollowCommandServiceTest.java @@ -3,11 +3,13 @@ import com.study.realworld.domain.follow.domain.Follow; import com.study.realworld.domain.follow.domain.FollowRepository; import com.study.realworld.domain.follow.dto.FollowResponse; +import com.study.realworld.domain.follow.dto.UnFollowResponse; import com.study.realworld.domain.user.application.UserQueryService; import com.study.realworld.domain.user.domain.persist.User; import com.study.realworld.domain.user.domain.vo.UserBio; import com.study.realworld.domain.user.domain.vo.UserImage; import com.study.realworld.domain.user.domain.vo.UserName; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.InjectMocks; @@ -21,6 +23,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.BDDMockito.willReturn; +@DisplayName("팔로우 커멘드 서비스(FollowCommandService)") @ExtendWith(MockitoExtension.class) class FollowCommandServiceTest { @@ -54,4 +57,22 @@ class FollowCommandServiceTest { () -> assertThat(followResponse.isFollowing()).isTrue() ); } + + @Test + void 팔로워_아이덴티티와_팔로위_이름을_입력하면_언팔로우_할_수_있다() { + final User follower = testUser("user1@gmail.com", "user1", "password1", "bio1", "image1"); + final User followee = testUser("user2@gmail.com", "user2", "password2", "bio2", "image2"); + final Follow follow = testFollower(followee, follower); + willReturn(follower).given(userQueryService).findById(any()); + willReturn(followee).given(userQueryService).findByUserName(any()); + willReturn(follow).given(followQueryService).findByFolloweeAndFollower(any(), any()); + + final UnFollowResponse unFollowResponse = followCommandService.unfollow(1L, UserName.from("user2")); + assertAll( + () -> assertThat(unFollowResponse.userName()).isEqualTo(UserName.from("user2")), + () -> assertThat(unFollowResponse.userBio()).isEqualTo(UserBio.from("bio2")), + () -> assertThat(unFollowResponse.userImage()).isEqualTo(UserImage.from("image2")), + () -> assertThat(unFollowResponse.isFollowing()).isFalse() + ); + } }