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 0293f46d..558451cf 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 @@ -3,54 +3,47 @@ import org.junit.Before; import org.junit.Test; import pp.mdga.client.*; -import pp.mdga.client.Ceremony; -import pp.mdga.client.ceremonyState.Podium; -import pp.mdga.client.ceremonyState.Statistics; -import pp.mdga.client.dialogState.Lobby; -import pp.mdga.client.dialogState.NetworkDialog; -import pp.mdga.client.dialogState.StartDialog; +import pp.mdga.client.dialogState.*; +import pp.mdga.client.ceremonyState.*; import pp.mdga.client.gameState.*; -import pp.mdga.client.gameState.turnState.choosePieceState.*; -import pp.mdga.client.gameState.determineStartPlayer.DetermineStartPlayerStateMachine; +import pp.mdga.client.settingsState.*; import pp.mdga.client.gameState.turnState.*; -import pp.mdga.client.gameState.turnState.powerCardState.ChoosePowerCard; -import pp.mdga.client.gameState.turnState.powerCardState.Shield; -import pp.mdga.client.gameState.turnState.powerCardState.Swap; -import pp.mdga.client.Settings; -import pp.mdga.client.settingsState.AudioSettings; -import pp.mdga.client.settingsState.MainSettings; -import pp.mdga.client.settingsState.VideoSettings; +import pp.mdga.client.gameState.determineStartPlayerState.*; +import pp.mdga.client.gameState.turnState.choosePieceState.*; +import pp.mdga.client.gameState.turnState.powerCardState.*; +import pp.mdga.game.Game; +import pp.mdga.message.server.*; 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.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; /** * this test-class tests the testcases T170-T239 */ public class ClientStateTest { - //sets the variables for the states + //declare game here + private Game game; + + //declare state-machines here + + //declare states here private Animation animation; private AudioSettings audioSettings; private Ceremony ceremony; - private CeremonyStateMachine ceremonyStateMachine; private ChoosePiece choosePiece; - private ChoosePieceStateMachine choosePieceStateMachine; private ChoosePowerCard choosePowerCard; - private ClientAutomaton clientAutomaton; private ClientGameLogic clientGameLogic; private DetermineStartPlayer determineStartPlayer; - private DetermineStartPlayerStateMachine determineStartPlayerStateMachine; private Dialogs dialogs; - private DialogsStateMachine dialogsStateMachine; private GameState gameState; - private GameStateMachine gameStateMachine; private Interrupt interrupt; private Lobby lobby; private MainSettings mainSettings; @@ -60,12 +53,10 @@ public class ClientStateTest { private PlayPowerCard playPowerCard; private Podium podium; private PowerCard powerCard; - private PowerCardStateMachine powerCardStateMachine; private RollDice rollDice; private RollRankingDice rollRankingDice; private SelectPiece selectPiece; private Settings settings; - private SettingsStateMachine settingsStateMachine; private Shield shield; private Spectator spectator; private StartDialog startDialog; @@ -73,18 +64,17 @@ public class ClientStateTest { private Statistics statistics; private Swap swap; private Turn turn; - private TurnStateMachine turnStateMachine; private VideoSettings videoSettings; private Waiting waiting; private WaitingPiece waitingPiece; private WaitRanking waitRanking; - //sets the variables for the messages + //declare server-messages here private ActivePlayer activePlayer; private AnyPiece anyPiece; private Briefing briefing; private CeremonyMessage ceremonyMessage; - private Dice dice; + private Die die; private DiceAgain diceAgain; private DiceNow diceNow; private EndOfTurn endOfTurn; @@ -95,6 +85,11 @@ public class ClientStateTest { private MoveMessage moveMessage; private NoTurn noTurn; private PauseGame pauseGame; + + private PlayCard playCardSwap; + private PlayCard playCardShield; + private PlayCard playCardTurbo; + private PossibleCard possibleCard; private PossiblePiece possiblePiece; private RankingResponse rankingResponce; @@ -107,9 +102,12 @@ public class ClientStateTest { private UpdateTSK updateTSK; private WaitPiece waitPiece; - private PlayCard playCardSwap; - private PlayCard playCardShield; - private PlayCard playCardTurbo; + + + + + + private int from; private String name; @@ -118,13 +116,21 @@ public class ClientStateTest { private BonusCard shieldCard; private BonusCard turboCard; - private pp.mdga.game.Game game; + @Before public void setUp() { //initialize the game game = new pp.mdga.game.Game(); + //initialize the clientGameLogic + clientGameLogic = new ClientGameLogic(game, new ClientSender() { + @Override + public void send(ClientMessage msg) { + + } + }); + //initialize the playerID from=1234; name="Daniel"; @@ -138,7 +144,7 @@ public void setUp() { anyPiece = new AnyPiece(); briefing = new Briefing(); ceremonyMessage = new CeremonyMessage(); - dice = new Dice(6,new ArrayList<>()); + die = new Dice(6, new ArrayList<>()); diceAgain = new DiceAgain(); diceNow = new DiceNow(); endOfTurn = new EndOfTurn(); @@ -163,46 +169,41 @@ public void setUp() { updateReady = new UpdateReady(color,true); updateTSK = new UpdateTSK(name,color); waitPiece = new WaitPiece(); + interruptMessage = new Interrupt(); + - //initialize the clientGameLogic - clientGameLogic = new ClientGameLogic(game, new ClientSender() { - @Override - public void send(ClientMessage msg) { - } - }); - clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); //initialize the settings mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); - settings = new Settings(clientAutomaton,clientGameLogic); + settings = new Settings(clientGameLogic,clientGameLogic); //initialize the stateMachines - ceremonyStateMachine =ceremony.getCeremonyStateMachine(); - choosePieceStateMachine = choosePiece.getChoosePieceStateMachine(); + ceremonyState =ceremony.getCeremonyState(); + choosePieceState = choosePiece.getChoosePieceStateMachine(); determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); - dialogsStateMachine = dialogs.getDialogsStateMachine(); + dialogs = dialogs.getDialogsState(); gameStateMachine = gameState.getGameStateMachine(); powerCardStateMachine = powerCard.getPowerCardStateMachine(); settingsStateMachine = settings.getSettingsStateMachine(); - turnStateMachine = turn.getTurnStateMachine(); + turnState = turn.getTurnState(); //initialize the states - dialogs = new Dialogs(clientAutomaton,clientGameLogic); - gameState = new GameState(clientAutomaton,clientGameLogic); - ceremony = new Ceremony(clientAutomaton,clientGameLogic); - interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState); + dialogs = new Dialogs(clientGameLogic,clientGameLogic); + gameState = new GameState(clientGameLogic,clientGameLogic); + ceremony = new Ceremony(clientGameLogic,clientGameLogic); + interrupt = new Interrupt(clientGameLogic,clientGameLogic,gameState); - startDialog = new StartDialog(dialogsStateMachine,clientGameLogic); - networkDialog = new NetworkDialog(dialogsStateMachine,clientGameLogic); - lobby = new Lobby(dialogsStateMachine,clientGameLogic); + startDialog = new StartDialog(dialogs,clientGameLogic); + networkDialog = new NetworkDialog(dialogs,clientGameLogic); + lobby = new Lobby(dialogs,clientGameLogic); - podium = new Podium(ceremonyStateMachine,clientGameLogic); - statistics = new Statistics(ceremonyStateMachine,clientGameLogic); + podium = new Podium(ceremonyState,clientGameLogic); + statistics = new Statistics(ceremonyState,clientGameLogic); determineStartPlayer = new DetermineStartPlayer(gameStateMachine,clientGameLogic); waiting= new Waiting(gameStateMachine,clientGameLogic); @@ -213,20 +214,20 @@ public void send(ClientMessage msg) { rollRankingDice = new RollRankingDice(determineStartPlayerStateMachine,clientGameLogic); waitRanking = new WaitRanking(determineStartPlayerStateMachine,clientGameLogic); - powerCard = new PowerCard(turnStateMachine,clientGameLogic); - playPowerCard = new PlayPowerCard(turnStateMachine,clientGameLogic); - rollDice= new RollDice(turnStateMachine,clientGameLogic); - choosePiece = new ChoosePiece(turnStateMachine,clientGameLogic); - movePiece = new MovePiece(turnStateMachine,clientGameLogic); + powerCard = new PowerCard(turnState,clientGameLogic); + playPowerCard = new PlayPowerCard(turnState,clientGameLogic); + rollDice= new RollDice(turnState,clientGameLogic); + choosePiece = new ChoosePiece(turnState,clientGameLogic); + movePiece = new MovePiece(turnState,clientGameLogic); choosePowerCard = new ChoosePowerCard(powerCardStateMachine,clientGameLogic); shield =new Shield(powerCardStateMachine,clientGameLogic); swap = new Swap(powerCardStateMachine,clientGameLogic); - noPiece = new NoPiece(choosePieceStateMachine,clientGameLogic); - waitingPiece = new WaitingPiece(choosePieceStateMachine,clientGameLogic); - selectPiece = new SelectPiece(choosePieceStateMachine,clientGameLogic); - startPiece = new StartPiece(choosePieceStateMachine,clientGameLogic); + noPiece = new NoPiece(choosePieceState,clientGameLogic); + waitingPiece = new WaitingPiece(choosePieceState,clientGameLogic); + selectPiece = new SelectPiece(choosePieceState,clientGameLogic); + startPiece = new StartPiece(choosePieceState,clientGameLogic); } /** @@ -234,14 +235,10 @@ public void send(ClientMessage msg) { */ @Test public void testInitialStateClientState() { - //tests if the clientAutomaton is in Dialogs - assertNotEquals(clientAutomaton.getState() , null); - assertTrue(clientAutomaton.getState() instanceof Dialogs); - Dialogs dialogs = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + //tests if the clientGameLogic is in Dialogs + assertEquals(clientGameLogic.getState(),dialogs); //tests if the statemachine is in StartDialog - assertNotEquals(dialogsStateMachine1.getState(), null); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertEquals(dialogs.getState(),startDialog); } /** @@ -250,24 +247,22 @@ public void testInitialStateClientState() { @Test public void testDialogsToGame() { //tests if the client is in Dialogs - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState(),dialogs); + + //TODO //sends the startGame-Message to the client - clientGameLogic.receive(startGame); + clientGameLogic.received(startGame); //tests if the client is in the gameState after receiving the message - assertTrue(clientAutomaton.getState() instanceof GameState); + assertEquals(clientGameLogic.getState(),gameState); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); - assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + assertEquals(gameState.getState(), determineStartPlayer); //tests if the new State of DetermineStartPlayer is RollRankingDice - DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); - DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); - assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); + assertEquals(determineStartPlayer.getState() ,rollDice); } /** @@ -285,37 +280,37 @@ public void testDialogsToClientStateEndState() { @Test public void testClientGameToCeremony() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(),gameState); + + //TODO //sends the Ceremony-Message to the client - clientGameLogic.receive(ceremonyMessage); + clientGameLogic.received(ceremonyMessage); //tests if the client is in the ceremony after receiving the message - assertTrue(clientAutomaton.getState() instanceof Ceremony); + assertEquals(clientGameLogic.getState() , ceremony); //tests if the state of ceremony is Podium - Ceremony ceremony1 = (Ceremony) clientAutomaton.getState(); - CeremonyStateMachine ceremonyStateMachine1 = ceremony1.getCeremonyStateMachine(); - assertTrue(ceremonyStateMachine1.getState() instanceof Podium); + assertEquals(ceremony.getState() ,podium); } /** - * UC-ClientState-05: Test the transition from ClientGame substates to Interrupt. + * UC-ClientState-05: Test the transition from ClientGame sub-states to Interrupt. */ @Test public void testClientGameSubStatesToInterrupt() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(),gameState); - //tests if the client is in GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + //TODO //sends the Ceremony-Message to the client - clientGameLogic.receive(interrupt); + clientGameLogic.received(pauseGame); //tests if the client-automaton is in the interrupt state - assertTrue(clientAutomaton.getState() instanceof Interrupt); + assertEquals(clientGameLogic.getState() ,interrupt); } /** @@ -323,7 +318,14 @@ public void testClientGameSubStatesToInterrupt() { */ @Test public void testGameToDialogs() { - // Todo Implementation goes here + //sends the client into the GameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState(),gameState); + + //TODO + + assertEquals(clientGameLogic.getState(),dialogs); + assertEquals(dialogs.getState(), startDialog); } /** @@ -332,12 +334,12 @@ public void testGameToDialogs() { @Test public void testStayInInterrupt() { //sends the ClientAutomaton in Interrupt - clientAutomaton.gotoState(interrupt); - assertTrue(clientAutomaton.getState() instanceof Interrupt); + clientGameLogic.setState(interrupt); + assertEquals(clientGameLogic.getState(),interrupt); //Todo send all messages except the continue-message - assertTrue(clientAutomaton.getState() instanceof Interrupt); + assertEquals(clientGameLogic.getState(),interrupt); } /** @@ -346,13 +348,13 @@ public void testStayInInterrupt() { @Test public void testClientInterruptToGame() { //sends the ClientAutomaton in Interrupt - clientAutomaton.gotoState(interrupt); - assertTrue(clientAutomaton.getState() instanceof Interrupt); + clientGameLogic.setState(interrupt); + assertEquals(clientGameLogic.getState() ,interrupt); //Todo sends the continue-message //tests if the client is in the game - assertTrue(clientAutomaton.getState() instanceof GameState); + assertEquals(clientGameLogic.getState() ,gameState); } /** @@ -361,15 +363,13 @@ public void testClientInterruptToGame() { @Test public void testInterruptToDialogs() { //sends the ClientAutomaton in Interrupt - clientAutomaton.gotoState(interrupt); - assertTrue(clientAutomaton.getState() instanceof Interrupt); + clientGameLogic.setState(interrupt); + assertEquals(clientGameLogic.getState() ,interrupt); //Todo send the server-closed message and the leave option - assertTrue(clientAutomaton.getState() instanceof Dialogs); - Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine(); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,startDialog); } /** @@ -378,19 +378,17 @@ public void testInterruptToDialogs() { @Test public void testCeremonyToDialogs() { //send the client in the ceremony - clientAutomaton.gotoState(ceremony); - assertTrue(clientAutomaton.getState() instanceof Ceremony); + clientGameLogic.setState(ceremony); + assertEquals(clientGameLogic.getState() ,ceremony); //sends the ceremony machine in the statistics - ceremonyStateMachine.gotoState(statistics); - assertTrue(ceremonyStateMachine.getState() instanceof Statistics); + ceremony.setState(statistics); + assertEquals(ceremony.getState() ,statistics); //Todo simulate the button next - assertTrue(clientAutomaton.getState() instanceof Dialogs); - Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = dialogs1.getDialogsStateMachine(); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,startDialog); } /** @@ -398,18 +396,18 @@ public void testCeremonyToDialogs() { */ @Test public void testStartDialogToNetworkDialog1() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in StartDialog - dialogsStateMachine.gotoState(startDialog); - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + //sends the DialogsState in StartDialog + dialogs.setState(startDialog); + assertEquals(dialogs.getState() ,startDialog); //todo simulate pushBtn as client or host - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,networkDialog); } /** @@ -417,18 +415,18 @@ public void testStartDialogToNetworkDialog1() { */ @Test public void testStartDialogToNetworkDialog2() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in StartDialog - dialogsStateMachine.gotoState(startDialog); - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + //sends the DialogsState in StartDialog + dialogs.setState(startDialog); + assertEquals(dialogs.getState() ,startDialog); //todo simulate pushBtn as client or host - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,networkDialog); } /** @@ -445,18 +443,18 @@ public void testStartDialogToDialogsEndState() { */ @Test public void testNetworkDialogToStartDialog() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in NetworkDialog - dialogsStateMachine.gotoState(networkDialog); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + //sends the DialogsState in NetworkDialog + dialogs.setState(networkDialog); + assertEquals(dialogs.getState() ,networkDialog); //todo simulate pushBtn - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialog.getState() ,startDialog); } /** @@ -464,18 +462,18 @@ public void testNetworkDialogToStartDialog() { */ @Test public void testNetworkDialogToNetworkDialog1() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in NetworkDialog - dialogsStateMachine.gotoState(networkDialog); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + //sends the DialogsState in NetworkDialog + dialogs.setState(networkDialog); + assertEquals(dialogs.getState() ,networkDialog); //todo test receiving all messages and making input - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,networkDialog); } /** @@ -483,23 +481,23 @@ public void testNetworkDialogToNetworkDialog1() { */ @Test public void testNetworkDialogToNetworkDialog2() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in NetworkDialog - dialogsStateMachine.gotoState(networkDialog); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + //sends the DialogsState in NetworkDialog + dialogs.setState(networkDialog); + assertEquals(dialogs.getState() ,networkDialog); //todo simulate try connect to server ith wrong variables - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState(),networkDialog); - //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message + //todo simulate try connect to server with send: join-lobby and received lobby-refuse-message - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,networkDialog); } /** @@ -507,18 +505,18 @@ public void testNetworkDialogToNetworkDialog2() { */ @Test public void testNetworkDialogToLobby() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in NetworkDialog - dialogsStateMachine.gotoState(networkDialog); - assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + //sends the DialogsState in NetworkDialog + dialogs.setState(networkDialog); + assertEquals(dialogs.getState() ,networkDialog); //todo simulate connect to server with send lobby request - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof Lobby); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState(),lobby); } /** @@ -526,18 +524,18 @@ public void testNetworkDialogToLobby() { */ @Test public void testLobbyToStartDialog() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in Lobby - dialogsStateMachine.gotoState(lobby); - assertTrue(dialogsStateMachine.getState() instanceof Lobby); + //sends the DialogsState in Lobby + dialogs.setState(lobby); + assertEquals(dialogs.getState() ,lobby); //todo simulate leave the lobby - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() instanceof StartDialog); } /** @@ -545,18 +543,18 @@ public void testLobbyToStartDialog() { */ @Test public void testStayInLobby() { - // sends the clientAutomaton in StartDialog - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + // sends the clientGameLogic in StartDialog + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); - //sends the DialogsStateMachine in Lobby - dialogsStateMachine.gotoState(lobby); - assertTrue(dialogsStateMachine.getState() instanceof Lobby); + //sends the DialogsState in Lobby + dialogs.setState(lobby); + assertEquals(dialogs.getState() ,lobby); //todo send all messages that dont indicate a change-state - assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine.getState() instanceof Lobby); + assertEquals(clientGameLogic.getState() ,dialogs); + assertEquals(dialogs.getState() ,lobby); } /** @@ -565,28 +563,24 @@ public void testStayInLobby() { @Test public void testLobbyToRollRankingDice() { //sends the clientStatemachine in Dialogs - clientAutomaton.gotoState(dialogs); - assertTrue(clientAutomaton.getState() instanceof Dialogs); + clientGameLogic.setState(dialogs); + assertEquals(clientGameLogic.getState() ,dialogs); //sends the clientStatemachine in Lobby - dialogsStateMachine.gotoState(lobby); - assertTrue(dialogsStateMachine.getState() instanceof Lobby); + dialogs.setState(lobby); + assertEquals(dialogs.getState() ,lobby); //sends the message to start the game - clientGameLogic.receive();//TODO message + clientGameLogic.received();//TODO message //tests if the clientStateMachine is in the GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + assertEquals(clientGameLogic.getState() ,gameState); //tests if the clientStateMachine is in the DetermineStartPlayer - GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); - assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + assertEquals(gameState.getState() ,determineStartPlayer); //tests if the clientStateMachine is in the RollRankingDice - DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); - DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); - assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); + assertEquals(determineStartPlayer.getState() ,rollRankingDice); } /** @@ -594,7 +588,19 @@ public void testLobbyToRollRankingDice() { */ @Test public void testDetermineStartPlayerToWait() { - // Todo Implementation goes here + //sends the clientGameLogic into the gameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); + + //sends the gameState into the DetermineStartPlayer-state + gameState.setState(determineStartPlayer); + assertEquals(gameState.getState(),determineStartPlayer); + + //TODO + + //tests if the client is in the Wait-State + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameState.getState(),waiting); } /** @@ -603,35 +609,41 @@ public void testDetermineStartPlayerToWait() { @Test public void testWaitToAnimation() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the client in WaitState - gameStateMachine.gotoState(waiting); - assertTrue(gameStateMachine.getState() instanceof Waiting); + gameState.setState(waiting); + assertEquals(gameState.getState() ,waiting); + + //sends the moveMessage + clientGameLogic.received(moveMessage); //Todo ??? richtige message //tests if a piece is moved,that the client goes into Animation - clientGameLogic.receive(moveMessage); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Animation); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameState.getState() ,animation); //sends the client in WaitState - gameStateMachine.gotoState(waiting); - assertTrue(gameStateMachine.getState() instanceof Waiting); + gameState.setState(waiting); + assertEquals(gameState.getState() ,waiting); + + //sends the playTurboCard-message + clientGameLogic.received(playCardTurbo); //Todo ??? richtige message //tests if a powerCard is played,that the client goes into Animation - clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Animation); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameState.getState() ,animation); //sends the client in WaitState - gameStateMachine.gotoState(waiting); - assertTrue(gameStateMachine.getState() instanceof Waiting); + gameState.setState(waiting); + assertEquals(gameState.getState() ,waiting); + + //sends the playTurboCard-message + clientGameLogic.received(die); //Todo ??? richtige message //tests if a die is rolled,that the client goes into Animation - clientGameLogic.receive(dice); //Todo ??? richtige message - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Animation); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameState.getState() ,animation); } /** @@ -640,29 +652,27 @@ public void testWaitToAnimation() { @Test public void testWaitToTurn() { //sends client in gameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Waiting - gameStateMachine.gotoState(waiting); - assertTrue(gameStateMachine.getState() instanceof Waiting); + gameState.setState(waiting); + assertEquals(gameState.getState() ,waiting); //the client receives the message ActivePlayer - clientGameLogic.receive(activePlayer); + clientGameLogic.received(activePlayer); //tests if the client is in GameState - assertTrue(clientAutomaton.getState() instanceof GameState); + assertEquals(clientGameLogic.getState() ,gameState); //tests if Client is in Turn - assertTrue(gameStateMachine.getState() instanceof Turn); + assertEquals(gameState.getState() ,turn); //tests if Client is in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertEquals(turn.getState() ,powerCard); //tests if Client is in ChoosePowerCard - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + assertEquals(powerCard.getState() ,choosePowerCard); } /** @@ -670,7 +680,19 @@ public void testWaitToTurn() { */ @Test public void testWaitToGameEndState() { - // Implementation goes here + //sends client in gameState + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); + + //sends the gameStateMachine in the Waiting + gameState.setState(waiting); + assertEquals(gameState.getState() ,waiting); + + //Todo + + //tests if the client is in the ceremony + assertEquals(clientGameLogic.getState() ,ceremony); + assertEquals(ceremony.getState(),podium); } /** @@ -727,23 +749,23 @@ public void testPowerCardSubStatesToRollDice() { @Test public void testStayInPlayPowerCard() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - turnStateMachine.gotoState(playPowerCard); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + turnState.setState(playPowerCard); + assertEquals(turnState.getState() instanceof PlayPowerCard); //Todo send messages to test to stay in playPowerCard //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PlayPowerCard); } /** @@ -752,24 +774,24 @@ public void testStayInPlayPowerCard() { @Test public void testPlayPowerCardToRollDice() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - turnStateMachine.gotoState(playPowerCard); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + turnState.setState(playPowerCard); + assertEquals(turnState.getState() instanceof PlayPowerCard); //Todo send messages to test the transition in rollDice //Todo test other messages, that there is no state change //tests if the client is in RollDice - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof RollDice); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() ,rollDice); } /** @@ -852,27 +874,27 @@ public void testChoosePowerCardToRollDice() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - powerCardStateMachine.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); + powerCardStateMachine.setState(choosePowerCard); + assertEquals(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to rollDice - //tests if the turnStateMachine is in RollDice - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof RollDice); + //tests if the turnState is in RollDice + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() ,rollDice); } /** @@ -881,28 +903,28 @@ public void testChoosePowerCardToRollDice() { @Test public void testChoosePowerCardToSwap() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - powerCardStateMachine.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); + powerCardStateMachine.setState(choosePowerCard); + assertEquals(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to swap //tests if the client is in Swap - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine.getState() instanceof Swap); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PowerCard); + assertEquals(powerCardStateMachine.getState() instanceof Swap); } /** @@ -911,28 +933,28 @@ public void testChoosePowerCardToSwap() { @Test public void testChoosePowerCardToShield() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - powerCardStateMachine.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine.getState() instanceof ChoosePowerCard); + powerCardStateMachine.setState(choosePowerCard); + assertEquals(powerCardStateMachine.getState() instanceof ChoosePowerCard); //todo send the messages, to force a state change to shield //tests if the client is in Shield - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine.getState() instanceof Shield); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PowerCard); + assertEquals(powerCardStateMachine.getState() instanceof Shield); } /** @@ -941,28 +963,28 @@ public void testChoosePowerCardToShield() { @Test public void testStayInShield() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in Shield - powerCardStateMachine.gotoState(shield); - assertTrue(powerCardStateMachine.getState() instanceof Shield); + powerCardStateMachine.setState(shield); + assertEquals(powerCardStateMachine.getState() instanceof Shield); //todo send the messages, which dont force a statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PowerCard); + assertEquals(powerCardStateMachine.getState() instanceof PlayPowerCard); } /** @@ -971,28 +993,28 @@ public void testStayInShield() { @Test public void testShieldToPowerCardEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in Shield PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(shield); - assertTrue(powerCardStateMachine1.getState() instanceof Shield); + powerCardStateMachine1.setState(shield); + assertEquals(powerCardStateMachine1.getState() instanceof Shield); //todo send the message to force the statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PlayPowerCard); } /** @@ -1001,27 +1023,27 @@ public void testShieldToPowerCardEndState() { @Test public void testSwapToPowerCardEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - turnStateMachine.gotoState(powerCard); - assertTrue(turnStateMachine.getState() instanceof PowerCard); + turnState.setState(powerCard); + assertEquals(turnState.getState() instanceof PowerCard); //sends the turnStatemachine in Swap - powerCardStateMachine.gotoState(swap); - assertTrue(powerCardStateMachine.getState() instanceof Swap); + powerCardStateMachine.setState(swap); + assertEquals(powerCardStateMachine.getState() instanceof Swap); //todo send the message to force the statechange //tests if the client is in PlayPowerCard - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof PlayPowerCard); } /** @@ -1030,30 +1052,30 @@ public void testSwapToPowerCardEndState() { @Test public void testNoPieceInWaitingPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - turnStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + turnState.setState(noPiece); + assertEquals(choosePieceState.getState() instanceof NoPiece); //Todo test other messages, that there is no state change //sends to the clientGameLogic the message WaitPiece - clientGameLogic.receive(waitPiece); + clientGameLogic.received(waitPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() ,waitingPiece); } /** @@ -1062,30 +1084,30 @@ public void testNoPieceInWaitingPiece() { @Test public void testNoPieceInSelectedPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + choosePieceState.setState(noPiece); + assertEquals(choosePieceState.getState() instanceof NoPiece); //Todo test other messages, that there is no state change //sends to the clientGameLogic the message SelectPiece - clientGameLogic.receive(selectPiece); + clientGameLogic.received(selectPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() instanceof SelectPiece); } /** @@ -1094,30 +1116,30 @@ public void testNoPieceInSelectedPiece() { @Test public void testNoPieceInStartPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + choosePieceState.setState(noPiece); + assertEquals(choosePieceState.getState() instanceof NoPiece); //Todo test other messages, that there is no state change //sends to the clientGameLogic the message StartPiece - clientGameLogic.receive(startPiece); + clientGameLogic.received(startPiece); - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() instanceof StartPiece); } /** @@ -1126,29 +1148,29 @@ public void testNoPieceInStartPiece() { @Test public void testNoPieceInWait() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + choosePieceState.setState(noPiece); + assertEquals(choosePieceState.getState() instanceof NoPiece); //Todo test other messages, that there is no state change //sends to the clientGameLogic the message NoTurn - clientGameLogic.receive(noTurn); + clientGameLogic.received(noTurn); - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof Waiting); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() ,waiting); } /** @@ -1157,27 +1179,27 @@ public void testNoPieceInWait() { @Test public void testStayInWaitingPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - choosePieceStateMachine.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + choosePieceState.setState(waitingPiece); + assertEquals(choosePieceState.getState() ,waitingPiece); //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() ,waitingPiece); } /** @@ -1186,26 +1208,26 @@ public void testStayInWaitingPiece() { @Test public void testWaitingPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - choosePieceStateMachine.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + choosePieceState.setState(waitingPiece); + assertEquals(choosePieceState.getState() ,waitingPiece); //Todo send the message to the clientGameLogic to force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof MovePiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof MovePiece); } /** @@ -1214,27 +1236,27 @@ public void testWaitingPieceInChoosePieceEndState() { @Test public void testStayInSelectedPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece; - choosePieceStateMachine.gotoState(selectPiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + choosePieceState.setState(selectPiece); + assertEquals(choosePieceState.getState() instanceof SelectPiece); //Todo send all server messages which dont force a state change here - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() instanceof SelectPiece); } /** @@ -1243,26 +1265,26 @@ public void testStayInSelectedPiece() { @Test public void testSelectedPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece - choosePieceStateMachine.gotoState(selectPiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + choosePieceState.setState(selectPiece); + assertEquals(choosePieceState.getState() instanceof SelectPiece); //Todo send the message which force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof MovePiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof MovePiece); } /** @@ -1271,27 +1293,27 @@ public void testSelectedPieceInChoosePieceEndState() { @Test public void testStayInStartPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - choosePieceStateMachine.gotoState(startPiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + choosePieceState.setState(startPiece); + assertEquals(choosePieceState.getState() instanceof StartPiece); //todo send all messages which dont force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof ChoosePiece); + assertEquals(choosePieceState.getState() instanceof StartPiece); } /** @@ -1300,26 +1322,26 @@ public void testStayInStartPiece() { @Test public void testStartPieceToChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.gotoState(gameState); - assertTrue(clientAutomaton.getState() instanceof GameState); + clientGameLogic.setState(gameState); + assertEquals(clientGameLogic.getState() ,gameState); //sends the gameStateMachine in the Turn - gameStateMachine.gotoState(turn); - assertTrue(gameStateMachine.getState() instanceof Turn); + gameStateMachine.setState(turn); + assertEquals(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - turnStateMachine.gotoState(choosePiece); - assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + turnState.setState(choosePiece); + assertEquals(turnState.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - choosePieceStateMachine.gotoState(startPiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + choosePieceState.setState(startPiece); + assertEquals(choosePieceState.getState() instanceof StartPiece); //Todo send the message which force a state change - assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Turn); - assertTrue(turnStateMachine.getState() instanceof MovePiece); + assertEquals(clientGameLogic.getState() ,gameState); + assertEquals(gameStateMachine.getState() instanceof Turn); + assertEquals(turnState.getState() instanceof MovePiece); } /** 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 f410785c..87a9e0d4 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 @@ -1,14 +1,17 @@ package pp.mdga.server.serverState; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; import pp.mdga.game.Game; 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.ServerAutomaton; +import pp.mdga.server.automaton.ServerState; import static org.junit.Assert.*; @@ -17,39 +20,51 @@ */ public class ServerStateTest { - //Todo - private ServerGameLogic logic; + //declare game here + private Game game; + + //declare client-messages here + private ServerGameLogic serverGameLogic; private AnimationEnd animationEnd; private ClientStartGame clientStartGame; private DeselectTSK deselectTSK; private ForceContinueGame forceContinueGame; - private ForceStartGame forceStartGame; + private StartGame forceStartGame; private JoinServer joinServer; private LeaveGame leaveGame; private LobbyNotReady lobbyNotReady; private LobbyReady lobbyReady; private NoPowerCard noPowerCard; private RequestBriefing requestBriefing; - private RequestDice requestDice; + private RequestDie requestDice; private RequestMove requestMove; private RequestPlayCard requestPlayCard; private SelectCard selectCard; private SelectedPieces selectedPieces; private SelectTSK selectTSK; - private ClientMessage[] clientMessages; - //Todo + //declare state-machines here + private CeremonyState ceremonyState; + private GameState gameState; + private ServerState serverState; + //TODO: interrupt and lobby are no state-machines + + //declare states here + //TODO + + + + //Todo declare attributes to simulate a player private int from; private int fromHost; - //Todo - private GameStateMachine gameStateMachine; - private TurnStateMachine turnStateMachine; - private RollDiceMachine rollDiceMachine; - private ChoosePieceStateMachine choosePieceStateMachine; - private ServerAutomaton serverAutomaton; + //Todo declare stateMachines here + private CeremonyState gameState; + private TurnState turnState; //TODO move turnstate in automaton + private RollDiceState rollDiceMachine; //TODO move turnstate in automaton - //TODO + + //TODO declare the states here private Animation animation; private CeremonyState ceremonyState; private ChoosePieceState choosePieceState; @@ -72,84 +87,75 @@ public class ServerStateTest { private WaitingPieceState waitingPiece; /** - * TODO + * TODO initialize the states and machines and messages here */ @Before public void setUp() { - logic = new ServerGameLogic(new Game(), new ServerSender() { + game = new Game(); + + serverGameLogic = new ServerGameLogic(new ServerSender() { @Override - public void send(int id, ServerMessage msg) { + public void send(int id, ServerMessage message) { } - }); + + @Override + public void broadcast(ServerMessage message) { + + } + }, game); + animationEnd = new AnimationEnd(); clientStartGame = new ClientStartGame(); deselectTSK = new DeselectTSK(); forceContinueGame = new ForceContinueGame(); - forceStartGame = new ForceStartGame(); + forceStartGame = new StartGame(); joinServer = new JoinServer(); leaveGame = new LeaveGame(); lobbyReady = new LobbyReady(); noPowerCard = new NoPowerCard(); requestBriefing = new RequestBriefing(); - requestDice = new RequestDice(); + requestDice = new RequestDie(); requestMove = new RequestMove(); requestPlayCard = new RequestPlayCard(); - selectCard = new SelectCard(); - selectedPieces = new SelectedPieces(); - selectTSK = new SelectTSK(); - clientMessages = new ClientMessage[]{ - animationEnd, - clientStartGame, - deselectTSK, - forceContinueGame, - forceStartGame, - joinServer, - leaveGame, - lobbyReady, - noPowerCard, - requestBriefing, - requestDice, - requestMove, - requestPlayCard, - selectCard, - selectedPieces, - selectTSK - }; + selectCard = new SelectCard(BonusCard.SHIELD); //TODO + selectedPieces = new SelectedPieces("www"); //TODO + selectTSK = new SelectTSK(Color.ARMY); //TODO + from = 1234; fromHost = 2345; - choosePieceStateMachine = choosePieceState.getChoosePieceMachine(); + //initialize the state-machines here + choosePieceState = choosePieceState.getChoosePieceMachine(); rollDiceMachine = rollDiceState.getRollDicemachine(); - turnStateMachine = turnState.getTurnStatemachine(); - serverAutomaton = logic.getServerAutomaton(); - gameStateMachine = gameState.getGameStatemachine(); + turnState = turnState.getTurnStatemachine(); + gameState = gameState.getGameStatemachine(); - thirdRoll = new ThirdRollState(rollDiceMachine, logic); - secondRoll = new SecondRollState(rollDiceMachine, logic); - firstRollState = new FirstRollStateState(rollDiceMachine, logic); + thirdRoll = rollDiceState.getThridRollState(); + secondRoll = rollDiceState.getSecondRollState(); + firstRollState = rollDiceState.getThirdRollState(); - noPiece = new NoPieceState(choosePieceStateMachine, logic); - noTurnState = new NoTurnState(choosePieceStateMachine, logic); - waitingPiece = new WaitingPieceState(choosePieceStateMachine, logic); - startPiece = new StartPieceState(choosePieceStateMachine, logic); - selectPiece = new SelectPieceState(choosePieceStateMachine, logic); + noPiece = choosePieceState.getNoPieceState(); + noTurnState = choosePieceState.getNoTurnState(); + waitingPiece = choosePieceState.getWaitingPieceState(); + startPiece = choosePieceState.getStartPieceState(); + selectPiece =choosePieceState.getSelectPieceState(); - powerCardState = new PowerCardState(turnStateMachine, logic); - playPowerCard = new PlayPowerCard(turnStateMachine, logic); - rollDiceState = new RollDiceState(turnStateMachine, logic); - choosePieceState = new ChoosePieceState(turnStateMachine, logic); - movePieceState = new MovePieceState(turnStateMachine, logic); + powerCardState = turnState.getPowerCardState(); + playPowerCard = turnState.getPlayPowerCardState(); + rollDiceState = turnState.getRollDiceState(); + choosePieceState = turnState.getChoosePieceState(); + movePieceState = turnState.getMovePieceState(); - determineStartPlayerState = new DetermineStartPlayerState(gameStateMachine, logic); - turnState = new TurnState(gameStateMachine, logic); - animation = new Animation(gameStateMachine, logic); + determineStartPlayerState = gameState.getDetermineStartPlayerState(); + turnState = gameState.getTurnState(); + animation = gameState.getAnimationState(); - lobbyState = new LobbyState(serverAutomaton, logic); - gameState = new GameState(serverAutomaton, logic); - ceremonyState = new CeremonyState(serverAutomaton, logic); - interruptState = new InterruptState(serverAutomaton, logic, gameState); + lobbyState = (LobbyState) serverGameLogic.getLobbyState(); + gameState = (GameState) serverGameLogic.getGameState(); + ceremonyState = (CeremonyState) serverGameLogic.getCeremonyState(); + interruptState = (InterruptState) serverGameLogic.getInterruptState(); } /** @@ -157,7 +163,7 @@ public void send(int id, ServerMessage msg) { */ @Test public void testInitialStateServerState() { - assertTrue(serverAutomaton.getState() instanceof LobbyState); + assertEquals(serverGameLogic.getCurrentState(),lobbyState); } /** @@ -167,17 +173,20 @@ public void testInitialStateServerState() { @Test public void testLobbyToDetermineStartPlayer() { //sends the server in the lobby-state - serverAutomaton.gotoState(lobbyState); - assertTrue(serverAutomaton.getState() instanceof LobbyState); + serverGameLogic.setCurrentState(lobbyState); + assertEquals(serverGameLogic.getCurrentState(),lobbyState); - //sends the startGame message from the Host to the server - logic.received(clientStartGame, from); + //Todo send all other messages, which dont indicate a state change - //tests if the server iss in DSP-state - assertTrue(serverAutomaton.getState() instanceof GameState); - GameState gameState1 = (GameState) serverAutomaton.getState();//Todo erzeuge state - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayerState); + //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); + + //tests if the server is in DSP-state + assertEquals(serverGameLogic.getCurrentState(),gameState); + assertEquals(gameState.getCurrentState(),determineStartPlayerState); } /** @@ -186,29 +195,29 @@ public void testLobbyToDetermineStartPlayer() { @Test public void testStayInLobby() { //sends the server in the lobby-state - serverAutomaton.gotoState(lobbyState); - assertTrue(serverAutomaton.getState() instanceof LobbyState); + serverGameLogic.setCurrentState(lobbyState); + assertEquals(serverGameLogic.getCurrentState(),lobbyState); - //TODO logic gets all messages - logic.received(animationEnd, from); - logic.received(clientStartGame, from); - logic.received(deselectTSK, from); - logic.received(forceContinueGame, from); - logic.received(forceStartGame, from); - logic.received(joinServer, from); - logic.received(leaveGame, from); - logic.received(lobbyReady, from); - logic.received(noPowerCard, from); - logic.received(requestBriefing, from); - logic.received(requestDice, from); - logic.received(requestMove, from); - logic.received(requestPlayCard, from); - logic.received(selectCard, from); - logic.received(selectedPieces, from); - logic.received(selectTSK, from); + //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); //tests if Server is still in Lobby - assertTrue(serverAutomaton.getState() instanceof LobbyState); + assertEquals(serverGameLogic.getCurrentState(),lobbyState); } /** @@ -217,13 +226,13 @@ public void testStayInLobby() { @Test public void testServerGameSubStatesToInterrupt() { //sends the server in the gameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); //TODO könnte auch auf gleichheit prüfen + serverGameLogic.setCurrentState(gameState); + assertEquals(serverGameLogic.getCurrentState(),gameState); //TODO create interrupt //tests if the server is in the Interrupt-state - assertTrue(serverAutomaton.getState() instanceof InterruptState); + assertEquals(serverGameLogic.getInterruptState(),interruptState); } /** @@ -232,13 +241,13 @@ public void testServerGameSubStatesToInterrupt() { @Test public void testServerGameToCeremony() { //sends the server in the gameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //Todo game is finished //tests if the server is in the Ceremony-state - assertTrue(serverAutomaton.getState() instanceof CeremonyState); + assertTrue(serverGameLogic.getCurrentState() instanceof CeremonyState); } /** @@ -247,14 +256,14 @@ public void testServerGameToCeremony() { @Test public void testInterruptToGameContinue() { //sends the server in the Interrupt-State - serverAutomaton.gotoState(interruptState); - assertTrue(serverAutomaton.getState() instanceof InterruptState); + serverGameLogic.setCurrentState(interruptState); + assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState); //sends the continue-message to the server - logic.received(forceContinueGame, from); + serverGameLogic.received(forceContinueGame, from); //tests if new Stet is in GameState - assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); } /** @@ -263,13 +272,13 @@ public void testInterruptToGameContinue() { @Test public void testInterruptToGameReconnect() { //sends the server in the Interrupt-State - serverAutomaton.gotoState(interruptState); - assertTrue(serverAutomaton.getState() instanceof InterruptState); + serverGameLogic.setCurrentState(interruptState); + assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState); //todo implement the timer //tests if new Stet is in GameState - assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); } /** @@ -278,13 +287,13 @@ public void testInterruptToGameReconnect() { @Test public void testInterruptToGameTimer() { //sends the server in the Interrupt-State - serverAutomaton.gotoState(interruptState); - assertTrue(serverAutomaton.getState() instanceof InterruptState); + serverGameLogic.setCurrentState(interruptState); + assertTrue(serverGameLogic.getCurrentState() instanceof InterruptState); //Todo implement the timer //tests if new Stet is in GameState - assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); } /** @@ -292,7 +301,7 @@ public void testInterruptToGameTimer() { */ @Test public void testCeremonyToServerStateEndState() { - // TODO: Implement test logic for transition from Ceremony to Server State End State + // TODO: Implement test serverGameLogic for transition from Ceremony to Server State End State // TODO how???? } @@ -302,18 +311,18 @@ public void testCeremonyToServerStateEndState() { @Test public void testDetermineStartPlayerToDetermineStartPlayer1() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in DSP-state - gameStateMachine.gotoState(determineStartPlayerState); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + //sends the gameState in DSP-state + gameState.setCurrentState(determineStartPlayerState); + assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState); //TODO sends messages to the server //tests if the server is still in DSP-state - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState); } /** @@ -322,18 +331,18 @@ public void testDetermineStartPlayerToDetermineStartPlayer1() { @Test public void testDetermineStartPlayerToDetermineStartPlayer2() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in DSP-state - gameStateMachine.gotoState(determineStartPlayerState); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + //sends the gameState in DSP-state + gameState.setCurrentState(determineStartPlayerState); + assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState); //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 DetermineStartPlayerState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState); } /** @@ -342,18 +351,18 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() { @Test public void testDetermineStartPlayerToAnimation() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in DSP-state - gameStateMachine.gotoState(determineStartPlayerState); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayerState); + //sends the gameState in DSP-state + gameState.setCurrentState(determineStartPlayerState); + assertTrue(gameState.getCurrentState() instanceof DetermineStartPlayerState); //TODO sends messages 2 RequestDiceMessage, die ungleich geränkt werden, sodass der server weitergeht //tests if the Server is in animationState - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof Animation); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof Animation); } /** @@ -363,27 +372,27 @@ public void testDetermineStartPlayerToAnimation() { @Test public void testAnimationToPowerCard() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Animation - gameStateMachine.gotoState(animation); - assertTrue(gameStateMachine.getState() instanceof Animation); + //sends the gameState in Animation + gameState.setCurrentState(animation); + assertTrue(gameState.getCurrentState() instanceof Animation); //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); + serverGameLogic.received(animationEnd, fromHost); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof Animation); //receives another animation endMessage - logic.received(animationEnd, from); + serverGameLogic.received(animationEnd, from); //tests if the server is in the PowerCard-state - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - TurnState turnState1 = (TurnState) gameStateMachine.getState(); - TurnStateMachine turnStateMachine = (TurnStateMachine) turnState1.getTurnStateMachine(); - assertTrue(turnStateMachine.getState() instanceof PowerCardState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + TurnState turnState1 = (TurnState) gameState.getCurrentState(); + TurnState turnState = (TurnState) turnState1.getTurnState(); + assertTrue(turnState.getCurrentState() instanceof PowerCardState); } /** @@ -393,18 +402,18 @@ public void testAnimationToPowerCard() { @Test public void testTurnToAnimation() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //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); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof Animation); } /** @@ -414,17 +423,17 @@ public void testTurnToAnimation() { @Test public void testTurnToGameEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //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 CeremonyState); + assertTrue(serverGameLogic.getCurrentState() instanceof CeremonyState); } /** @@ -434,23 +443,23 @@ public void testTurnToGameEndState() { @Test public void testStayInPowerCard() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in PowerCard - turnStateMachine.gotoState(powerCardState); - assertTrue(turnStateMachine.getState() instanceof PowerCardState); + //sends the TurnState in PowerCard + turnState.setCurrentState(powerCardState); + assertTrue(turnState.getCurrentState() instanceof PowerCardState); //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 TurnState); - assertTrue(turnStateMachine.getState() instanceof PowerCardState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof PowerCardState); } /** @@ -460,23 +469,23 @@ public void testStayInPowerCard() { @Test public void testPowerCardToPlayPowerCard() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in PowerCard - turnStateMachine.gotoState(powerCardState); - assertTrue(turnStateMachine.getState() instanceof PowerCardState); + //sends the TurnState in PowerCard + turnState.setCurrentState(powerCardState); + assertTrue(turnState.getCurrentState() instanceof PowerCardState); //todo //tests if the server is in PlayPowerCard - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof PlayPowerCard); } /** @@ -486,33 +495,33 @@ public void testPowerCardToPlayPowerCard() { @Test public void testPlayPowerCardToRollDice() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in PowerCard - turnStateMachine.gotoState(playPowerCard); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + //sends the TurnState in PowerCard + turnState.setCurrentState(playPowerCard); + assertTrue(turnState.getCurrentState() instanceof PlayPowerCard); //receive first AnimationEndMessage from the host - logic.received(animationEnd, fromHost); - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + serverGameLogic.received(animationEnd, fromHost); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof PlayPowerCard); //receive second AnimationEndMessage - logic.received(animationEnd, from); + serverGameLogic.received(animationEnd, from); //tests if the server is in RollDice and in FirstRoll - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); - RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState(); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); + RollDiceState rollDiceState = (RollDiceState) turnState.getCurrentState(); RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine(); - assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState); + assertTrue(rollDiceMachine1.getCurrentState() instanceof FirstRollStateState); } /** @@ -522,22 +531,22 @@ public void testPlayPowerCardToRollDice() { @Test public void testChoosePieceToMovePiece() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + //sends the TurnState in ChoosePiece + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //Todo ??? - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof MovePieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof MovePieceState); } /** @@ -547,16 +556,16 @@ public void testChoosePieceToMovePiece() { @Test public void testMovePieceToTurnEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in MovePiece - turnStateMachine.gotoState(movePieceState); - assertTrue(turnStateMachine.getState() instanceof MovePieceState); + //sends the TurnState in MovePiece + turnState.setCurrentState(movePieceState); + assertTrue(turnState.getCurrentState() instanceof MovePieceState); //Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game //TODO @@ -570,25 +579,25 @@ public void testMovePieceToTurnEndState() { @Test public void testMovePieceToFirstRoll() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in MovePiece - turnStateMachine.gotoState(movePieceState); - assertTrue(turnStateMachine.getState() instanceof MovePieceState); + //sends the TurnState in MovePiece + turnState.setCurrentState(movePieceState); + assertTrue(turnState.getCurrentState() instanceof MovePieceState); //Todo the player rolled a 6 and the player is not finished - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); - RollDiceState rollDiceState = (RollDiceState) turnStateMachine.getState(); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); + RollDiceState rollDiceState = (RollDiceState) turnState.getCurrentState(); RollDiceMachine rollDiceMachine1 = rollDiceState.getRollDiceStateMachine(); - assertTrue(rollDiceMachine1.getState() instanceof FirstRollStateState); + assertTrue(rollDiceMachine1.getCurrentState() instanceof FirstRollStateState); } /** @@ -598,30 +607,30 @@ public void testMovePieceToFirstRoll() { @Test public void testFirstRollToRollDiceEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in FirstRoll - rollDiceMachine.gotoState(firstRollState); - assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState); + rollDiceMachine.setCurrentState(firstRollState); + assertTrue(rollDiceMachine.getCurrentState() instanceof FirstRollStateState); //TODO 2 Möglichkeiten //tests if the server is in NoPiece of ChoosePiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); - ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState(); + ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); } /** @@ -631,28 +640,28 @@ public void testFirstRollToRollDiceEndState() { @Test public void testFirstRollToSecondRoll() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in FirstRoll - rollDiceMachine.gotoState(firstRollState); - assertTrue(rollDiceMachine.getState() instanceof FirstRollStateState); + rollDiceMachine.setCurrentState(firstRollState); + assertTrue(rollDiceMachine.getCurrentState() instanceof FirstRollStateState); //Todo player has no figures to move and had no 6 //tests if the server is in the SecondRoll - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); - assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); + assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState); } /** @@ -662,30 +671,30 @@ public void testFirstRollToSecondRoll() { @Test public void testSecondRollToRollDiceEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in SecondRoll - rollDiceMachine.gotoState(secondRoll); - assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + rollDiceMachine.setCurrentState(secondRoll); + assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState); //Todo //tests if the server is in NoPiece of ChoosePiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); - ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState(); + ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); } /** @@ -695,28 +704,28 @@ public void testSecondRollToRollDiceEndState() { @Test public void testSecondRollToThirdRoll() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in SecondRoll - rollDiceMachine.gotoState(secondRoll); - assertTrue(rollDiceMachine.getState() instanceof SecondRollState); + rollDiceMachine.setCurrentState(secondRoll); + assertTrue(rollDiceMachine.getCurrentState() instanceof SecondRollState); //Todo player has no figures to move and had no 6 //tests if the server is in the ThirdRoll - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); - assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); + assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState); } /** @@ -726,30 +735,30 @@ public void testSecondRollToThirdRoll() { @Test public void testThirdRollToRollDiceEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in ThirdRoll - rollDiceMachine.gotoState(thirdRoll); - assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + rollDiceMachine.setCurrentState(thirdRoll); + assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState); //Todo //tests if the server is in NoPiece of ChoosePiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - ChoosePieceState choosePieceState1 = (ChoosePieceState) turnStateMachine.getState(); - ChoosePieceStateMachine choosePieceStateMachine = choosePieceState1.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + ChoosePieceState choosePieceState1 = (ChoosePieceState) turnState.getCurrentState(); + ChoosePieceStateMachine choosePieceState = choosePieceState1.getChoosePieceStateMachine(); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); } /** @@ -759,20 +768,20 @@ public void testThirdRollToRollDiceEndState() { @Test public void testThirdRollToTurnEndState() { //sends the server in Game-State - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); - //sends the gameStateMachine in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + //sends the gameState in Turn + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); - //sends the TurnStateMachine in RollDice - turnStateMachine.gotoState(rollDiceState); - assertTrue(turnStateMachine.getState() instanceof RollDiceState); + //sends the TurnState in RollDice + turnState.setCurrentState(rollDiceState); + assertTrue(turnState.getCurrentState() instanceof RollDiceState); //sends the RollDiceMachine in ThirdRoll - rollDiceMachine.gotoState(thirdRoll); - assertTrue(rollDiceMachine.getState() instanceof ThirdRollState); + rollDiceMachine.setCurrentState(thirdRoll); + assertTrue(rollDiceMachine.getCurrentState() instanceof ThirdRollState); //Todo } @@ -784,28 +793,28 @@ public void testThirdRollToTurnEndState() { @Test public void testNoPieceToWaitingPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + choosePieceState.setCurrentState(noPiece); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); //TODO //tests if the server is in WaitingPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState); } @@ -816,28 +825,28 @@ public void testNoPieceToWaitingPiece() { @Test public void testNoPieceToNoTurn() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + choosePieceState.setCurrentState(noPiece); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); //TODO //tests if the server is in NoTurn - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof NoTurnState); } /** @@ -847,20 +856,20 @@ public void testNoPieceToNoTurn() { @Test public void testNoTurnToTurnEndState() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in NoTurn - choosePieceStateMachine.gotoState(noTurnState); - assertTrue(choosePieceStateMachine.getState() instanceof NoTurnState); + choosePieceState.setCurrentState(noTurnState); + assertTrue(choosePieceState.getCurrentState() instanceof NoTurnState); //TODO } @@ -872,28 +881,28 @@ public void testNoTurnToTurnEndState() { @Test public void testStayInWaitingPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in WaitingPiece - choosePieceStateMachine.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + choosePieceState.setCurrentState(waitingPiece); + assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState); //TODO //tests if the server is in WaitingPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState); } /** @@ -903,20 +912,20 @@ public void testStayInWaitingPiece() { @Test public void testWaitingPieceToMovePiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in WaitingPiece - choosePieceStateMachine.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine.getState() instanceof WaitingPieceState); + choosePieceState.setCurrentState(waitingPiece); + assertTrue(choosePieceState.getCurrentState() instanceof WaitingPieceState); //TODO } @@ -928,28 +937,28 @@ public void testWaitingPieceToMovePiece() { @Test public void testNoPieceToSelectPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + choosePieceState.setCurrentState(noPiece); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); //TODO //tests if the server is in SelectPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState); } /** @@ -959,28 +968,28 @@ public void testNoPieceToSelectPiece() { @Test public void testNoPieceToStartPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in NoPiece - choosePieceStateMachine.gotoState(noPiece); - assertTrue(choosePieceStateMachine.getState() instanceof NoPieceState); + choosePieceState.setCurrentState(noPiece); + assertTrue(choosePieceState.getCurrentState() instanceof NoPieceState); //TODO //tests if the server is in StartPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState); } /** @@ -990,28 +999,28 @@ public void testNoPieceToStartPiece() { @Test public void testStayInSelectPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in SelectPiece - choosePieceStateMachine.gotoState(selectPiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + choosePieceState.setCurrentState(selectPiece); + assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState); //TODO //tests if the server is in SelectPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState); } /** @@ -1021,20 +1030,20 @@ public void testStayInSelectPiece() { @Test public void testSelectPieceToMovePiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in SelectPiece - choosePieceStateMachine.gotoState(selectPiece); - assertTrue(choosePieceStateMachine.getState() instanceof SelectPieceState); + choosePieceState.setCurrentState(selectPiece); + assertTrue(choosePieceState.getCurrentState() instanceof SelectPieceState); //TODO } @@ -1046,28 +1055,28 @@ public void testSelectPieceToMovePiece() { @Test public void testStayInStartPiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in StartPiece - choosePieceStateMachine.gotoState(startPiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + choosePieceState.setCurrentState(startPiece); + assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState); //TODO //tests if the server is in StartPiece - assertTrue(serverAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine.getState() instanceof TurnState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); - assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); + assertTrue(gameState.getCurrentState() instanceof TurnState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); + assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState); } /** @@ -1077,20 +1086,20 @@ public void testStayInStartPiece() { @Test public void testStartPieceToMovePiece() { //sends the server in GameState - serverAutomaton.gotoState(gameState); - assertTrue(serverAutomaton.getState() instanceof GameState); + serverGameLogic.setCurrentState(gameState); + assertTrue(serverGameLogic.getCurrentState() instanceof GameState); //sends the server in Turn - gameStateMachine.gotoState(turnState); - assertTrue(gameStateMachine.getState() instanceof TurnState); + gameState.setCurrentState(turnState); + assertTrue(gameState.getCurrentState() instanceof TurnState); //sends the server in ChoosePiece - turnStateMachine.gotoState(choosePieceState); - assertTrue(turnStateMachine.getState() instanceof ChoosePieceState); + turnState.setCurrentState(choosePieceState); + assertTrue(turnState.getCurrentState() instanceof ChoosePieceState); //sends the server in StartPiece - choosePieceStateMachine.gotoState(startPiece); - assertTrue(choosePieceStateMachine.getState() instanceof StartPieceState); + choosePieceState.setCurrentState(startPiece); + assertTrue(choosePieceState.getCurrentState() instanceof StartPieceState); //TODO }