fixed some tests
This commit is contained in:
		@@ -27,6 +27,8 @@
 | 
			
		||||
import pp.mdga.server.automaton.game.turn.rolldice.ThirdRollState;
 | 
			
		||||
import pp.mdga.visitor.Visitor;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static org.junit.Assert.assertEquals;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -115,6 +117,8 @@ public class ServerStateTest {
 | 
			
		||||
    private TurnState turnState;
 | 
			
		||||
    private WaitingPieceState waitingPieceState;
 | 
			
		||||
 | 
			
		||||
    private SelectedPiecesMessage selectedPiecesMessage;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method is used to initialize the attributes of this test-class
 | 
			
		||||
@@ -124,7 +128,11 @@ public void setUp() {
 | 
			
		||||
        game = new Game();
 | 
			
		||||
        //initialize two players
 | 
			
		||||
        playerHost = new Player("Host");
 | 
			
		||||
        playerHost.addHandCard(new ShieldCard());
 | 
			
		||||
        PowerCard shield= new ShieldCard();
 | 
			
		||||
        selectCard = new SelectCardMessage(shield);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        playerHost.addHandCard(shield);
 | 
			
		||||
        playerHost.addHandCard(new SwapCard());
 | 
			
		||||
        playerHost.addHandCard(new TurboCard());
 | 
			
		||||
        playerHost.initialize();
 | 
			
		||||
@@ -140,6 +148,7 @@ public void setUp() {
 | 
			
		||||
        hostPiece1.setState(PieceState.ACTIVE);
 | 
			
		||||
        game.getBoard().setPieceOnBoard(35,hostPiece2);
 | 
			
		||||
        hostPiece2.setState(PieceState.ACTIVE);
 | 
			
		||||
        selectedPiecesMessage = new SelectedPiecesMessage(List.of(hostPiece2));
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -182,9 +191,6 @@ public void shutdown() {
 | 
			
		||||
            }
 | 
			
		||||
        }, game);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        game.setActiveColor(playerClientColor);
 | 
			
		||||
 | 
			
		||||
        //initialize a piece for client
 | 
			
		||||
        IDPiece = 3;
 | 
			
		||||
        pieceState = PieceState.ACTIVE;
 | 
			
		||||
@@ -264,6 +270,8 @@ public void accept(Visitor visitor) {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this test-method tests, that the server, when initialized, is in the Lobby-state
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest1
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testInitialStateServerState() {
 | 
			
		||||
@@ -274,6 +282,8 @@ public void testInitialStateServerState() {
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server, if all players are ready and the startGameMessage is issued,
 | 
			
		||||
     * changes into the DetermineStartPlayer-state
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest2
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testLobbyToDetermineStartPlayer() {
 | 
			
		||||
@@ -316,6 +326,8 @@ public void testLobbyToDetermineStartPlayer() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests, that the server stays in the Lobby
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest3
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testStayInLobby() {
 | 
			
		||||
@@ -344,6 +356,8 @@ public void testStayInLobby() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests, that the server can go into the interrupt-state
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest4
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testServerGameSubStatesToInterrupt() {
 | 
			
		||||
@@ -360,6 +374,8 @@ public void testServerGameSubStatesToInterrupt() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * tests the state-change IDPlayerClient Game to Ceremony if the Game is finished
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest5
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testServerGameToCeremony() {
 | 
			
		||||
@@ -375,6 +391,8 @@ public void testServerGameToCeremony() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server goes back to the Game, when the ForceStartGame-message is issued
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest6
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testInterruptToGameContinue() {
 | 
			
		||||
@@ -412,6 +430,8 @@ public void testInterruptToGameContinue() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests, that the server goes back to the game, if the missing client has reconnected
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest7
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testInterruptToGameReconnect() {
 | 
			
		||||
@@ -427,6 +447,8 @@ public void testInterruptToGameReconnect() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests, that th e server continues with the game, if there is no time left on the timer
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest8
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testInterruptToGameTimer() {
 | 
			
		||||
@@ -442,6 +464,8 @@ public void testInterruptToGameTimer() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests, that the server closes, if the ceremony has ended
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest9
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testCeremonyToServerStateEndState() {
 | 
			
		||||
@@ -525,6 +549,8 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server goes into Animation-state, if there is an order
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest12
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testDetermineStartPlayerToAnimation() {
 | 
			
		||||
@@ -558,6 +584,8 @@ public void testDetermineStartPlayerToAnimation() {
 | 
			
		||||
    /**
 | 
			
		||||
     * tests that the server goes IDPlayerClient the animation-state into PowerCardState, if the animation in the client has ended
 | 
			
		||||
     * and all players have issued a animationEndMessage
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest13
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testAnimationToPowerCard() {
 | 
			
		||||
@@ -587,6 +615,8 @@ public void testAnimationToPowerCard() {
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server changes it's state IDPlayerClient the turn-state to the animation-state, if there are at
 | 
			
		||||
     * least two player left
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest14
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testTurnToAnimation() {
 | 
			
		||||
@@ -624,6 +654,8 @@ public void testTurnToAnimation() {
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server changes it's state IDPlayerClient the turn-state to the ceremony-state,
 | 
			
		||||
     * if there is only one player left
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest15
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testTurnToGameEndState() {
 | 
			
		||||
@@ -644,6 +676,8 @@ public void testTurnToGameEndState() {
 | 
			
		||||
    /**
 | 
			
		||||
     * this method tests that the server don't change it's state whe issued with messages,
 | 
			
		||||
     * which don't implicate a statechange
 | 
			
		||||
     *
 | 
			
		||||
     * serverStateTest16
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testStayInPowerCard() {
 | 
			
		||||
@@ -660,17 +694,14 @@ public void testStayInPowerCard() {
 | 
			
		||||
        assertEquals(turnState.getCurrentState(), powerCardState);
 | 
			
		||||
 | 
			
		||||
        //receive messages which don't lead to a state change
 | 
			
		||||
        serverGameLogic.received(animationEnd, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(deselectTSK, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(forceContinueGame, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(joinServer, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(lobbyNotReady, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(lobbyReady, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(noPowerCard, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(requestBriefing, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(requestDie, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(requestMove, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(selectCard, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(selectTSK, IDPlayerClient);
 | 
			
		||||
        serverGameLogic.received(startGame, IDPlayerClient);
 | 
			
		||||
 | 
			
		||||
@@ -698,8 +729,12 @@ public void testPowerCardToPlayPowerCard() {
 | 
			
		||||
        turnState.setCurrentState(powerCardState);
 | 
			
		||||
        assertEquals(turnState.getCurrentState(), powerCardState);
 | 
			
		||||
 | 
			
		||||
        //todo
 | 
			
		||||
        serverGameLogic.received(selectCard, IDPlayerClient);
 | 
			
		||||
        //sends the server in shieldState
 | 
			
		||||
        powerCardState.setCurrentState(powerCardState.getShieldCardState());
 | 
			
		||||
        assertEquals(powerCardState.getCurrentState(), powerCardState.getShieldCardState());
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        serverGameLogic.received(selectedPiecesMessage, IDPlayerHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in PlayPowerCard
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
@@ -797,7 +832,7 @@ public void testMovePieceToTurnEndState() {
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testMovePieceToFirstRoll() {
 | 
			
		||||
        //sets the die to 6
 | 
			
		||||
        game.setDie(new Die(6));
 | 
			
		||||
        game.setDiceEyes(6);
 | 
			
		||||
 | 
			
		||||
        //sends the server in Game-State
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
@@ -831,6 +866,8 @@ public void testMovePieceToFirstRoll() {
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testFirstRollToRollDiceEndState() {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        //sends the server in Game-State
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
@@ -878,7 +915,11 @@ public void testFirstRollToSecondRoll() {
 | 
			
		||||
        rollDiceState.setCurrentState(firstRollState);
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), firstRollState);
 | 
			
		||||
 | 
			
		||||
        game.setDie(new Die(5));
 | 
			
		||||
        game.setDiceEyes(5);
 | 
			
		||||
        //Todo player has no figures to move and had no 6
 | 
			
		||||
        serverGameLogic.received(requestDie, IDPlayerHost);
 | 
			
		||||
        serverGameLogic.received(animationEnd, IDPlayerHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in the SecondRoll
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
@@ -893,7 +934,6 @@ public void testFirstRollToSecondRoll() {
 | 
			
		||||
     */
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testSecondRollToRollDiceEndState() {
 | 
			
		||||
        //sends the server in Game-State
 | 
			
		||||
        serverGameLogic.setCurrentState(gameState);
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
 | 
			
		||||
@@ -909,7 +949,7 @@ public void testSecondRollToRollDiceEndState() {
 | 
			
		||||
        rollDiceState.setCurrentState(secondRollState);
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), secondRollState);
 | 
			
		||||
 | 
			
		||||
        //Todo
 | 
			
		||||
        //TODO
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in NoPiece of ChoosePiece
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
@@ -940,7 +980,11 @@ public void testSecondRollToThirdRoll() {
 | 
			
		||||
        rollDiceState.setCurrentState(secondRollState);
 | 
			
		||||
        assertEquals(rollDiceState.getCurrentState(), secondRollState);
 | 
			
		||||
 | 
			
		||||
        //Todo player has no figures to move and had no 6
 | 
			
		||||
        game.setDie(new Die(5));
 | 
			
		||||
        game.setDiceEyes(5);
 | 
			
		||||
        //player has no figures to move and had no 6
 | 
			
		||||
        serverGameLogic.received(requestDie, IDPlayerHost);
 | 
			
		||||
        serverGameLogic.received(animationEnd, IDPlayerHost);
 | 
			
		||||
 | 
			
		||||
        //tests if the server is in the ThirdRoll
 | 
			
		||||
        assertEquals(serverGameLogic.getCurrentState(), gameState);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user