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 4c84b874..17f466c8 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 @@ -15,6 +15,7 @@ import pp.mdga.game.BonusCard; import pp.mdga.game.Color; import pp.mdga.message.client.ClientMessage; + import java.util.ArrayList; import static org.junit.Assert.*; @@ -282,7 +283,7 @@ public void testDialogsToClientStateEndState() { //sends dialogs in startDialog-state dialogs.setState(startDialog); - assertEquals(dialogs.getState(),startDialog); + assertEquals(dialogs.getState(), startDialog); //TODO how????????? } @@ -885,11 +886,11 @@ public void testTurnSubStatesToGameEndState() { //sends the gameState in turnState gameState.setState(turnState); - assertEquals(gameState.getState(),turnState); + assertEquals(gameState.getState(), turnState); //sends the turnState in movePiece turnState.setState(movePiece); - assertEquals(turnState.getState(),movePiece); + assertEquals(turnState.getState(), movePiece); //tests all messages, that don't indicate a state-change clientGameLogic.received(activePlayer); @@ -926,15 +927,15 @@ public void testTurnSubStatesToGameEndState() { //tests if the client is still in MovePiece assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),movePiece); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), movePiece); //sends the spectator message clientGameLogic.received(ceremonyMessage); //tests if the client is in spectator-state assertEquals(clientGameLogic.getState(), ceremony); - assertEquals(ceremony.getState(),podium); + assertEquals(ceremony.getState(), podium); } /** @@ -951,11 +952,11 @@ public void testTurnSubStatesToWait() { //sends the gameState in turnState gameState.setState(turnState); - assertEquals(gameState.getState(),turnState); + assertEquals(gameState.getState(), turnState); //sends the turnState in movePiece turnState.setState(movePiece); - assertEquals(turnState.getState(),movePiece); + assertEquals(turnState.getState(), movePiece); //tests all messages, that don't indicate a state-change clientGameLogic.received(activePlayer); @@ -992,15 +993,15 @@ public void testTurnSubStatesToWait() { //tests if the client is still in MovePiece assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),movePiece); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), movePiece); //sends the endOfTurn message clientGameLogic.received(endOfTurn); //tests if the client is in waiting-state assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),waiting); + assertEquals(gameState.getState(), waiting); /** * tests thr transition from choosePiece to Wait @@ -1012,15 +1013,15 @@ public void testTurnSubStatesToWait() { //sends the gameState in turnState gameState.setState(turnState); - assertEquals(gameState.getState(),turnState); + assertEquals(gameState.getState(), turnState); //sends the turnState in choosePiece turnState.setState(movePiece); - assertEquals(turnState.getState(),choosePiece); + assertEquals(turnState.getState(), choosePiece); //sends the choosePiece in NoPiece choosePiece.setState(noPiece); - assertEquals(choosePiece.getState(),noPiece); + assertEquals(choosePiece.getState(), noPiece); //tests all messages, that don't indicate a state-change clientGameLogic.received(activePlayer); @@ -1057,16 +1058,16 @@ public void testTurnSubStatesToWait() { //tests if the client is still in MovePiece assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),choosePiece); - assertEquals(choosePiece.getState(),noPiece); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), choosePiece); + assertEquals(choosePiece.getState(), noPiece); //sends the endOfTurn message clientGameLogic.received(endOfTurn); //tests if the client is in waiting-state assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),waiting); + assertEquals(gameState.getState(), waiting); /** * tests the transition from RollDice to Wait @@ -1078,11 +1079,11 @@ public void testTurnSubStatesToWait() { //sends the gameState in turnState gameState.setState(turnState); - assertEquals(gameState.getState(),turnState); + assertEquals(gameState.getState(), turnState); //sends the turnState in movePiece turnState.setState(movePiece); - assertEquals(turnState.getState(),rollDice); + assertEquals(turnState.getState(), rollDice); //tests all messages, that don't indicate a state-change clientGameLogic.received(activePlayer); @@ -1119,15 +1120,15 @@ public void testTurnSubStatesToWait() { //tests if the client is still in MovePiece assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),rollDice); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), rollDice); //sends the endOfTurn message clientGameLogic.received(endOfTurn); //tests if the client is in waiting-state assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),waiting); + assertEquals(gameState.getState(), waiting); } /** @@ -1141,11 +1142,11 @@ public void testTurnSubStatesToSpectator() { //sends the gameState in turnState gameState.setState(turnState); - assertEquals(gameState.getState(),turnState); + assertEquals(gameState.getState(), turnState); //sends the turnState in movePiece turnState.setState(movePiece); - assertEquals(turnState.getState(),movePiece); + assertEquals(turnState.getState(), movePiece); //tests all messages, that don't indicate a state-change clientGameLogic.received(activePlayer); @@ -1182,15 +1183,15 @@ public void testTurnSubStatesToSpectator() { //tests if the client is still in MovePiece assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),movePiece); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), movePiece); //sends the spectator message clientGameLogic.received(spectatorMessage); //tests if the client is in spectator-state assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),spectator); + assertEquals(gameState.getState(), spectator); } /** @@ -1248,7 +1249,7 @@ public void testSpectatorToGameEndState() { //tests if the client is in the podium-state assertEquals(clientGameLogic.getState(), ceremony); - assertEquals(ceremony.getState(),podium); + assertEquals(ceremony.getState(), podium); } /** @@ -1313,7 +1314,7 @@ public void testPowerCardSubStatesToPlayPowerCard() { /** * UC-ClientState-30: Test the transition from PowerCard sub-states to RollDice. - * + *

* tests the transition from ChoosePowerCard from PowerCard to RollDice */ @Test @@ -1572,7 +1573,7 @@ public void testRollDiceToWait() { /** * UC-ClientState-36: Test the transition from ChoosePiece to Wait. - * + *

* this method tests the transition from noPiece to Wait */ @Test @@ -1591,7 +1592,7 @@ public void testChoosePieceToWait() { //sends the choosePiece into noTurn choosePiece.setState(noPiece); - assertEquals(choosePiece.getState(),noPiece); + assertEquals(choosePiece.getState(), noPiece); //send the noTurnMessage clientGameLogic.received(noTurn); @@ -1625,7 +1626,7 @@ public void testChoosePieceToMovePiece() { //sends the choosePiece into waitingPiece choosePiece.setState(waitingPiece); - assertEquals(choosePiece.getState(),waitingPiece); + assertEquals(choosePiece.getState(), waitingPiece); //sends the movePieceMessage clientGameLogic.received(moveMessage); @@ -1652,7 +1653,7 @@ public void testChoosePieceToMovePiece() { //sends the choosePiece into startPiece choosePiece.setState(startPiece); - assertEquals(choosePiece.getState(),startPiece); + assertEquals(choosePiece.getState(), startPiece); //sends the movePieceMessage clientGameLogic.received(moveMessage); @@ -1679,7 +1680,7 @@ public void testChoosePieceToMovePiece() { //sends the choosePiece into selectPiece choosePiece.setState(selectPiece); - assertEquals(choosePiece.getState(),selectPiece); + assertEquals(choosePiece.getState(), selectPiece); //sends the movePieceMessage clientGameLogic.received(moveMessage); @@ -1738,7 +1739,7 @@ public void testMovePieceToSpectator() { //tests if the client is in Spectator assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),spectator); + assertEquals(gameState.getState(), spectator); } /** @@ -1763,7 +1764,7 @@ public void testMovePieceToCeremony() { //tests if the client is in Spectator assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),spectator); + assertEquals(gameState.getState(), spectator); } /** @@ -1815,12 +1816,11 @@ public void testStayInChoosePowerCard() { clientGameLogic.received(waitPiece); clientGameLogic.received(spectatorMessage); clientGameLogic.received(selectPieceMessage); - //TODO selectable pieces //tests if the client is still in the choosePowerCard-State assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getState(),turnState); - assertEquals(turnState.getState(),choosePowerCard); + assertEquals(gameState.getState(), turnState); + assertEquals(turnState.getState(), choosePowerCard); } /** @@ -2066,7 +2066,8 @@ public void testSwapToPowerCardEndState() { powerCard.setState(swap); assertEquals(powerCard.getState(), swap); - //todo send the message to force the statechange + //sends the playCardMessage + clientGameLogic.received(playCardSwap); //tests if the client is in PlayPowerCard assertEquals(clientGameLogic.getState(), gameState); @@ -2558,16 +2559,16 @@ public void testRollRankingDiceToWaitRanking() { //test if the client is still in rollRankingDice assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),determineStartPlayer); - assertEquals(determineStartPlayer.getState(),rollRankingDice); + assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(determineStartPlayer.getState(), rollRankingDice); //sends die-message clientGameLogic.received(die); //test if the client is in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),determineStartPlayer); - assertEquals(determineStartPlayer.getState(),waitRanking); + assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(determineStartPlayer.getState(), waitRanking); } /** @@ -2622,16 +2623,16 @@ public void testWaitRankingToRollRankingDice() { //test if the client is still in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),determineStartPlayer); - assertEquals(determineStartPlayer.getState(),waitRanking); + assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(determineStartPlayer.getState(), waitRanking); //sends rankingRollAgain-message clientGameLogic.received(rankingRollAgain); //test if the client is in rollRankingDice assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),determineStartPlayer); - assertEquals(determineStartPlayer.getState(),rollRankingDice); + assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(determineStartPlayer.getState(), rollRankingDice); } /** @@ -2686,15 +2687,15 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() { //test if the client is still in waitRanking assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),determineStartPlayer); - assertEquals(determineStartPlayer.getState(),waitRanking); + assertEquals(gameState.getLogic(), determineStartPlayer); + assertEquals(determineStartPlayer.getState(), waitRanking); //sends endOfTurn-message clientGameLogic.received(endOfTurn); //test if the client is in wait assertEquals(clientGameLogic.getState(), gameState); - assertEquals(gameState.getLogic(),waiting); + assertEquals(gameState.getLogic(), waiting); } /** @@ -2728,13 +2729,13 @@ public void testStatisticsToCeremonyEndState() { //sends the ceremony in statistics ceremony.setState(statistics); - assertEquals(ceremony.getState(),statistics); + assertEquals(ceremony.getState(), statistics); //TODO simulate button-push //tests if client is in startDialog assertEquals(clientGameLogic.getState(), dialogs); - assertEquals(dialogs.getState(),startDialog); + assertEquals(dialogs.getState(), startDialog); } /** 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 97f2a436..dfcf6066 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 @@ -46,9 +46,9 @@ public class ServerStateTest { private SelectTSKMessage selectTSK; private DisconnectedMessage disconnect; - //declare state-machines here + //declare state-States here - //TODO: interrupt and lobby are no state-machines + //TODO: interrupt and lobby are no state-States //declare states here //TODO @@ -79,13 +79,13 @@ public class ServerStateTest { private RollDiceState rollDiceState; private SecondRollState secondRoll; private SelectPieceState selectPiece; - private StartPieceState startPiece; + private StartPieceState startPieceState; private ThirdRollState thirdRoll; private TurnState turnState; private WaitingPieceState waitingPiece; /** - * TODO initialize the states and machines and messages here + * this method is used to initialize the attributes of this test-class */ @Before public void setUp() { @@ -124,7 +124,7 @@ public void broadcast(ServerMessage message) { from = 1234; fromHost = 2345; - //initialize the state-machines here + //initialize the states here thirdRoll = rollDiceState.getThirdRollState(); secondRoll = rollDiceState.getSecondRollState(); firstRollState = rollDiceState.getThirdRollState(); @@ -132,7 +132,7 @@ public void broadcast(ServerMessage message) { noPiece = choosePieceState.getNoPieceState(); noTurnState = choosePieceState.getNoTurnState(); waitingPiece = choosePieceState.getWaitingPieceState(); - startPiece = choosePieceState.getStartPieceState(); + startPieceState = choosePieceState.getStartPieceState(); selectPiece =choosePieceState.getSelectPieceState(); powerCardState = turnState.getPowerCardState(); @@ -257,6 +257,9 @@ public void testInterruptToGameContinue() { //Todo send all other messages except forceContinue + //tests if the server is still in Interrupt + assertEquals(serverGameLogic.getCurrentState(),interruptState); + //sends the continue-message to the server serverGameLogic.received(forceContinueGame, from); @@ -273,7 +276,7 @@ public void testInterruptToGameReconnect() { serverGameLogic.setCurrentState(interruptState); assertEquals(serverGameLogic.getCurrentState() ,interruptState); - //todo implement the timer + //todo implement the reconnect //tests if new Stet is in GameState assertEquals(serverGameLogic.getCurrentState() ,gameState); @@ -598,7 +601,7 @@ public void testMovePieceToFirstRoll() { assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,turnState); assertEquals(turnState.getCurrentState() ,rollDiceState); - assertEquals(rollDiceState.getCurrentState() ,firstRollStateState); + assertEquals(rollDiceState.getCurrentState() ,firstRollState); } /** @@ -619,9 +622,9 @@ public void testFirstRollToRollDiceEndState() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in FirstRoll - rollDiceMachine.setCurrentState(firstRollState); - assertEquals(rollDiceMachine.getCurrentState() ,firstRollStateState); + //sends the RollDiceState in FirstRoll + rollDiceState.setCurrentState(firstRollState); + assertEquals(rollDiceState.getCurrentState() ,firstRollState); //TODO 2 Möglichkeiten @@ -650,9 +653,9 @@ public void testFirstRollToSecondRoll() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in FirstRoll - rollDiceMachine.setCurrentState(firstRollState); - assertEquals(rollDiceMachine.getCurrentState() ,firstRollStateState); + //sends the RollDiceState in FirstRoll + rollDiceState.setCurrentState(firstRollState); + assertEquals(rollDiceState.getCurrentState() ,firstRollState); //Todo player has no figures to move and had no 6 @@ -660,7 +663,7 @@ public void testFirstRollToSecondRoll() { assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,turnState); assertEquals(turnState.getCurrentState() ,rollDiceState); - assertEquals(rollDiceMachine.getCurrentState() ,secondRollState); + assertEquals(rollDiceState.getCurrentState() ,secondRollState); } /** @@ -681,9 +684,9 @@ public void testSecondRollToRollDiceEndState() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in SecondRoll - rollDiceMachine.setCurrentState(secondRoll); - assertEquals(rollDiceMachine.getCurrentState() ,secondRollState); + //sends the RollDiceState in SecondRoll + rollDiceState.setCurrentState(secondRoll); + assertEquals(rollDiceState.getCurrentState() ,secondRollState); //Todo @@ -712,9 +715,9 @@ public void testSecondRollToThirdRoll() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in SecondRoll - rollDiceMachine.setCurrentState(secondRoll); - assertEquals(rollDiceMachine.getCurrentState() ,secondRollState); + //sends the RollDiceState in SecondRoll + rollDiceState.setCurrentState(secondRoll); + assertEquals(rollDiceState.getCurrentState() ,secondRollState); //Todo player has no figures to move and had no 6 @@ -722,7 +725,7 @@ public void testSecondRollToThirdRoll() { assertEquals(serverGameLogic.getCurrentState() ,gameState); assertEquals(gameState.getCurrentState() ,turnState); assertEquals(turnState.getCurrentState() ,rollDiceState); - assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState); + assertEquals(rollDiceState.getCurrentState() ,thirdRollState); } /** @@ -743,9 +746,9 @@ public void testThirdRollToRollDiceEndState() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in ThirdRoll - rollDiceMachine.setCurrentState(thirdRoll); - assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState); + //sends the RollDiceState in ThirdRoll + rollDiceState.setCurrentState(thirdRoll); + assertEquals(rollDiceState.getCurrentState() ,thirdRollState); //Todo @@ -774,9 +777,9 @@ public void testThirdRollToTurnEndState() { turnState.setCurrentState(rollDiceState); assertEquals(turnState.getCurrentState() ,rollDiceState); - //sends the RollDiceMachine in ThirdRoll - rollDiceMachine.setCurrentState(thirdRoll); - assertEquals(rollDiceMachine.getCurrentState() ,thirdRollState); + //sends the RollDiceState in ThirdRoll + rollDiceState.setCurrentState(thirdRoll); + assertEquals(rollDiceState.getCurrentState() ,thirdRollState); //Todo }