From b8f6d516ee1eb35b583d0fae0a9b81b4f018faa5 Mon Sep 17 00:00:00 2001 From: swonny Date: Tue, 16 Apr 2024 14:31:15 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20MockitoJunitRunner=20=ED=99=9C=EC=84=B1?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ddang/websocket/handler/WebSocketHandlerTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/ddang/src/test/java/com/ddang/ddang/websocket/handler/WebSocketHandlerTest.java b/backend/ddang/src/test/java/com/ddang/ddang/websocket/handler/WebSocketHandlerTest.java index 40b7cca3e..bfd48fec1 100644 --- a/backend/ddang/src/test/java/com/ddang/ddang/websocket/handler/WebSocketHandlerTest.java +++ b/backend/ddang/src/test/java/com/ddang/ddang/websocket/handler/WebSocketHandlerTest.java @@ -1,5 +1,6 @@ package com.ddang.ddang.websocket.handler; +import com.ddang.ddang.chat.handler.ChatHandleTypeProviderComposite; import com.ddang.ddang.chat.handler.ChatWebSocketHandleTextMessageProvider; import com.ddang.ddang.configuration.IsolateDatabase; import com.ddang.ddang.websocket.handler.dto.SendMessageDto; @@ -9,9 +10,12 @@ import org.junit.jupiter.api.DisplayNameGeneration; import org.junit.jupiter.api.DisplayNameGenerator; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; @@ -23,6 +27,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; +@ExtendWith({MockitoExtension.class}) @IsolateDatabase @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) @SuppressWarnings("NonAsciiCharacters") @@ -34,6 +39,9 @@ class WebSocketHandlerTest extends WebSocketHandlerTestFixture { @MockBean WebSocketHandleTextMessageProviderComposite providerComposite; + @MockBean + ChatHandleTypeProviderComposite chatHandleTypeProviderComposite; + @Autowired WebSocketHandler webSocketHandler; @@ -64,7 +72,7 @@ class WebSocketHandlerTest extends WebSocketHandlerTestFixture { given(session.getAttributes()).willReturn(세션_attribute_정보); // when - webSocketHandler.afterConnectionClosed(session, null); + webSocketHandler.afterConnectionClosed(session, CloseStatus.NORMAL); // then verify(provider, times(1)).remove(any(WebSocketSession.class));