diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnectionTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnectionTest.java index 1016a6d..43ec130 100644 --- a/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnectionTest.java +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobbymanager/LobbyConnectionTest.java @@ -2,6 +2,8 @@ package uulm.teamname.marvelous.server.lobbymanager; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import org.mockito.ArgumentCaptor; +import org.mockito.MockedStatic; import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; import uulm.teamname.marvelous.gamelibrary.events.EventType; @@ -167,12 +169,15 @@ class LobbyConnectionTest { @Test void broadcastEventTest(){ - var webSock = mock(WebSocket.class); + var player1 = mock(WebSocket.class); + var player2 = mock(WebSocket.class); + var spectator1 = mock(WebSocket.class); + var spectator2 = mock(WebSocket.class); - Participant playerOne = new Participant(webSock, ParticipantType.PlayerOne, "playerOne"); - Participant playerTwo = new Participant(webSock, ParticipantType.PlayerTwo, "playerTwo"); - Participant spectatorOne = new Participant(webSock, ParticipantType.Spectator, "spectatorOne"); - Participant spectatorTwo = new Participant(webSock, ParticipantType.Spectator, "spectatorTwo"); + Participant playerOne = new Participant(player1, ParticipantType.PlayerOne, "playerOne"); + Participant playerTwo = new Participant(player2, ParticipantType.PlayerTwo, "playerTwo"); + Participant spectatorOne = new Participant(spectator1, ParticipantType.Spectator, "spectatorOne"); + Participant spectatorTwo = new Participant(spectator2, ParticipantType.Spectator, "spectatorTwo"); connection.addPlayer(playerOne); connection.addPlayer(playerTwo); @@ -187,8 +192,9 @@ class LobbyConnectionTest { var message = new EventMessage(); message.messages = events; - //TODO: fix them connection.broadcastEvents(events); + + verify(sendMessageCallback).accept(playerOne.getConnection(), message); verify(sendMessageCallback).accept(playerTwo.getConnection(), message); verify(sendMessageCallback).accept(spectatorOne.getConnection(), message);