test: fixed LobbyConnection broadcastEvents test

This commit is contained in:
Yannik Bretschneider 2021-06-06 20:33:39 +02:00
parent 4ed6d23be6
commit a056674926

View File

@ -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);