Skip to content

Commit

Permalink
test: 콕 찌르기 여부를 확인하는 기능 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan committed Nov 7, 2023
1 parent 5aee8a9 commit 50e3b04
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.moabam.api.domain.entity.Participant;
import com.moabam.api.domain.repository.NotificationRepository;
import com.moabam.api.domain.repository.ParticipantSearchRepository;
import com.moabam.api.dto.KnockNotificationStatusResponse;
import com.moabam.global.common.annotation.MemberTest;
import com.moabam.global.error.exception.ConflictException;
import com.moabam.global.error.exception.NotFoundException;
Expand Down Expand Up @@ -134,4 +135,40 @@ void notificationService_sendCertificationTimeNotification_NoFirebaseMessaging(L
// Then
verify(firebaseMessaging, times(0)).sendAsync(any(Message.class));
}

@DisplayName("특정 방에서 나 이외의 모든 사용자를 콕 찔렀을 때, - KnockNotificationStatusResponse")
@MethodSource("com.moabam.support.fixture.ParticipantFixture#provideParticipants")
@ParameterizedTest
void notificationService_knocked_checkMyKnockNotificationStatusInRoom(List<Participant> participants) {
// Given
given(participantSearchRepository.findOtherParticipantsInRoom(any(Long.class), any(Long.class)))
.willReturn(participants);
given(notificationRepository.existsByKey(any(String.class))).willReturn(true);

// When
KnockNotificationStatusResponse actual =
notificationService.checkMyKnockNotificationStatusInRoom(memberTest, 1L);

// Then
assertThat(actual.knockedMembersId()).hasSize(3);
assertThat(actual.notKnockedMembersId()).isEmpty();
}

@DisplayName("특정 방에서 나 이외의 모든 사용자를 콕 안 찔렀을 때, - KnockNotificationStatusResponse")
@MethodSource("com.moabam.support.fixture.ParticipantFixture#provideParticipants")
@ParameterizedTest
void notificationService_notKnocked_checkMyKnockNotificationStatusInRoom(List<Participant> participants) {
// Given
given(participantSearchRepository.findOtherParticipantsInRoom(any(Long.class), any(Long.class)))
.willReturn(participants);
given(notificationRepository.existsByKey(any(String.class))).willReturn(false);

// When
KnockNotificationStatusResponse actual =
notificationService.checkMyKnockNotificationStatusInRoom(memberTest, 1L);

// Then
assertThat(actual.knockedMembersId()).isEmpty();
assertThat(actual.notKnockedMembersId()).hasSize(3);
}
}

0 comments on commit 50e3b04

Please sign in to comment.