edited some tests in ServerStateTest
This commit is contained in:
@@ -5,10 +5,13 @@
|
|||||||
import pp.mdga.client.*;
|
import pp.mdga.client.*;
|
||||||
import pp.mdga.client.Ceremony;
|
import pp.mdga.client.Ceremony;
|
||||||
import pp.mdga.client.StartPiece;
|
import pp.mdga.client.StartPiece;
|
||||||
|
import pp.mdga.game.BonusCard;
|
||||||
|
import pp.mdga.game.Color;
|
||||||
import pp.mdga.game.Game;
|
import pp.mdga.game.Game;
|
||||||
|
import pp.mdga.message.client.ClientMessage;
|
||||||
import pp.mdga.message.server.*;
|
import pp.mdga.message.server.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
@@ -79,59 +82,88 @@ public class ClientStateTest {
|
|||||||
private MoveMessage moveMessage;
|
private MoveMessage moveMessage;
|
||||||
private NoTurn noTurn;
|
private NoTurn noTurn;
|
||||||
private PauseGame pauseGame;
|
private PauseGame pauseGame;
|
||||||
private PlayCard playCard;
|
|
||||||
private PossibleCard possibleCard;
|
private PossibleCard possibleCard;
|
||||||
private PossiblePiece possiblePiece;
|
private PossiblePiece possiblePiece;
|
||||||
private RankingResponse rankingResponce;
|
private RankingResponse rankingResponce;
|
||||||
private RankingRollAgain rankingRollAgain;
|
private RankingRollAgain rankingRollAgain;
|
||||||
private ReconnectBriefing reconnectBriefing;
|
private ReconnectBriefing reconnectBriefing;
|
||||||
private ResumeGame resumeGame;
|
private ResumeGame resumeGame;
|
||||||
|
private ServerStartGame startGame;
|
||||||
private StartPiece startPieceMessage;
|
private StartPiece startPieceMessage;
|
||||||
private UpdateReady updateReady;
|
private UpdateReady updateReady;
|
||||||
private UpdateTSK updateTSK;
|
private UpdateTSK updateTSK;
|
||||||
private WaitPiece waitPiece;
|
private WaitPiece waitPiece;
|
||||||
|
|
||||||
|
private PlayCard playCardSwap;
|
||||||
|
private PlayCard playCardShield;
|
||||||
|
private PlayCard playCardTurbo;
|
||||||
|
|
||||||
|
private int from;
|
||||||
|
private String name;
|
||||||
|
private Color color;
|
||||||
|
private BonusCard swapCard;
|
||||||
|
private BonusCard shieldCard;
|
||||||
|
private BonusCard turboCard;
|
||||||
|
|
||||||
|
private Game game;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
// This method will be executed before each test.
|
//initialize the game
|
||||||
// Initialize common objects or setup required state for Client State transitions.
|
game = new Game();
|
||||||
|
|
||||||
|
//initialize the playerID
|
||||||
|
from=1234;
|
||||||
|
name="Daniel";
|
||||||
|
color=Color.ARMY;
|
||||||
|
swapCard = BonusCard.SWAP;
|
||||||
|
shieldCard = BonusCard.SHIELD;
|
||||||
|
turboCard = BonusCard.TURBO;
|
||||||
|
|
||||||
//initialize the messages from the server
|
//initialize the messages from the server
|
||||||
activePlayer = new ActivePlayer();
|
activePlayer = new ActivePlayer(color);
|
||||||
anyPiece = new AnyPiece();
|
anyPiece = new AnyPiece();
|
||||||
briefing = new Briefing();
|
briefing = new Briefing();
|
||||||
ceremonyMessage = new CeremonyMessage();
|
ceremonyMessage = new CeremonyMessage();
|
||||||
dice = new Dice();
|
dice = new Dice(6,new ArrayList<>());
|
||||||
diceAgain = new DiceAgain();
|
diceAgain = new DiceAgain();
|
||||||
diceNow = new DiceNow();
|
diceNow = new DiceNow();
|
||||||
endOfTurn = new EndOfTurn();
|
endOfTurn = new EndOfTurn();
|
||||||
lobbyAccept = new LobbyAccept();
|
lobbyAccept = new LobbyAccept();
|
||||||
lobbyDeny = new LobbyDeny();
|
lobbyDeny = new LobbyDeny();
|
||||||
lobbyPlayerJoin = new LobbyPlayerJoin();
|
lobbyPlayerJoin = new LobbyPlayerJoin(name);
|
||||||
lobbyPlayerLeave = new LobbyPlayerLeave();
|
lobbyPlayerLeave = new LobbyPlayerLeave(name,color);
|
||||||
moveMessage = new MoveMessage();
|
moveMessage = new MoveMessage();
|
||||||
noTurn = new NoTurn();
|
noTurn = new NoTurn();
|
||||||
pauseGame = new PauseGame();
|
pauseGame = new PauseGame();
|
||||||
playCard = new PlayCard();
|
playCardSwap = new PlayCard(swapCard);
|
||||||
|
playCardShield = new PlayCard(shieldCard);
|
||||||
|
playCardTurbo = new PlayCard(turboCard);
|
||||||
possibleCard = new PossibleCard();
|
possibleCard = new PossibleCard();
|
||||||
possiblePiece = new PossiblePiece();
|
possiblePiece = new PossiblePiece();
|
||||||
rankingResponce = new RankingResponse();
|
rankingResponce = new RankingResponse();
|
||||||
rankingRollAgain = new RankingRollAgain();
|
rankingRollAgain = new RankingRollAgain();
|
||||||
reconnectBriefing = new ReconnectBriefing();
|
reconnectBriefing = new ReconnectBriefing(game);
|
||||||
resumeGame = new ResumeGame();
|
resumeGame = new ResumeGame();
|
||||||
|
startGame = new ServerStartGame();
|
||||||
startPieceMessage = new StartPiece();
|
startPieceMessage = new StartPiece();
|
||||||
updateReady = new UpdateReady();
|
updateReady = new UpdateReady();
|
||||||
updateTSK = new UpdateTSK();
|
updateTSK = new UpdateTSK();
|
||||||
waitPiece = new WaitPiece();
|
waitPiece = new WaitPiece();
|
||||||
|
|
||||||
//initialize the clientGameLogic
|
//initialize the clientGameLogic
|
||||||
clientGameLogic = new ClientGameLogic();
|
clientGameLogic = new ClientGameLogic(game, new ClientSender() {
|
||||||
|
@Override
|
||||||
|
public void send(ClientMessage msg) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
clientAutomaton = (ClientAutomaton) clientGameLogic.getState();
|
clientAutomaton = (ClientAutomaton) clientGameLogic.getState();
|
||||||
|
|
||||||
//initialize the settings
|
//initialize the settings
|
||||||
mainSettings = new MainSettings();
|
mainSettings = new MainSettings(settingsStateMachine,clientGameLogic);
|
||||||
videoSettings = new VideoSettings();
|
videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic);
|
||||||
audioSettings = new AudioSettings();
|
audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic);
|
||||||
settings = new Settings();
|
settings = new Settings();
|
||||||
|
|
||||||
|
|
||||||
@@ -535,7 +567,7 @@ public void testLobbyToRollRankingDice() {
|
|||||||
//sends the clientStatemachine in Lobby
|
//sends the clientStatemachine in Lobby
|
||||||
assertTrue(clientAutomaton.getState() instanceof Dialogs);
|
assertTrue(clientAutomaton.getState() instanceof Dialogs);
|
||||||
Dialogs dialogs1 = (Dialogs) clientAutomaton.getState();
|
Dialogs dialogs1 = (Dialogs) clientAutomaton.getState();
|
||||||
DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine();
|
DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine();
|
||||||
dialogsStateMachine1.gotoState(lobby);
|
dialogsStateMachine1.gotoState(lobby);
|
||||||
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
|
assertTrue(dialogsStateMachine1.getState() instanceof Lobby);
|
||||||
|
|
||||||
@@ -547,7 +579,7 @@ public void testLobbyToRollRankingDice() {
|
|||||||
|
|
||||||
//tests if the clientStateMachine is in the DetermineStartPlayer
|
//tests if the clientStateMachine is in the DetermineStartPlayer
|
||||||
GameState gameState1 = (GameState) clientAutomaton.getState();
|
GameState gameState1 = (GameState) clientAutomaton.getState();
|
||||||
GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine();
|
GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine();
|
||||||
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
|
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
|
||||||
|
|
||||||
//tests if the clientStateMachine is in the RollRankingDice
|
//tests if the clientStateMachine is in the RollRankingDice
|
||||||
|
|||||||
@@ -51,7 +51,6 @@
|
|||||||
import pp.mdga.server.TurnStateMachine;
|
import pp.mdga.server.TurnStateMachine;
|
||||||
import pp.mdga.server.WaitingPiece;
|
import pp.mdga.server.WaitingPiece;
|
||||||
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
@@ -79,7 +78,9 @@ public class ServerStateTest {
|
|||||||
private SelectedPieces selectedPieces;
|
private SelectedPieces selectedPieces;
|
||||||
private SelectTSK selectTSK;
|
private SelectTSK selectTSK;
|
||||||
private ClientMessage[] clientMessages;
|
private ClientMessage[] clientMessages;
|
||||||
|
|
||||||
private int from;
|
private int from;
|
||||||
|
private int fromHost;
|
||||||
|
|
||||||
private GameStateMachine gameStateMachine;
|
private GameStateMachine gameStateMachine;
|
||||||
private TurnStateMachine turnStateMachine;
|
private TurnStateMachine turnStateMachine;
|
||||||
@@ -152,74 +153,69 @@ public void send(int id, ServerMessage msg) {
|
|||||||
selectedPieces,
|
selectedPieces,
|
||||||
selectTSK
|
selectTSK
|
||||||
};
|
};
|
||||||
from=1234;
|
from = 1234;
|
||||||
|
fromHost = 2345;
|
||||||
|
|
||||||
choosePieceStateMachine = choosePiece.getChoosePieceMachine();
|
choosePieceStateMachine = choosePiece.getChoosePieceMachine();
|
||||||
rollDiceMachine = rollDice.getRollDicemachine();
|
rollDiceMachine = rollDice.getRollDicemachine();
|
||||||
turnStateMachine = turn.getTurnStatemachine();
|
turnStateMachine = turn.getTurnStatemachine();
|
||||||
serverAutomaton = new ServerAutomaton(logic);
|
serverAutomaton = logic.getServerAutomaton();
|
||||||
gameStateMachine = gameState.getGameStatemachine();
|
gameStateMachine = gameState.getGameStatemachine();
|
||||||
|
|
||||||
thirdRoll = new ThirdRoll(rollDiceMachine,logic);
|
thirdRoll = new ThirdRoll(rollDiceMachine, logic);
|
||||||
secondRoll = new SecondRoll(rollDiceMachine,logic);
|
secondRoll = new SecondRoll(rollDiceMachine, logic);
|
||||||
firstRoll = new FirstRoll(rollDiceMachine,logic);
|
firstRoll = new FirstRoll(rollDiceMachine, logic);
|
||||||
|
|
||||||
noPiece = new NoPiece(choosePieceStateMachine,logic);
|
noPiece = new NoPiece(choosePieceStateMachine, logic);
|
||||||
noTurn = new NoTurn(choosePieceStateMachine,logic);
|
noTurn = new NoTurn(choosePieceStateMachine, logic);
|
||||||
waitingPiece = new WaitingPiece(choosePieceStateMachine,logic);
|
waitingPiece = new WaitingPiece(choosePieceStateMachine, logic);
|
||||||
startPiece = new StartPiece(choosePieceStateMachine,logic);
|
startPiece = new StartPiece(choosePieceStateMachine, logic);
|
||||||
selectPiece = new SelectPiece(choosePieceStateMachine,logic);
|
selectPiece = new SelectPiece(choosePieceStateMachine, logic);
|
||||||
|
|
||||||
powerCard = new PowerCard(turnStateMachine,logic);
|
powerCard = new PowerCard(turnStateMachine, logic);
|
||||||
playPowerCard = new PlayPowerCard(turnStateMachine,logic);
|
playPowerCard = new PlayPowerCard(turnStateMachine, logic);
|
||||||
rollDice = new RollDice(turnStateMachine,logic);
|
rollDice = new RollDice(turnStateMachine, logic);
|
||||||
choosePiece = new ChoosePiece(turnStateMachine,logic);
|
choosePiece = new ChoosePiece(turnStateMachine, logic);
|
||||||
movePiece = new MovePiece(turnStateMachine,logic);
|
movePiece = new MovePiece(turnStateMachine, logic);
|
||||||
|
|
||||||
determineStartPlayer = new DetermineStartPlayer(gameStateMachine,logic);
|
determineStartPlayer = new DetermineStartPlayer(gameStateMachine, logic);
|
||||||
turn = new Turn(gameStateMachine,logic);
|
turn = new Turn(gameStateMachine, logic);
|
||||||
animation = new Animation(gameStateMachine,logic);
|
animation = new Animation(gameStateMachine, logic);
|
||||||
|
|
||||||
lobby = new Lobby(serverAutomaton,logic);
|
lobby = new Lobby(serverAutomaton, logic);
|
||||||
gameState = new GameState(serverAutomaton,logic);
|
gameState = new GameState(serverAutomaton, logic);
|
||||||
ceremony = new Ceremony(serverAutomaton,logic);
|
ceremony = new Ceremony(serverAutomaton, logic);
|
||||||
interrupt = new Interrupt(serverAutomaton,logic,gameState);
|
interrupt = new Interrupt(serverAutomaton, logic, gameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInitialStateServerState() {
|
public void testInitialStateServerState() {
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLobbyToDetermineStartPlayer() {
|
public void testLobbyToDetermineStartPlayer() {
|
||||||
//tests if Server is in State Lobby
|
//sends the server in the lobby-state
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
serverAutomaton.gotoState(lobby);
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||||
Lobby lobby = (Lobby) automaton.getState();
|
|
||||||
//tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby
|
//sends the startGame message from the Host to the server
|
||||||
//TODO set one player not ready
|
logic.received(clientStartGame, from);
|
||||||
lobby.receivedStartGame(clientStartGame, from);
|
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
//tests if the server iss in DSP-state
|
||||||
//tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
//TODO set all player Ready
|
GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state
|
||||||
lobby.receivedStartGame(clientStartGame, from);
|
GameStateMachine gameStateMachine1 = gameState.getGameStateMachine();
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer);
|
||||||
GameState gameState = (GameState) automaton.getState();
|
|
||||||
assertTrue(gameState.getState() instanceof DetermineStartPlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStayInLobby() {
|
public void testStayInLobby() {
|
||||||
//tests if Server is in State Lobby
|
//sends the server in the lobby-state
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
serverAutomaton.gotoState(lobby);
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||||
|
|
||||||
//lobby gets all possible messages
|
//TODO logic gets all messages
|
||||||
Lobby lobby = (Lobby) automaton.getState();
|
|
||||||
|
|
||||||
//logic gets all messages
|
|
||||||
logic.received(animationEnd, from);
|
logic.received(animationEnd, from);
|
||||||
logic.received(clientStartGame, from);
|
logic.received(clientStartGame, from);
|
||||||
logic.received(deselectTSK, from);
|
logic.received(deselectTSK, from);
|
||||||
@@ -238,135 +234,209 @@ public void testStayInLobby() {
|
|||||||
logic.received(selectTSK, from);
|
logic.received(selectTSK, from);
|
||||||
|
|
||||||
//tests if Server is still in Lobby
|
//tests if Server is still in Lobby
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
assertTrue(serverAutomaton.getState() instanceof Lobby);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testServerGameSubStatesToInterrupt() {
|
public void testServerGameSubStatesToInterrupt() {
|
||||||
// TODO: Implement test logic for transition from Server Game Sub-States to Interrupt
|
//sends the server in the gameState
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState); //TODO könnte auch auf gleichheit prüfen
|
||||||
|
|
||||||
|
//TODO create interrupt
|
||||||
|
|
||||||
|
//tests if the server is in the Interrupt-state
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tests the state-change from Game to Ceremony if the Game is finished
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testServerGameToCeremony() {
|
public void testServerGameToCeremony() {
|
||||||
// TODO: Implement test logic for transition from Server Game to Ceremony
|
//sends the server in the gameState
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
serverAutomaton.gotoState(gameState);
|
||||||
assertTrue(automaton.getState() instanceof Lobby);
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
Lobby lobby = (Lobby) automaton.getState();
|
|
||||||
//Todo set all players ready
|
|
||||||
logic.received(clientStartGame, from);
|
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
|
||||||
//Todo game is finished
|
//Todo game is finished
|
||||||
assertTrue(automaton.getState() instanceof Ceremony);
|
|
||||||
|
//tests if the server is in the Ceremony-state
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof Ceremony);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterruptToGameContinue() {
|
public void testInterruptToGameContinue() {
|
||||||
//sends the server into the interrupt
|
//sends the server in the Interrupt-State
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
serverAutomaton.gotoState(interrupt);
|
||||||
automaton.gotoState(interrupt);
|
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||||
assertTrue(automaton.getState() instanceof Interrupt);
|
|
||||||
//sends the continue-message to the server
|
//sends the continue-message to the server
|
||||||
logic.received(forceContinueGame, from);
|
logic.received(forceContinueGame, from);
|
||||||
|
|
||||||
//tests if new Stet is in GameState
|
//tests if new Stet is in GameState
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterruptToGameReconnect() {
|
public void testInterruptToGameReconnect() {
|
||||||
// TODO: Implement test logic for transition from Interrupt to Game Reconnect
|
//sends the server in the Interrupt-State
|
||||||
|
serverAutomaton.gotoState(interrupt);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||||
|
|
||||||
|
//todo implement the timer
|
||||||
|
|
||||||
|
//tests if new Stet is in GameState
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testInterruptToGameTimer() {
|
public void testInterruptToGameTimer() {
|
||||||
// TODO: Implement test logic for transition from Interrupt to Game Timer
|
//sends the server in the Interrupt-State
|
||||||
|
serverAutomaton.gotoState(interrupt);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof Interrupt);
|
||||||
|
|
||||||
|
//Todo implement the timer
|
||||||
|
|
||||||
|
//tests if new Stet is in GameState
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCeremonyToServerStateEndState() {
|
public void testCeremonyToServerStateEndState() {
|
||||||
// TODO: Implement test logic for transition from Ceremony to Server State End State
|
// TODO: Implement test logic for transition from Ceremony to Server State End State
|
||||||
|
// TODO how????
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetermineStartPlayerToDetermineStartPlayer1() {
|
public void testDetermineStartPlayerToDetermineStartPlayer1() {
|
||||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 1)
|
//sends the server in Game-State
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
serverAutomaton.gotoState(gameState);
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
GameState gameState = (GameState) automaton.getState();
|
|
||||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
//sends the gameStateMachine in DSP-state
|
||||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
gameStateMachine.gotoState(determineStartPlayer);
|
||||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||||
|
|
||||||
logic.received(requestDice, from);
|
//TODO sends messages to the server
|
||||||
|
|
||||||
assertTrue(automaton.getState() instanceof DetermineStartPlayer);
|
|
||||||
|
|
||||||
|
//tests if the server is still in DSP-state
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetermineStartPlayerToDetermineStartPlayer2() {
|
public void testDetermineStartPlayerToDetermineStartPlayer2() {
|
||||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 2)
|
//sends the server in Game-State
|
||||||
// sends the server in determineStartPlayer
|
serverAutomaton.gotoState(gameState);
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
|
||||||
GameState gameState = (GameState) automaton.getState();
|
//sends the gameStateMachine in DSP-state
|
||||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
gameStateMachine.gotoState(determineStartPlayer);
|
||||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||||
|
|
||||||
|
//TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server
|
||||||
|
|
||||||
|
//tests if the server is still in DSP-state
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||||
//Todo: input same dices for both players
|
|
||||||
logic.received(requestDice, from);
|
|
||||||
logic.received(requestDice, 1235);
|
|
||||||
assertTrue(automaton.getState() instanceof DetermineStartPlayer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDetermineStartPlayerToAnimation() {
|
public void testDetermineStartPlayerToAnimation() {
|
||||||
// Implement test logic for Determine Start Player to Determine Start Player (Variant 2)
|
//sends the server in Game-State
|
||||||
// sends the server in determineStartPlayer
|
serverAutomaton.gotoState(gameState);
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
|
||||||
GameState gameState = (GameState) automaton.getState();
|
//sends the gameStateMachine in DSP-state
|
||||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
gameStateMachine.gotoState(determineStartPlayer);
|
||||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
|
||||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
||||||
//Todo: input different dices for both players
|
|
||||||
logic.received(requestDice, from);
|
//TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht
|
||||||
logic.received(requestDice, 1235);
|
|
||||||
assertTrue(automaton.getState() instanceof Animation);
|
//tests if the Server is in animationState
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAnimationToPowerCard() {
|
public void testAnimationToPowerCard() {
|
||||||
ServerAutomaton automaton = (ServerAutomaton) logic.getState();
|
//sends the server in Game-State
|
||||||
assertTrue(automaton.getState() instanceof GameState);
|
serverAutomaton.gotoState(gameState);
|
||||||
GameState gameState = (GameState) automaton.getState();
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
assertTrue(gameState.getState() instanceof GameStateMachine);
|
|
||||||
GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState();
|
//sends the gameStateMachine in Animation
|
||||||
assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer);
|
gameStateMachine.gotoState(animation);
|
||||||
//Todo: input different dices for both players
|
|
||||||
logic.received(requestDice, from);
|
|
||||||
logic.received(requestDice, 1235);
|
|
||||||
assertTrue(automaton.getState() instanceof Animation);
|
|
||||||
logic.received(animationEnd, from);
|
|
||||||
assertTrue(gameStateMachine.getState() instanceof Animation);
|
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||||
logic.received(animationEnd, 1235);
|
|
||||||
|
//receives one animation endMessage and tests if the server is still in the Animation-state
|
||||||
|
logic.received(animationEnd, fromHost);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||||
|
|
||||||
|
//receives another animation endMessage
|
||||||
|
logic.received(animationEnd, from);
|
||||||
|
|
||||||
|
//tests if the server is in the PowerCard-state
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
assertTrue(gameStateMachine.getState() instanceof Turn);
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState();
|
Turn turn1 = (Turn) gameStateMachine.getState();
|
||||||
|
TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine();
|
||||||
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTurnToAnimation() {
|
public void testTurnToAnimation() {
|
||||||
// TODO: Implement test logic for transition from Turn to Animation
|
//sends the server in Game-State
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
|
||||||
|
//sends the gameStateMachine in Turn
|
||||||
|
gameStateMachine.gotoState(turn);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
|
||||||
|
//todo set the turn finished and there are still two players left
|
||||||
|
|
||||||
|
//tests if the server is in the AnimationState
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Animation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTurnToGameEndState() {
|
public void testTurnToGameEndState() {
|
||||||
// TODO: Implement test logic for transition from Turn to Game End State
|
//sends the server in Game-State
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
|
||||||
|
//sends the gameStateMachine in Turn
|
||||||
|
gameStateMachine.gotoState(turn);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
|
||||||
|
//todo set the turn finished and there is only one players left
|
||||||
|
|
||||||
|
//tests if the server is in the end-state of game, Ceremony
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof Ceremony);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStayInPowerCard() {
|
public void testStayInPowerCard() {
|
||||||
// TODO: Implement test logic for staying in Power Card state
|
//sends the server in Game-State
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
|
||||||
|
//sends the gameStateMachine in Turn
|
||||||
|
gameStateMachine.gotoState(turn);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
|
||||||
|
//sends the TurnStateMachine in PowerCard
|
||||||
|
turnStateMachine.gotoState(powerCard);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||||
|
|
||||||
|
//Todo: receive messages which dont lead to a state change
|
||||||
|
|
||||||
|
//tests if the server is in PowerCard
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -375,7 +445,24 @@ public void testStayInPowerCard() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testPowerCardToPlayPowerCard() {
|
public void testPowerCardToPlayPowerCard() {
|
||||||
// UC-ServerState-17
|
//sends the server in Game-State
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
|
||||||
|
//sends the gameStateMachine in Turn
|
||||||
|
gameStateMachine.gotoState(turn);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
|
||||||
|
//sends the TurnStateMachine in PowerCard
|
||||||
|
turnStateMachine.gotoState(powerCard);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PowerCard);
|
||||||
|
|
||||||
|
//todo
|
||||||
|
|
||||||
|
//tests if the server is in PlayPowerCard
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -384,7 +471,34 @@ public void testPowerCardToPlayPowerCard() {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testPlayPowerCardToRollDice() {
|
public void testPlayPowerCardToRollDice() {
|
||||||
// UC-ServerState-18
|
//sends the server in Game-State
|
||||||
|
serverAutomaton.gotoState(gameState);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
|
||||||
|
//sends the gameStateMachine in Turn
|
||||||
|
gameStateMachine.gotoState(turn);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
|
||||||
|
//sends the TurnStateMachine in PowerCard
|
||||||
|
turnStateMachine.gotoState(playPowerCard);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||||
|
|
||||||
|
//receive first AnimationEndMessage from the host
|
||||||
|
logic.received(animationEnd, fromHost);
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof PlayPowerCard);
|
||||||
|
|
||||||
|
//receive second AnimationEndMessage
|
||||||
|
logic.received(animationEnd, from);
|
||||||
|
|
||||||
|
//tests if the server is in RollDice and in FirstRoll
|
||||||
|
assertTrue(serverAutomaton.getState() instanceof GameState);
|
||||||
|
assertTrue(gameStateMachine.getState() instanceof Turn);
|
||||||
|
assertTrue(turnStateMachine.getState() instanceof RollDice);
|
||||||
|
RollDice rollDice = (RollDice) turnStateMachine.getState();
|
||||||
|
RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine();
|
||||||
|
assertTrue(rollDiceMachine1.getState() instanceof FirstRoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user