Skip to content

Commit

Permalink
test: 채팅 데이터타입 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
swonny committed Apr 30, 2024
1 parent 27c573b commit 486e25d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Set;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willDoNothing;
Expand Down Expand Up @@ -173,6 +174,19 @@ class ChatWebSocketHandleTextMessageProviderTest extends ChatWebSocketHandleText
assertThat(actual).hasSize(1);
}

@Test
void 잘못된_데이터_타입_전달시_예외가_발생한다() throws JsonProcessingException {
// given
given(writerSession.getAttributes()).willReturn(발신자_세션_attribute_정보);
willDoNothing().given(sessions).add(writerSession, 채팅방.getId());
willReturn(false).given(sessions).containsByUserId(채팅방.getId(), 수신자.getId());
willReturn(Set.of(writerSession)).given(sessions).getSessionsByChatRoomId(채팅방.getId());

// when
assertThatThrownBy(() -> provider.handleCreateSendMessage(writerSession, 잘못된_메시지_전송_데이터))
.isInstanceOf(IllegalArgumentException.class);
}

@Test
void 세션을_삭제한다() {
// given
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class ChatWebSocketHandleTextMessageProviderTestFixture {
protected Map<String, Object> 발신자_세션_attribute_정보;
protected Map<String, Object> 수신자_세션_attribute_정보;
protected Map<String, String> 메시지_전송_데이터;
protected Map<String, String> 잘못된_메시지_전송_데이터;

protected CreateReadMessageLogEvent 메시지_로그_생성_이벤트;

Expand Down Expand Up @@ -93,6 +94,9 @@ void setUpFixture() {
"receiverId", String.valueOf(수신자.getId()),
"contents", "메시지 내용"
);
잘못된_메시지_전송_데이터 = Map.of(
"type", "wrong message type"
);

메시지_로그_생성_이벤트 = new CreateReadMessageLogEvent(채팅방);
}
Expand Down

0 comments on commit 486e25d

Please sign in to comment.