test: created test for TurnTimer
This commit is contained in:
		@ -33,6 +33,7 @@ public class Lobby {
 | 
			
		||||
            PartyConfig partyConfig,
 | 
			
		||||
            CharacterConfig characterConfig,
 | 
			
		||||
            ScenarioConfig scenarioConfig) {
 | 
			
		||||
 | 
			
		||||
        this.gameID = gameID;
 | 
			
		||||
        this.connection = connection;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,32 @@
 | 
			
		||||
package uulm.teamname.marvelous.server.lobby;
 | 
			
		||||
 | 
			
		||||
import org.java_websocket.WebSocket;
 | 
			
		||||
import org.junit.jupiter.api.BeforeEach;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
 | 
			
		||||
import uulm.teamname.marvelous.server.lobbymanager.LobbyConnection;
 | 
			
		||||
import uulm.teamname.marvelous.server.lobbymanager.Participant;
 | 
			
		||||
 | 
			
		||||
import java.util.function.Consumer;
 | 
			
		||||
 | 
			
		||||
import static org.junit.jupiter.api.Assertions.*;
 | 
			
		||||
import static org.assertj.core.api.Assertions.*;
 | 
			
		||||
import static org.mockito.Mockito.*;
 | 
			
		||||
 | 
			
		||||
class TurnTimerTest {
 | 
			
		||||
    TurnTimer turnTimer;
 | 
			
		||||
 | 
			
		||||
    @BeforeEach
 | 
			
		||||
    void beforeEach(){
 | 
			
		||||
        var callback = mock(Consumer.class);
 | 
			
		||||
        turnTimer = new TurnTimer(20, callback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Test
 | 
			
		||||
    void startTurnTimerTest(){
 | 
			
		||||
        var connection = mock(WebSocket.class);
 | 
			
		||||
        var participant = new Participant(connection, ParticipantType.Spectator, "spectator");
 | 
			
		||||
        assertThatIllegalStateException().describedAs("Spectators don't have TurnTime").isThrownBy(() -> turnTimer.startTurnTimer(participant));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@ -47,7 +47,7 @@ class PacketTest {
 | 
			
		||||
                new RequestBuilder(RequestType.Req).buildGameRequest(),
 | 
			
		||||
                new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
 | 
			
		||||
        };
 | 
			
		||||
        var participant = new Participant(null, ParticipantType.PlayerOne, "PlaerOne");
 | 
			
		||||
        var participant = new Participant(null, ParticipantType.PlayerOne, "PlayerOne");
 | 
			
		||||
        packet = new Packet(requests, participant);
 | 
			
		||||
 | 
			
		||||
        assertThat(packet.getOrigin()).isEqualTo(participant);
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user