Skip to content

Commit

Permalink
test: Follow, FollowCommandService 언팔로우 단위 테스트 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
kwj1270 committed Nov 25, 2021
1 parent 5df1d0d commit 8a73a1b
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -21,6 +23,7 @@
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.willReturn;

@DisplayName("팔로우 커멘드 서비스(FollowCommandService)")
@ExtendWith(MockitoExtension.class)
class FollowCommandServiceTest {

Expand Down Expand Up @@ -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()
);
}
}

0 comments on commit 8a73a1b

Please sign in to comment.