From 6a8de34c678fe01781cda3516d4f60d829772c0a Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Sun, 6 Jun 2021 00:39:15 +0200 Subject: [PATCH] refactor: extracted UpdateTimer method --- .../java/uulm/teamname/marvelous/server/lobby/Lobby.java | 6 +++--- .../uulm/teamname/marvelous/server/lobby/LobbyTest.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java index c8d0933..280e346 100644 --- a/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java +++ b/Server/src/main/java/uulm/teamname/marvelous/server/lobby/Lobby.java @@ -92,11 +92,11 @@ public class Lobby { badRequests = 0; } - updateTimer(game.state.getActiveCharacter().type); - + updateTimer(); } - void updateTimer(EntityType currentActiveCharacterType) { + void updateTimer() { + var currentActiveCharacterType = game.state.getActiveCharacter().type; if (pauseSegment.isPaused()) { turnTimer.clear(); } else if (currentActiveCharacterType == EntityType.P1) { diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java index ba9ce42..73eb330 100644 --- a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/LobbyTest.java @@ -35,13 +35,13 @@ class LobbyTest { }; var characterConfig = mock(CharacterConfig.class); - lobby = new Lobby( + lobby = spy(new Lobby( gameID, connection, partyConfig, characterConfig, scenarioConfig - ); + )); } @Test @@ -51,9 +51,10 @@ class LobbyTest { new RequestBuilder(RequestType.MoveRequest).buildGameRequest() }; var playerConnection = mock(WebSocket.class); + doNothing().when(lobby).updateTimer(); Participant playerOne = new Participant(playerConnection, ParticipantType.PlayerOne, "P1"); lobby.receiveRequests(requests, playerOne); } -} \ No newline at end of file +}