test: fixed LobbyManagerTest to not run lobbies

This commit is contained in:
Yannik Bretschneider 2021-06-06 18:43:38 +02:00
parent 472a1e70ce
commit 8dab25ca8d
1 changed files with 20 additions and 0 deletions

View File

@ -1,9 +1,12 @@
package uulm.teamname.marvelous.server.lobbymanager;
import org.java_websocket.WebSocket;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import uulm.teamname.marvelous.gamelibrary.messages.BasicMessage;
import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
import uulm.teamname.marvelous.gamelibrary.messages.RoleEnum;
@ -33,6 +36,9 @@ class LobbyManagerTest {
Participant player2Participant;
Participant player3Participant;
LobbyRunner lobbyRunner;
MockedStatic<LobbyRunner> lobbyRunnerMockedStatic;
@BeforeEach
void beforeEach() {
@ -67,6 +73,17 @@ class LobbyManagerTest {
player3,
ParticipantType.PlayerOne,
"AwesomestAwesomePlayer");
lobbyRunner = spy(LobbyRunner.getInstance());
doNothing().when(lobbyRunner).startLobby(any(LobbyConnection.class));
lobbyRunnerMockedStatic = Mockito.mockStatic(LobbyRunner.class);
lobbyRunnerMockedStatic.when(LobbyRunner::getInstance).thenReturn(lobbyRunner);
}
@AfterEach
void afterEach() {
lobbyRunnerMockedStatic.close();
}
@Test
@ -77,6 +94,9 @@ class LobbyManagerTest {
@Test
@DisplayName("When a participant is added, a new Lobby is created")
void lobbyCreationTest() {
var message = new PlayerReadyMessage();
message.role = RoleEnum.PLAYER;