From 56f32c5c0b9d565a280839e62668376bc01fb6fd Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 1 Dec 2024 12:09:13 +0100 Subject: [PATCH] edited some comments in the methods and wrote in som methods, to test unwanted statechanges --- .../client/clientState/ClientStateTest.java | 507 +++++++++--------- .../server/serverState/ServerStateTest.java | 161 +++--- 2 files changed, 353 insertions(+), 315 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 17f466c8..8da8e4d3 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -28,6 +28,9 @@ public class ClientStateTest { //declare game here private Game game; + //declare IP-Address + private static final String IP = "168.192.88.101"; + //declare states here private AnimationState animation; private AudioSettingsState audioSettings; @@ -84,7 +87,9 @@ public class ClientStateTest { private PlayCardMessage playCardTurbo; private PossibleCardMessage possibleCard; private PossiblePieceMessage possiblePiece; - private RankingResponseMessage rankingResponce; + private PossiblePieceMessage possiblePieceSwap; //TODO + private PossiblePieceMessage possiblePieceShield;//TODO + private RankingResponseMessage rankingResponse; private RankingRollAgainMessage rankingRollAgain; private ReconnectBriefingMessage reconnectBriefing; private ResumeGameMessage resumeGame; @@ -106,7 +111,7 @@ public class ClientStateTest { @Before public void setUp() { //initialize the game - game = new pp.mdga.game.Game(); + game = new Game(); //initialize the clientGameLogic clientGameLogic = new ClientGameLogic(game, new ClientSender() { @@ -120,6 +125,7 @@ public void send(ClientMessage msg) { from = 1234; name = "Daniel"; color = Color.ARMY; + swapCard = BonusCard.SWAP; shieldCard = BonusCard.SHIELD; turboCard = BonusCard.TURBO; @@ -137,15 +143,17 @@ public void send(ClientMessage msg) { lobbyDeny = new LobbyDenyMessage(); lobbyPlayerJoin = new LobbyPlayerJoinMessage(name); lobbyPlayerLeave = new LobbyPlayerLeaveMessage(name, color); - moveMessage = new MoveMessage("www");//Todo + moveMessage = new MoveMessage("www",false, 20);//Todo noTurn = new NoTurnMessage(); interruptMessage = new PauseGameMessage(); - playCardSwap = new PlayCardMessage(swapCard, "www");//Todo - playCardShield = new PlayCardMessage(shieldCard, "www");//Todo - playCardTurbo = new PlayCardMessage(turboCard, "www");//Todo + playCardSwap = PlayCardMessage.swap("www", "www");//Todo + playCardShield = PlayCardMessage.shield( "www");//Todo + playCardTurbo = PlayCardMessage.turbo(1);//Todo possibleCard = new PossibleCardMessage(); + possiblePieceShield = PossiblePieceMessage.shieldPossiblePieces(new ArrayList<>()); //TODO + possiblePieceSwap = PossiblePieceMessage.swapPossiblePieces(new ArrayList<>(),new ArrayList<>()); //TODO possiblePiece = new PossiblePieceMessage(); - rankingResponce = new RankingResponseMessage(); + rankingResponse = new RankingResponseMessage(); rankingRollAgain = new RankingRollAgainMessage(); reconnectBriefing = new ReconnectBriefingMessage(game); resumeGame = new ResumeGameMessage(); @@ -158,12 +166,6 @@ public void send(ClientMessage msg) { spectatorMessage = new SpectatorMessage(); selectPieceMessage = new SelectPieceMessage(); - //initialize the settings - mainSettings = settings.getMainSettings(); - videoSettings = settings.getVideoSettings(); - audioSettings = settings.getAudioSettings(); - settings = new SettingsState(); - //initialize the states dialogs = clientGameLogic.getDialogs(); gameState = clientGameLogic.getGameState(); @@ -174,8 +176,8 @@ public void send(ClientMessage msg) { networkDialog = dialogs.getNetworkDialog(); lobby = dialogs.getLobby(); - podium = ceremony.getPodium(); - statistics = ceremony.getStatistics(); + podium = ceremony.getPodiumState(); + statistics = ceremony.getStatisticsState(); determineStartPlayer = gameState.getDetermineStartPlayer(); waiting = gameState.getWaiting(); @@ -243,7 +245,7 @@ public void testDialogsToGame() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -269,7 +271,7 @@ public void testDialogsToGame() { assertEquals(gameState.getState(), determineStartPlayer); //tests if the new State of DetermineStartPlayer is RollRankingDice - assertEquals(determineStartPlayer.getState(), rollDice); + assertEquals(determineStartPlayer.getState(), rollRankingDice); } /** @@ -293,7 +295,7 @@ public void testDialogsToClientStateEndState() { */ @Test public void testClientGameToCeremony() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -317,7 +319,7 @@ public void testClientGameToCeremony() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -347,7 +349,7 @@ public void testClientGameToCeremony() { */ @Test public void testClientGameSubStatesToInterrupt() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -379,7 +381,7 @@ public void testGameToDialogs() { */ @Test public void testStayInInterrupt() { - //sends the ClientAutomaton in Interrupt + //sends the ClientGameLogic in Interrupt clientGameLogic.setState(interrupt); assertEquals(clientGameLogic.getState(), interrupt); @@ -404,7 +406,7 @@ public void testStayInInterrupt() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); //clientGameLogic.received(resumeGame); commented out, because it indicates a state-change to gameState @@ -425,7 +427,7 @@ public void testStayInInterrupt() { */ @Test public void testClientInterruptToGame() { - //sends the ClientAutomaton in Interrupt + //sends the ClientGameLogic in Interrupt clientGameLogic.setState(interrupt); assertEquals(clientGameLogic.getState(), interrupt); @@ -441,7 +443,7 @@ public void testClientInterruptToGame() { */ @Test public void testInterruptToDialogs() { - //sends the ClientAutomaton in Interrupt + //sends the ClientGameLogic in Interrupt clientGameLogic.setState(interrupt); assertEquals(clientGameLogic.getState(), interrupt); @@ -478,10 +480,6 @@ public void testCeremonyToDialogs() { @Test public void testStartDialogToNetworkDialog1() { - /** - * tests the transition from StartDialog to Network-Dialog through button-push - */ - // sends the clientGameLogic in StartDialog clientGameLogic.setState(dialogs); assertEquals(clientGameLogic.getState(), dialogs); @@ -502,9 +500,6 @@ public void testStartDialogToNetworkDialog1() { */ @Test public void testStartDialogToNetworkDialog2() { - /** - * test if the player can change it's state through btn-push of the host-button - */ // sends the clientGameLogic in StartDialog clientGameLogic.setState(dialogs); @@ -526,9 +521,6 @@ public void testStartDialogToNetworkDialog2() { */ @Test public void testStartDialogToDialogsEndState() { - /** - * test if the player can end it's application through btn-push of the leave-button - */ // sends the clientGameLogic in StartDialog clientGameLogic.setState(dialogs); @@ -563,7 +555,7 @@ public void testNetworkDialogToStartDialog() { //tests if the client is in startDialog assertEquals(clientGameLogic.getState(), dialogs); - assertEquals(dialog.getState(), startDialog); + assertEquals(dialogs.getState(), startDialog); } /** @@ -580,7 +572,7 @@ public void testNetworkDialogToNetworkDialog1() { assertEquals(dialogs.getState(), networkDialog); //simulate all input, that don't indicate a state-change - clientGameLogic.selectPiece(null); + clientGameLogic.selectPiece(null); //TODO clientGameLogic.selectCard(null); clientGameLogic.selectTsk(color); clientGameLogic.selectDice(); @@ -675,7 +667,7 @@ public void testStayInLobby() { assertEquals(dialogs.getState(), lobby); //simulate all input that don't indicate a state-change - clientGameLogic.selectPiece(null); + clientGameLogic.selectPiece(null); //TODO clientGameLogic.selectCard(null); clientGameLogic.selectTsk(color); clientGameLogic.selectDice(); @@ -708,7 +700,7 @@ public void testStayInLobby() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -776,7 +768,7 @@ public void testDetermineStartPlayerToWait() { */ @Test public void testWaitToAnimation() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -913,7 +905,7 @@ public void testTurnSubStatesToGameEndState() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -943,9 +935,6 @@ public void testTurnSubStatesToGameEndState() { */ @Test public void testTurnSubStatesToWait() { - /** - * tests the transition from MovePiece to Wait - */ //sends the clientGameLogic in gameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -979,7 +968,7 @@ public void testTurnSubStatesToWait() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1003,7 +992,7 @@ public void testTurnSubStatesToWait() { assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), waiting); - /** + /* * tests thr transition from choosePiece to Wait */ @@ -1044,7 +1033,7 @@ public void testTurnSubStatesToWait() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1069,7 +1058,7 @@ public void testTurnSubStatesToWait() { assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), waiting); - /** + /* * tests the transition from RollDice to Wait */ @@ -1106,7 +1095,7 @@ public void testTurnSubStatesToWait() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1169,7 +1158,7 @@ public void testTurnSubStatesToSpectator() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1228,7 +1217,7 @@ public void testSpectatorToGameEndState() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1257,10 +1246,10 @@ public void testSpectatorToGameEndState() { */ @Test public void testPowerCardSubStatesToPlayPowerCard() { - /** + /* * sends the client in the swap-state */ - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1268,7 +1257,7 @@ public void testPowerCardSubStatesToPlayPowerCard() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PlayPowerCard + //sends the turnState in PlayPowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); @@ -1284,10 +1273,10 @@ public void testPowerCardSubStatesToPlayPowerCard() { assertEquals(gameState.getState(), turnState); assertEquals(turnState.getState(), playPowerCard); - /** + /* * send the client in the shield-state */ - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1295,7 +1284,7 @@ public void testPowerCardSubStatesToPlayPowerCard() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PlayPowerCard + //sends the turnState in PlayPowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); @@ -1319,7 +1308,7 @@ public void testPowerCardSubStatesToPlayPowerCard() { */ @Test public void testPowerCardSubStatesToRollDice() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1327,7 +1316,7 @@ public void testPowerCardSubStatesToRollDice() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PlayPowerCard + //sends the turnState in PlayPowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); @@ -1349,7 +1338,7 @@ public void testPowerCardSubStatesToRollDice() { */ @Test public void testStayInPlayPowerCard() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1357,7 +1346,7 @@ public void testStayInPlayPowerCard() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PlayPowerCard + //sends the turnState in PlayPowerCard turnState.setState(playPowerCard); assertEquals(turnState.getState(), playPowerCard); @@ -1382,7 +1371,7 @@ public void testStayInPlayPowerCard() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1413,7 +1402,7 @@ public void testPlayPowerCardToRollDice() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PlayPowerCard + //sends the turnState in PlayPowerCard turnState.setState(playPowerCard); assertEquals(turnState.getState(), playPowerCard); @@ -1438,7 +1427,7 @@ public void testPlayPowerCardToRollDice() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1502,7 +1491,7 @@ public void testStayInRollDice() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1609,7 +1598,7 @@ public void testChoosePieceToWait() { */ @Test public void testChoosePieceToMovePiece() { - /** + /* * tests the transition from waitingPiece to MovePiece */ //sends the client into noPiece @@ -1636,7 +1625,7 @@ public void testChoosePieceToMovePiece() { assertEquals(gameState.getState(), turnState); assertEquals(turnState.getState(), movePiece); - /** + /* * tests the transition from startPiece to MovePiece */ //sends the client into noPiece @@ -1663,7 +1652,7 @@ public void testChoosePieceToMovePiece() { assertEquals(gameState.getState(), turnState); assertEquals(turnState.getState(), movePiece); - /** + /* * tests the transition from selectPiece to MovePiece */ //sends the client into noPiece @@ -1688,7 +1677,7 @@ public void testChoosePieceToMovePiece() { //tests if the client is in the movePiece-state assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); - assertEquals(turnState.getState(), sele); + assertEquals(turnState.getState(), movePiece); } /** @@ -1805,7 +1794,7 @@ public void testStayInChoosePowerCard() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1828,7 +1817,7 @@ public void testStayInChoosePowerCard() { */ @Test public void testChoosePowerCardToRollDice() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1836,11 +1825,11 @@ public void testChoosePowerCardToRollDice() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PowerCard + //sends the turnState in PowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece powerCard.setState(choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard); @@ -1858,7 +1847,7 @@ public void testChoosePowerCardToRollDice() { */ @Test public void testChoosePowerCardToSwap() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1866,16 +1855,16 @@ public void testChoosePowerCardToSwap() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PowerCard + //sends the turnState in PowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece powerCard.setState(choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard); - //sends the TODO selectable Pieces - clientGameLogic.received(); + //sends the possiblePieces-Message + clientGameLogic.received(possiblePieceSwap); //tests if the client is in Swap assertEquals(clientGameLogic.getState(), gameState); @@ -1889,7 +1878,7 @@ public void testChoosePowerCardToSwap() { */ @Test public void testChoosePowerCardToShield() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1897,16 +1886,16 @@ public void testChoosePowerCardToShield() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PowerCard + //sends the turnState in PowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece powerCard.setState(choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard); - //sends the TODO - clientGameLogic.received(); + //sends the possiblePiece-Message + clientGameLogic.received(possiblePieceShield); //tests if the client is in Shield assertEquals(clientGameLogic.getState(), gameState); @@ -1920,7 +1909,7 @@ public void testChoosePowerCardToShield() { */ @Test public void testStayInShield() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -1928,11 +1917,11 @@ public void testStayInShield() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in PowerCard + //sends the turnState in PowerCard turnState.setState(powerCard); assertEquals(turnState.getState(), powerCard); - //sends the turnStatemachine in Shield + //sends the turnState in Shield powerCard.setState(shield); assertEquals(powerCard.getState(), shield); @@ -1957,7 +1946,7 @@ public void testStayInShield() { //clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -1973,7 +1962,7 @@ public void testStayInShield() { assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); assertEquals(turnState.getState(), powerCard); - assertEquals(powerCard.getState(), playPowerCard); + assertEquals(powerCard.getState(), shield); } /** @@ -2018,7 +2007,7 @@ public void testShieldToPowerCardEndState() { //clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2050,7 +2039,7 @@ public void testShieldToPowerCardEndState() { */ @Test public void testSwapToPowerCardEndState() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2080,7 +2069,7 @@ public void testSwapToPowerCardEndState() { */ @Test public void testNoPieceInWaitingPiece() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2088,7 +2077,7 @@ public void testNoPieceInWaitingPiece() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); @@ -2117,7 +2106,7 @@ public void testNoPieceInWaitingPiece() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2143,7 +2132,7 @@ public void testNoPieceInWaitingPiece() { */ @Test public void testNoPieceInSelectedPiece() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2180,7 +2169,7 @@ public void testNoPieceInSelectedPiece() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2243,7 +2232,7 @@ public void testNoPieceInStartPiece() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2269,7 +2258,7 @@ public void testNoPieceInStartPiece() { */ @Test public void testNoPieceInWait() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2277,22 +2266,58 @@ public void testNoPieceInWait() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePiecemachine in NoPiece + //sends the choosePieceState in NoPiece choosePiece.setState(noPiece); assertEquals(choosePiece.getState(), noPiece); - //Todo test other messages, that there is no state change + //test other messages, that there is no state change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + clientGameLogic.received(moveMessage); + //clientGameLogic.received(noTurn); + //clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponse); + clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + //clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + //clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + //clientGameLogic.received(selectPieceMessage); + + //tests if the client is still in noPiece + assertEquals(clientGameLogic.getState(), gameState); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), choosePiece); + assertEquals(choosePiece.getState(), noPiece); //sends to the clientGameLogic the message NoTurn clientGameLogic.received(noTurn); assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(), turnState); - assertEquals(turnState.getState(), waiting); + assertEquals(gameState.getState(), waiting); } /** @@ -2300,7 +2325,7 @@ public void testNoPieceInWait() { */ @Test public void testStayInWaitingPiece() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2308,16 +2333,48 @@ public void testStayInWaitingPiece() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePiecemachine in WaitingPiece + //sends the choosePieceState in WaitingPiece choosePiece.setState(waitingPiece); assertEquals(choosePiece.getState(), waitingPiece); - //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change + //send all sever-messages except interrupt and moveMessage to test, if there are no state change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + //clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + //clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponse); + clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + clientGameLogic.received(selectPieceMessage); + //tests, if the client is still in WaitingPiece assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); assertEquals(turnState.getState(), choosePiece); @@ -2329,7 +2386,7 @@ public void testStayInWaitingPiece() { */ @Test public void testWaitingPieceInChoosePieceEndState() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2337,15 +2394,16 @@ public void testWaitingPieceInChoosePieceEndState() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePieceStatemachine in WaitingPiece + //sends the choosePieceState in WaitingPiece choosePiece.setState(waitingPiece); assertEquals(choosePiece.getState(), waitingPiece); - //Todo send the message to the clientGameLogic to force a state change + //send the move-message to the clientGameLogic to force a state change + clientGameLogic.received(moveMessage); assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); @@ -2357,7 +2415,7 @@ public void testWaitingPieceInChoosePieceEndState() { */ @Test public void testStayInSelectedPiece() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2365,15 +2423,46 @@ public void testStayInSelectedPiece() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePieceStatemachine in SelectPiece; + //sends the choosePieceState in SelectPiece; choosePiece.setState(selectPiece); assertEquals(choosePiece.getState(), selectPiece); - //Todo send all server messages which dont force a state change here + //send all server messages which dont force a state change here + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + //clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + //clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponse); + clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + clientGameLogic.received(selectPieceMessage); assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); @@ -2386,7 +2475,7 @@ public void testStayInSelectedPiece() { */ @Test public void testSelectedPieceInChoosePieceEndState() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2394,15 +2483,16 @@ public void testSelectedPieceInChoosePieceEndState() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePieceStatemachine in SelectPiece + //sends the choosePieceState in SelectPiece choosePiece.setState(selectPiece); assertEquals(choosePiece.getState(), selectPiece); - //Todo send the message which force a state change + //sends the move-message + clientGameLogic.received(moveMessage); assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); @@ -2414,7 +2504,7 @@ public void testSelectedPieceInChoosePieceEndState() { */ @Test public void testStayInStartPiece() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2422,15 +2512,46 @@ public void testStayInStartPiece() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePieceStatemachine in StartPiece + //sends the choosePieceState in StartPiece choosePiece.setState(startPiece); assertEquals(choosePiece.getState(), startPiece); - //todo send all messages which dont force a state change + //send all messages which dont force a state change + clientGameLogic.received(activePlayer); + clientGameLogic.received(anyPiece); + clientGameLogic.received(briefing); + clientGameLogic.received(ceremonyMessage); + clientGameLogic.received(die); + clientGameLogic.received(diceAgain); + clientGameLogic.received(diceNow); + clientGameLogic.received(endOfTurn); + clientGameLogic.received(lobbyAccept); + clientGameLogic.received(lobbyDeny); + clientGameLogic.received(lobbyPlayerJoin); + clientGameLogic.received(lobbyPlayerLeave); + //clientGameLogic.received(moveMessage); + clientGameLogic.received(noTurn); + //clientGameLogic.received(interruptMessage); + clientGameLogic.received(playCardSwap); + clientGameLogic.received(playCardShield); + clientGameLogic.received(playCardTurbo); + clientGameLogic.received(possibleCard); + clientGameLogic.received(possiblePiece); + clientGameLogic.received(rankingResponse); + clientGameLogic.received(rankingRollAgain); + clientGameLogic.received(reconnectBriefing); + clientGameLogic.received(resumeGame); + clientGameLogic.received(startGame); + clientGameLogic.received(startPieceMessage); + clientGameLogic.received(updateReady); + clientGameLogic.received(updateTSK); + clientGameLogic.received(waitPiece); + clientGameLogic.received(spectatorMessage); + clientGameLogic.received(selectPieceMessage); assertEquals(clientGameLogic.getState(), gameState); assertEquals(gameState.getState(), turnState); @@ -2443,7 +2564,7 @@ public void testStayInStartPiece() { */ @Test public void testStartPieceToChoosePieceEndState() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2451,11 +2572,11 @@ public void testStartPieceToChoosePieceEndState() { gameState.setState(turnState); assertEquals(gameState.getState(), turnState); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece turnState.setState(choosePiece); assertEquals(turnState.getState(), choosePiece); - //sends the choosePieceStatemachine in StartPiece + //sends the choosePieceState in StartPiece choosePiece.setState(startPiece); assertEquals(choosePiece.getState(), startPiece); @@ -2480,7 +2601,7 @@ public void testStartPieceToChoosePieceEndState() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2512,7 +2633,7 @@ public void testStartPieceToChoosePieceEndState() { */ @Test public void testRollRankingDiceToWaitRanking() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2520,7 +2641,7 @@ public void testRollRankingDiceToWaitRanking() { gameState.setState(determineStartPlayer); assertEquals(gameState.getState(), determineStartPlayer); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece determineStartPlayer.setState(rollRankingDice); assertEquals(determineStartPlayer.getState(), rollRankingDice); @@ -2545,7 +2666,7 @@ public void testRollRankingDiceToWaitRanking() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2559,7 +2680,7 @@ public void testRollRankingDiceToWaitRanking() { //test if the client is still in rollRankingDice assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); assertEquals(determineStartPlayer.getState(), rollRankingDice); //sends die-message @@ -2567,7 +2688,7 @@ public void testRollRankingDiceToWaitRanking() { //test if the client is in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); assertEquals(determineStartPlayer.getState(), waitRanking); } @@ -2576,7 +2697,7 @@ public void testRollRankingDiceToWaitRanking() { */ @Test public void testWaitRankingToRollRankingDice() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2584,7 +2705,7 @@ public void testWaitRankingToRollRankingDice() { gameState.setState(determineStartPlayer); assertEquals(gameState.getState(), determineStartPlayer); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece determineStartPlayer.setState(waitRanking); assertEquals(determineStartPlayer.getState(), waitRanking); @@ -2609,7 +2730,7 @@ public void testWaitRankingToRollRankingDice() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); //clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2623,7 +2744,7 @@ public void testWaitRankingToRollRankingDice() { //test if the client is still in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); assertEquals(determineStartPlayer.getState(), waitRanking); //sends rankingRollAgain-message @@ -2631,7 +2752,7 @@ public void testWaitRankingToRollRankingDice() { //test if the client is in rollRankingDice assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); assertEquals(determineStartPlayer.getState(), rollRankingDice); } @@ -2640,7 +2761,7 @@ public void testWaitRankingToRollRankingDice() { */ @Test public void testWaitRankingToEndStateDetermineStartingPlayer() { - //sends the ClientAutomaton in GameState + //sends the ClientGameLogic in GameState clientGameLogic.setState(gameState); assertEquals(clientGameLogic.getState(), gameState); @@ -2648,7 +2769,7 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() { gameState.setState(determineStartPlayer); assertEquals(gameState.getState(), determineStartPlayer); - //sends the turnStatemachine in ChoosePiece + //sends the turnState in ChoosePiece determineStartPlayer.setState(waitRanking); assertEquals(determineStartPlayer.getState(), waitRanking); @@ -2673,7 +2794,7 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() { clientGameLogic.received(playCardTurbo); clientGameLogic.received(possibleCard); clientGameLogic.received(possiblePiece); - clientGameLogic.received(rankingResponce); + clientGameLogic.received(rankingResponse); //clientGameLogic.received(rankingRollAgain); clientGameLogic.received(reconnectBriefing); clientGameLogic.received(resumeGame); @@ -2687,7 +2808,7 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() { //test if the client is still in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); assertEquals(determineStartPlayer.getState(), waitRanking); //sends endOfTurn-message @@ -2695,7 +2816,7 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() { //test if the client is in wait assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(), waiting); + assertEquals(gameState.getState(), waiting); } /** @@ -2737,110 +2858,4 @@ public void testStatisticsToCeremonyEndState() { assertEquals(clientGameLogic.getState(), dialogs); assertEquals(dialogs.getState(), startDialog); } - - /** - * UC-ClientState-63: Test the transition from MainSettings to VideoSettings. - */ - @Test - public void testMainSettingsToVideoSettings() { - //send the settings into main-settings - settings.setState(mainSettings); - assertEquals(settings.getState(), mainSettings); - - //todo - - //tests if the client is in the video-settings - assertEquals(settings.getState(), videoSettings); - } - - /** - * UC-ClientState-64: Test the transition from MainSettings to AudioSettings. - */ - @Test - public void testMainSettingsToAudioSettings() { - //send the settings into main-settings - settings.setState(mainSettings); - assertEquals(settings.getState(), mainSettings); - - //todo - - //tests if the client is in the audio-settings - assertEquals(settings.getState(), audioSettings); - } - - /** - * UC-ClientState-65: Test the transition from MainSettings to ClientState. - */ - @Test - public void testMainSettingsToClientState() { - // Todo Implementation goes here - } - - /** - * UC-ClientState-66: Test staying in the VideoSettings state. - */ - @Test - public void testStayInVideoSettings() { - //send the settings into AudioSettings - settings.setState(audioSettings); - assertEquals(settings.getState(), audioSettings); - - //TODo - - //tests if the client is in the video-settings - assertEquals(settings.getState(), videoSettings); - } - - /** - * UC-ClientState-67: Test the transition from VideoSettings to MainSettings. - */ - @Test - public void testVideoSettingsToMainSettings() { - //send the settings into AudioSettings - settings.setState(videoSettings); - assertEquals(settings.getState(), videoSettings); - - //TODo - - //tests if the client is in the main-settings - assertEquals(settings.getState(), mainSettings); - } - - /** - * UC-ClientState-68: Test staying in the AudioSettings state. - */ - @Test - public void testStayInAudioSettings() { - //send the settings into AudioSettings - settings.setState(audioSettings); - assertEquals(settings.getState(), audioSettings); - - //TODo - - //tests if the client is in the audio-settings - assertEquals(settings.getState(), audioSettings); - } - - /** - * UC-ClientState-69: Test the transition from AudioSettings to MainSettings. - */ - @Test - public void testAudioSettingsToMainSettings() { - //send the settings into AudioSettings - settings.setState(audioSettings); - assertEquals(settings.getState(), audioSettings); - - //TODo - - //tests if the client is in the main-settings - assertEquals(settings.getState(), mainSettings); - } - - /** - * UC-ClientState-70: Test the transition from ClientState substates to MainSettings. - */ - @Test - public void testClientStateSubStatesToMainSettings() { - // todo Implementation goes here - } } diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index dfcf6066..4b0b0e39 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -6,14 +6,13 @@ import pp.mdga.game.BonusCard; import pp.mdga.game.Color; import pp.mdga.game.Game; +import pp.mdga.game.Piece; +import pp.mdga.game.PieceState; +import pp.mdga.game.Player; import pp.mdga.message.server.ServerMessage; import pp.mdga.message.client.*; import pp.mdga.server.*; -import pp.mdga.server.automaton.CeremonyState; -import pp.mdga.server.automaton.GameState; -import pp.mdga.server.automaton.InterruptState; -import pp.mdga.server.automaton.LobbyState; -import pp.mdga.server.automaton.ServerState; +import pp.mdga.server.automaton.*; import static org.junit.Assert.*; @@ -46,20 +45,21 @@ public class ServerStateTest { private SelectTSKMessage selectTSK; private DisconnectedMessage disconnect; - //declare state-States here + //TODO declare two players - //TODO: interrupt and lobby are no state-States + private Player playerHost; + private int IDPlayerHost; + private Color playerHostColor; - //declare states here - //TODO - - - - //Todo declare attributes to simulate a player - private int from; - private int fromHost; + private Player playerClient; + private int IDPlayerClient; + private Color playerClientColor; + //todo declare a piece + private Piece piece; + private PieceState pieceState; + private int IDPiece; //TODO declare the states here @@ -121,9 +121,6 @@ public void broadcast(ServerMessage message) { selectedPieces = new SelectedPiecesMessage("www"); //TODO selectTSK = new SelectTSKMessage(Color.ARMY); //TODO - from = 1234; - fromHost = 2345; - //initialize the states here thirdRoll = rollDiceState.getThirdRollState(); secondRoll = rollDiceState.getSecondRollState(); @@ -149,6 +146,27 @@ public void broadcast(ServerMessage message) { gameState = (GameState) serverGameLogic.getGameState(); ceremonyState = (CeremonyState) serverGameLogic.getCeremonyState(); interruptState = (InterruptState) serverGameLogic.getInterruptState(); + + //Todo initialize two players + + playerHost = new Player("Host"); + IDPlayerHost = 1; + playerHostColor = Color.ARMY; + playerHost.setColor(playerHostColor); + game.addPlayer(IDPlayerHost,playerHost); + + playerClient = new Player("Client"); + IDPlayerClient = 2; + playerClientColor = Color.AIRFORCE; + playerClient.setColor(playerClientColor); + game.addPlayer(IDPlayerClient,playerClient); + + //todo initialize a piece + IDPiece = 3; + pieceState = PieceState.ACTIVE; + piece = new Piece(playerClientColor,pieceState,IDPiece); + + game.getBoard().setPieceOnBoard(15,piece); //TODO } /** @@ -156,6 +174,7 @@ public void broadcast(ServerMessage message) { */ @Test public void testInitialStateServerState() { + //tests if the server is in lobbyState assertEquals(serverGameLogic.getCurrentState(),lobbyState); } @@ -174,8 +193,8 @@ public void testLobbyToDetermineStartPlayer() { //tests if the server is still in the lobby-state assertEquals(serverGameLogic.getLobbyState(),lobbyState); - //sends the startGame-message from the Host to the server - serverGameLogic.received(clientStartGame, from); + //sends the startGame-message IDPlayerClient the Host to the server + serverGameLogic.received(clientStartGame, IDPlayerHost); //TODO is playerId == ConnectionID? //tests if the server is in DSP-state assertEquals(serverGameLogic.getCurrentState(),gameState); @@ -192,22 +211,22 @@ public void testStayInLobby() { assertEquals(serverGameLogic.getCurrentState(),lobbyState); //TODO serverGameLogic gets all messages, which dont indicate a state change - serverGameLogic.received(animationEnd, from); - serverGameLogic.received(clientStartGame, from); - serverGameLogic.received(deselectTSK, from); - serverGameLogic.received(forceContinueGame, from); - serverGameLogic.received(forceStartGame, from); - serverGameLogic.received(joinServer, from); - serverGameLogic.received(leaveGame, from); - serverGameLogic.received(lobbyReady, from); - serverGameLogic.received(noPowerCard, from); - serverGameLogic.received(requestBriefing, from); - serverGameLogic.received(requestDice, from); - serverGameLogic.received(requestMove, from); - serverGameLogic.received(requestPlayCard, from); - serverGameLogic.received(selectCard, from); - serverGameLogic.received(selectedPieces, from); - serverGameLogic.received(selectTSK, from); + serverGameLogic.received(animationEnd, IDPlayerClient); + serverGameLogic.received(clientStartGame, IDPlayerClient); + serverGameLogic.received(deselectTSK, IDPlayerClient); + serverGameLogic.received(forceContinueGame, IDPlayerClient); + serverGameLogic.received(forceStartGame, IDPlayerClient); + serverGameLogic.received(joinServer, IDPlayerClient); + serverGameLogic.received(leaveGame, IDPlayerClient); + serverGameLogic.received(lobbyReady, IDPlayerClient); + serverGameLogic.received(noPowerCard, IDPlayerClient); + serverGameLogic.received(requestBriefing, IDPlayerClient); + serverGameLogic.received(requestDice, IDPlayerClient); + serverGameLogic.received(requestMove, IDPlayerClient); + serverGameLogic.received(requestPlayCard, IDPlayerClient); + serverGameLogic.received(selectCard, IDPlayerClient); + serverGameLogic.received(selectedPieces, IDPlayerClient); + serverGameLogic.received(selectTSK, IDPlayerClient); //tests if Server is still in Lobby assertEquals(serverGameLogic.getCurrentState(),lobbyState); @@ -225,14 +244,14 @@ public void testServerGameSubStatesToInterrupt() { //Todo //sends the interrupt - serverGameLogic.received(disconnect,from); + serverGameLogic.received(disconnect,IDPlayerClient); //tests if the server is in the Interrupt-state assertEquals(serverGameLogic.getInterruptState(),interruptState); } /** - * tests the state-change from Game to Ceremony if the Game is finished + * tests the state-change IDPlayerClient Game to Ceremony if the Game is finished */ @Test public void testServerGameToCeremony() { @@ -261,7 +280,7 @@ public void testInterruptToGameContinue() { assertEquals(serverGameLogic.getCurrentState(),interruptState); //sends the continue-message to the server - serverGameLogic.received(forceContinueGame, from); + serverGameLogic.received(forceContinueGame, IDPlayerClient); //tests if new Stet is in GameState assertEquals(serverGameLogic.getCurrentState() ,gameState); @@ -302,7 +321,11 @@ public void testInterruptToGameTimer() { */ @Test public void testCeremonyToServerStateEndState() { - // TODO: Implement test serverGameLogic for transition from Ceremony to Server State End State + //sends the server in ceremony + serverGameLogic.setCurrentState(ceremonyState); + assertEquals(serverGameLogic.getCurrentState() ,ceremonyState); + + //tests if the server is closed // TODO how???? } @@ -341,14 +364,14 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() { //TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server //sends the requestDiceMessage to the server - gameState.received(requestDice, from); + gameState.received(requestDice, IDPlayerClient); //tests if the server is still in DSP-state assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,determineStartPlayerState); //sends the requestDiceMessage to the server - gameState.received(requestMove, fromHost); + gameState.received(requestMove, IDPlayerClient); //tests if the server is still in DSP-state assertEquals(serverGameLogic.getCurrentState() ,gameState); @@ -376,7 +399,7 @@ public void testDetermineStartPlayerToAnimation() { } /** - * tests that the server goes from the animation-state into PowerCardState, if the animation in the client has ended + * 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 */ @Test @@ -390,12 +413,12 @@ public void testAnimationToPowerCard() { assertEquals(gameState.getCurrentState() ,animation); //receives one animation endMessage and tests if the server is still in the Animation-state - serverGameLogic.received(animationEnd, fromHost); + serverGameLogic.received(animationEnd, IDPlayerClient); assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,animation); //receives another animation endMessage - serverGameLogic.received(animationEnd, from); + serverGameLogic.received(animationEnd, IDPlayerClient); //tests if the server is in the PowerCard-state assertEquals(serverGameLogic.getCurrentState() ,gameState); @@ -404,7 +427,7 @@ public void testAnimationToPowerCard() { } /** - * this method tests that the server changes it's state from the turn-state to the animation-state, if there are at + * 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 */ @Test @@ -425,7 +448,7 @@ public void testTurnToAnimation() { } /** - * this method tests that the server changes it's state from the turn-state to the ceremony-state, + * 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 */ @Test @@ -471,7 +494,7 @@ public void testStayInPowerCard() { } /** - * Tests the transition from PowerCard state to PlayPowerCard state. + * Tests the transition IDPlayerClient PowerCard state to PlayPowerCard state. * UC-ServerState-17 */ @Test @@ -497,7 +520,7 @@ public void testPowerCardToPlayPowerCard() { } /** - * Tests the transition from PlayPowerCard state to RollDice state. + * Tests the transition IDPlayerClient PlayPowerCard state to RollDice state. * UC-ServerState-18 */ @Test @@ -514,14 +537,14 @@ public void testPlayPowerCardToRollDice() { turnState.setCurrentState(playPowerCard); assertEquals(turnState.getCurrentState() ,playPowerCard); - //receive first AnimationEndMessage from the host - serverGameLogic.received(animationEnd, fromHost); + //receive first AnimationEndMessage IDPlayerClient the host + serverGameLogic.received(animationEnd, IDPlayerClient); assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,turnState); assertEquals(turnState.getCurrentState() ,playPowerCard); //receive second AnimationEndMessage - serverGameLogic.received(animationEnd, from); + serverGameLogic.received(animationEnd, IDPlayerClient); //tests if the server is in RollDice and in FirstRoll assertEquals(serverGameLogic.getCurrentState() ,gameState); @@ -531,7 +554,7 @@ public void testPlayPowerCardToRollDice() { } /** - * Tests the transition from ChoosePiece state to MovePiece state. + * Tests the transition IDPlayerClient ChoosePiece state to MovePiece state. * UC-ServerState-19 */ @Test @@ -556,7 +579,7 @@ public void testChoosePieceToMovePiece() { } /** - * Tests the transition from MovePiece state to TurnEndState. + * Tests the transition IDPlayerClient MovePiece state to TurnEndState. * UC-ServerState-20 */ @Test @@ -579,7 +602,7 @@ public void testMovePieceToTurnEndState() { } /** - * Tests the transition from MovePiece state to FirstRoll state. + * Tests the transition IDPlayerClient MovePiece state to FirstRoll state. * UC-ServerState-21 */ @Test @@ -605,7 +628,7 @@ public void testMovePieceToFirstRoll() { } /** - * Tests the transition from FirstRoll state to RollDiceEndState. + * Tests the transition IDPlayerClient FirstRoll state to RollDiceEndState. * UC-ServerState-22 */ @Test @@ -636,7 +659,7 @@ public void testFirstRollToRollDiceEndState() { } /** - * Tests the transition from FirstRoll state to SecondRoll state. + * Tests the transition IDPlayerClient FirstRoll state to SecondRoll state. * UC-ServerState-23 */ @Test @@ -667,7 +690,7 @@ public void testFirstRollToSecondRoll() { } /** - * Tests the transition from SecondRoll state to RollDiceEndState. + * Tests the transition IDPlayerClient SecondRoll state to RollDiceEndState. * UC-ServerState-24 */ @Test @@ -698,7 +721,7 @@ public void testSecondRollToRollDiceEndState() { } /** - * Tests the transition from SecondRoll state to ThirdRoll state. + * Tests the transition IDPlayerClient SecondRoll state to ThirdRoll state. * UC-ServerState-25 */ @Test @@ -729,7 +752,7 @@ public void testSecondRollToThirdRoll() { } /** - * Tests the transition from ThirdRoll state to RollDiceEndState. + * Tests the transition IDPlayerClient ThirdRoll state to RollDiceEndState. * UC-ServerState-26 */ @Test @@ -760,7 +783,7 @@ public void testThirdRollToRollDiceEndState() { } /** - * Tests the transition from ThirdRoll state to TurnEndState. + * Tests the transition IDPlayerClient ThirdRoll state to TurnEndState. * UC-ServerState-27 */ @Test @@ -785,7 +808,7 @@ public void testThirdRollToTurnEndState() { } /** - * Tests the transition from NoPiece state to WaitingPiece state. + * Tests the transition IDPlayerClient NoPiece state to WaitingPiece state. * UC-ServerState-28 */ @Test @@ -817,7 +840,7 @@ public void testNoPieceToWaitingPiece() { } /** - * Tests the transition from NoPiece state to NoTurn state. + * Tests the transition IDPlayerClient NoPiece state to NoTurn state. * UC-ServerState-29 */ @Test @@ -848,7 +871,7 @@ public void testNoPieceToNoTurn() { } /** - * Tests the transition from NoTurn state to TurnEndState. + * Tests the transition IDPlayerClient NoTurn state to TurnEndState. * UC-ServerState-30 */ @Test @@ -904,7 +927,7 @@ public void testStayInWaitingPiece() { } /** - * Tests the transition from WaitingPiece state to MovePiece state. + * Tests the transition IDPlayerClient WaitingPiece state to MovePiece state. * UC-ServerState-32 */ @Test @@ -929,7 +952,7 @@ public void testWaitingPieceToMovePiece() { } /** - * Tests the transition from NoPiece state to SelectPiece state. + * Tests the transition IDPlayerClient NoPiece state to SelectPiece state. * UC-ServerState-33 */ @Test @@ -960,7 +983,7 @@ public void testNoPieceToSelectPiece() { } /** - * Tests the transition from NoPiece state to StartPiece state. + * Tests the transition IDPlayerClient NoPiece state to StartPiece state. * UC-ServerState-34 */ @Test @@ -1022,7 +1045,7 @@ public void testStayInSelectPiece() { } /** - * Tests the transition from SelectPiece state to MovePiece state. + * Tests the transition IDPlayerClient SelectPiece state to MovePiece state. * UC-ServerState-36 */ @Test @@ -1083,7 +1106,7 @@ public void testStayInStartPiece() { } /** - * Tests the transition from StartPiece state to MovePiece state. + * Tests the transition IDPlayerClient StartPiece state to MovePiece state. * UC-ServerState-38 */ @Test