Skip to content

Commit

Permalink
test : 테스트 케이스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-1116 committed Jun 5, 2024
1 parent 67ab632 commit 8596989
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import java.util.Collections;
Expand All @@ -15,6 +16,7 @@
import org.junit.jupiter.api.Test;
import org.springframework.transaction.support.TransactionTemplate;
import site.timecapsulearchive.core.common.dependency.TestTransactionTemplate;
import site.timecapsulearchive.core.common.fixture.domain.MemberFixture;
import site.timecapsulearchive.core.common.fixture.dto.FriendInviteMemberIdsDtoFixture;
import site.timecapsulearchive.core.domain.friend.exception.FriendInviteDuplicateException;
import site.timecapsulearchive.core.domain.friend.exception.FriendInviteNotFoundException;
Expand Down Expand Up @@ -93,6 +95,25 @@ class FriendCommandServiceTest {
verify(transactionTemplate, never()).execute(any());
}

@Test
void 친구_요청을_보낸_경우_트랜잭션이_동작된다() {
//given
Long memberId = 1L;
List<Long> friendIds = List.of(2L, 3L, 4L, 5L, 6L);
List<Long> subFriendIds = friendIds.subList(0, 3);
given(friendInviteRepository.findFriendInviteMemberIdsDtoByMemberIdsAndFriendId(anyList(),
any()))
.willReturn(FriendInviteMemberIdsDtoFixture.twoWays(memberId, subFriendIds));
given(memberRepository.findMemberById(anyLong())).willReturn(
Optional.ofNullable(MemberFixture.memberWithMemberId(0L)));

//when
friendCommandService.requestFriends(memberId, friendIds);

//then
verify(transactionTemplate, times(1)).execute(any());
}

@Test
void 사용자_본인한테_단건_친구_요청을_보낸_경우_예외가_발생한다() {
//given
Expand Down

0 comments on commit 8596989

Please sign in to comment.