diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java new file mode 100644 index 00000000..b9dfba4c --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java @@ -0,0 +1,44 @@ +package pp.mdga.client; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T066-T071 + */ +public class ClientTest { + @Before + public void Setup() { + + } + + @Test + public void testClientTerminatesConnection() { + + } + + @Test + public void testClientConnects() { + + } + + @Test + public void testClientCantConnect() { + + } + + @Test + public void testClientReconnect() { + + } + + @Test + public void testClientDoesntReconnect() { + + } + + @Test + public void testClientDisconnects() { + + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java new file mode 100644 index 00000000..fba98391 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java @@ -0,0 +1,88 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T084-T095 + */ +public class LobbyTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Lobby actions. + } + + // UC-Lobby-01 + @Test + public void testSelectTSK() { + // TODO: Implement test logic for selecting a task (TSK) + } + + // UC-Lobby-02 + @Test + public void testDeselectTSK() { + // TODO: Implement test logic for deselecting a previously selected task (TSK) + } + + // UC-Lobby-03 + @Test + public void testChangeTSK() { + // TODO: Implement test logic for changing a selected task (TSK) + } + + // UC-Lobby-04 + @Test + public void testReady() { + // TODO: Implement test logic for setting the player status to "ready" + } + + // UC-Lobby-05 + @Test + public void testNotReady() { + // TODO: Implement test logic for setting the player status to "not ready" + } + + // UC-Lobby-06 + @Test + public void testLeaveLobby() { + // TODO: Implement test logic for a player leaving the lobby + } + + // UC-Lobby-07 + @Test + public void testStartGame() { + // TODO: Implement test logic for starting the game + } + + // UC-Lobby-08 + @Test + public void testShowStatus() { + // TODO: Implement test logic for showing the status of all players (ready/not ready) + } + + // UC-Lobby-09 + @Test + public void testShowNames() { + // TODO: Implement test logic for showing the names of all players in the lobby + } + + // UC-Lobby-10 + @Test + public void testShowAvailableTSKs() { + // TODO: Implement test logic for displaying the list of available tasks (TSKs) + } + + // UC-Lobby-11 + @Test + public void testShowAssignedTSKs() { + // TODO: Implement test logic for showing the tasks assigned to players + } + + // UC-Lobby-12 + @Test + public void testServerAssignsTSK() { + // TODO: Implement test logic for server-side assignment of tasks (TSKs) to players + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java new file mode 100644 index 00000000..53e42e3c --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java @@ -0,0 +1,45 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T079-T083 + */ +public class NetworkDialogClientTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Network Dialog Client actions. + } + + // UC-NetworkDialogClient-01 + @Test + public void testEnterIP() { + // TODO: Implement test logic for entering an IP address + } + + // UC-NetworkDialogClient-02 + @Test + public void testEnterPort() { + // TODO: Implement test logic for entering a port number + } + + // UC-NetworkDialogClient-03 + @Test + public void testConnectToServer() { + // TODO: Implement test logic for attempting to connect to a server + } + + @Test + public void testCantConnectToServer() { + // TODO: Implement test logic for handling failed server connection attempts + } + + // UC-NetworkDialogClient-04 + @Test + public void testCancelJoining() { + // TODO: Implement test logic for canceling the joining process + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java new file mode 100644 index 00000000..71b7198d --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java @@ -0,0 +1,35 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T076-T078 + */ +public class NetworkDialogHostTest { + + @Before + public void setUp() { + // This method will be executed before each test. + } + + // UC-NetworkDialogHost-01 + @Test + public void testSpecifyPort() { + // TODO: Implement test logic for specifying a port + } + + // UC-NetworkDialogHost-02 + @Test + public void testCreateServer() { + // TODO: Implement test logic for creating a server + // Example: Check that the server is created successfully and starts listening on the specified port. + } + + // UC-NetworkDialogHost-03 + @Test + public void testCancelServer() { + // TODO: Implement test logic for canceling server creation + // Example: Verify that the server creation process is canceled properly without starting a server. + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java new file mode 100644 index 00000000..f1d88ac3 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java @@ -0,0 +1,39 @@ +package pp.mdga.client.Dialog; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T072-T075 + */ +public class StartDialogTest { + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Start Dialog actions. + } + + // UC-StartDialog-01 + @Test + public void testEnterName() { + // TODO: Implement test logic for entering a player name + } + + // UC-StartDialog-02 + @Test + public void testJoinServer() { + // TODO: Implement test logic for joining a game server + } + + // UC-StartDialog-03 + @Test + public void testHostServer() { + // TODO: Implement test logic for hosting a server + } + + // UC-StartDialog-04 + @Test + public void testExitGame() { + // TODO: Implement test logic for exiting the game + } +} 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 new file mode 100644 index 00000000..468f87b7 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -0,0 +1,1416 @@ +package pp.mdga.client.clientState; + +import org.junit.Before; +import org.junit.Test; +import pp.mdga.client.*; +import pp.mdga.client.Ceremony; +import pp.mdga.client.StartPiece; +import pp.mdga.game.BonusCard; +import pp.mdga.game.Color; +import pp.mdga.game.Game; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.server.*; + +import java.util.ArrayList; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +/** + * this test-class tests the testcases T170-T239 + */ +public class ClientStateTest { + + //sets the variables for the states + 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; + private MovePiece movePiece; + private NetworkDialog networkDialog; + private NoPiece noPiece; + 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; + private StartPiece startPiece; + 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 + private ActivePlayer activePlayer; + private AnyPiece anyPiece; + private Briefing briefing; + private CeremonyMessage ceremonyMessage; + private Dice dice; + private DiceAgain diceAgain; + private DiceNow diceNow; + private EndOfTurn endOfTurn; + private LobbyAccept lobbyAccept; + private LobbyDeny lobbyDeny; + private LobbyPlayerJoin lobbyPlayerJoin; + private LobbyPlayerLeave lobbyPlayerLeave; + private MoveMessage moveMessage; + private NoTurn noTurn; + private PauseGame pauseGame; + private PossibleCard possibleCard; + private PossiblePiece possiblePiece; + private RankingResponse rankingResponce; + private RankingRollAgain rankingRollAgain; + private ReconnectBriefing reconnectBriefing; + private ResumeGame resumeGame; + private ServerStartGame startGame; + private StartPiece startPieceMessage; + private UpdateReady updateReady; + private UpdateTSK updateTSK; + private WaitPiece waitPiece; + + private PlayCard playCardSwap; + private PlayCard playCardShield; + private PlayCard playCardTurbo; + + private int from; + private String name; + private Color color; + private BonusCard swapCard; + private BonusCard shieldCard; + private BonusCard turboCard; + + private Game game; + + @Before + public void setUp() { + //initialize the game + game = new Game(); + + //initialize the playerID + from=1234; + name="Daniel"; + color=Color.ARMY; + swapCard = BonusCard.SWAP; + shieldCard = BonusCard.SHIELD; + turboCard = BonusCard.TURBO; + + //initialize the messages from the server + activePlayer = new ActivePlayer(color); + anyPiece = new AnyPiece(); + briefing = new Briefing(); + ceremonyMessage = new CeremonyMessage(); + dice = new Dice(6,new ArrayList<>()); + diceAgain = new DiceAgain(); + diceNow = new DiceNow(); + endOfTurn = new EndOfTurn(); + lobbyAccept = new LobbyAccept(); + lobbyDeny = new LobbyDeny(); + lobbyPlayerJoin = new LobbyPlayerJoin(name); + lobbyPlayerLeave = new LobbyPlayerLeave(name,color); + moveMessage = new MoveMessage("www");//Todo + noTurn = new NoTurn(); + pauseGame = new PauseGame(); + playCardSwap = new PlayCard(swapCard,"www");//Todo + playCardShield = new PlayCard(shieldCard,"www");//Todo + playCardTurbo = new PlayCard(turboCard,"www");//Todo + possibleCard = new PossibleCard(); + possiblePiece = new PossiblePiece(); + rankingResponce = new RankingResponse(); + rankingRollAgain = new RankingRollAgain(); + reconnectBriefing = new ReconnectBriefing(game); + resumeGame = new ResumeGame(); + startGame = new ServerStartGame(); + startPieceMessage = new StartPiece(); //Todo wrong class + updateReady = new UpdateReady(color,true); + updateTSK = new UpdateTSK(name,color); + waitPiece = new WaitPiece(); + + //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); + + + //initialize the stateMachines + ceremonyStateMachine =ceremony.getCeremonyStateMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceStateMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); + dialogsStateMachine = dialogs.getDialogsStateMachine(); + gameStateMachine = gameState.getGameStateMachine(); + powerCardStateMachine = powerCard.getPowerCardStateMachine(); + settingsStateMachine = settings.getSettingsStateMachine(); + turnStateMachine = turn.getTurnStateMachine(); + + + //initialize the states + dialogs = new Dialogs(clientAutomaton,clientGameLogic); + gameState = new GameState(clientAutomaton,clientGameLogic); + ceremony = new Ceremony(clientAutomaton,clientGameLogic); + interrupt = new Interrupt(clientAutomaton,clientGameLogic,gameState); + + startDialog = new StartDialog(dialogsStateMachine,clientGameLogic); + networkDialog = new NetworkDialog(dialogsStateMachine,clientGameLogic); + lobby = new Lobby(dialogsStateMachine,clientGameLogic); + + podium = new Podium(ceremonyStateMachine,clientGameLogic); + statistics = new Statistics(ceremonyStateMachine,clientGameLogic); + + determineStartPlayer = new DetermineStartPlayer(gameStateMachine,clientGameLogic); + waiting= new Waiting(gameStateMachine,clientGameLogic); + animation = new Animation(gameStateMachine,clientGameLogic); + turn = new Turn(gameStateMachine,clientGameLogic); + spectator = new Spectator(gameStateMachine,clientGameLogic); + + 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); + + 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); + } + + /** + * UC-ClientState-01: Test the initial state of the ClientState. + */ + @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 statemachine is in StartDialog + assertNotEquals(dialogsStateMachine1.getState(), null); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-02: Test the transition from dialogs to the game state. + */ + @Test + public void testDialogsToGame() { + //tests if the client is in Dialogs + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the startGame-Message to the client + clientGameLogic.receive(startGame); + + //tests if the client is in the gameState after receiving the message + assertTrue(clientAutomaton.getState() instanceof 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); + + //tests if the new State of DetermineStartPlayer is RollRankingDice + DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); + } + + /** + * UC-ClientState-03: Test the transition from dialogs to the end state of ClientState . + */ + @Test + public void testDialogsToClientStateEndState() { + //Todo Implementation goes here + //TODO how????????? + } + + /** + * UC-ClientState-04: Test the transition from ClientGame to Ceremony. + */ + @Test + public void testClientGameToCeremony() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the Ceremony-Message to the client + clientGameLogic.receive(ceremonyMessage); + + //tests if the client is in the ceremony after receiving the message + assertTrue(clientAutomaton.getState() instanceof Ceremony); + + //tests if the state of ceremony is Podium + Ceremony ceremony1 = (Ceremony) clientAutomaton.getState(); + CeremonyStateMachine ceremonyStateMachine1 = ceremony1.getCeremonyStateMachine(); + assertTrue(ceremonyStateMachine1.getState() instanceof Podium); + } + + /** + * UC-ClientState-05: Test the transition from ClientGame substates to Interrupt. + */ + @Test + public void testClientGameSubStatesToInterrupt() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the Ceremony-Message to the client + clientGameLogic.receive(interrupt); + + //tests if the client-automaton is in the interrupt state + assertTrue(clientAutomaton.getState() instanceof Interrupt); + } + + /** + * UC-ClientState-06: Test the transition from the game state to dialogs. + */ + @Test + public void testGameToDialogs() { + // Todo Implementation goes here + } + + /** + * UC-ClientState-07: Test remaining in the Interrupt state. + */ + @Test + public void testStayInInterrupt() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo send all messages except the continue-message + + assertTrue(clientAutomaton.getState() instanceof Interrupt); + } + + /** + * UC-ClientState-08: Test the transition from ClientInterrupt to the game state. + */ + @Test + public void testClientInterruptToGame() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo sends the continue-message + + //tests if the client is in the game + assertTrue(clientAutomaton.getState() instanceof GameState); + } + + /** + * UC-ClientState-09: Test the transition from Interrupt to dialogs. + */ + @Test + public void testInterruptToDialogs() { + //sends the ClientAutomaton in Interrupt + clientAutomaton.gotoState(interrupt); + assertTrue(clientAutomaton.getState() instanceof 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); + } + + /** + * UC-ClientState-10: Test the transition from Ceremony to dialogs. + */ + @Test + public void testCeremonyToDialogs() { + //send the client in the ceremony + clientAutomaton.gotoState(ceremony); + assertTrue(clientAutomaton.getState() instanceof Ceremony); + + //sends the ceremony machine in the statistics + ceremonyStateMachine.gotoState(statistics); + assertTrue(ceremonyStateMachine.getState() instanceof 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); + } + + /** + * UC-ClientState-11: Test the transition from StartDialog to NetworkDialog1. + */ + @Test + public void testStartDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-12: Test the transition from StartDialog to NetworkDialog2. + */ + @Test + public void testStartDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-13: Test the transition from StartDialog to the dialogs end state. + */ + @Test + public void testStartDialogToDialogsEndState() { + // Implementation goes here + //TODO how to test? + } + + /** + * UC-ClientState-14: Test the transition from NetworkDialog to StartDialog. + */ + @Test + public void testNetworkDialogToStartDialog() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate pushBtn + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-15: Test the transition from NetworkDialog to NetworkDialog1. + */ + @Test + public void testNetworkDialogToNetworkDialog1() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo test receiving all messages and making input + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-16: Test the transition from NetworkDialog to NetworkDialog2. + */ + @Test + public void testNetworkDialogToNetworkDialog2() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate try connect to server ith wrong variables + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + } + + /** + * UC-ClientState-17: Test the transition from NetworkDialog to Lobby. + */ + @Test + public void testNetworkDialogToLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); + + //todo simulate connect to server with send lobby request + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + } + + /** + * UC-ClientState-18: Test the transition from Lobby to StartDialog. + */ + @Test + public void testLobbyToStartDialog() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + + //todo simulate leave the lobby + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-19: Test remaining in the Lobby state. + */ + @Test + public void testStayInLobby() { + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + + //todo send all messages that dont indicate a change-state + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + } + + /** + * UC-ClientState-20: Test the transition from Lobby to RollRankingDice. + */ + @Test + public void testLobbyToRollRankingDice() { + //sends the clientStatemachine in Dialogs + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the clientStatemachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); + + //sends the message to start the game + clientGameLogic.receive();//TODO message + + //tests if the clientStateMachine is in the GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //tests if the clientStateMachine is in the DetermineStartPlayer + GameState gameState1 = (GameState) clientAutomaton.getState(); + GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the clientStateMachine is in the RollRankingDice + DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); + } + + /** + * UC-ClientState-21: Test the transition from DetermineStartPlayer to Wait. + */ + @Test + public void testDetermineStartPlayerToWait() { + // Todo Implementation goes here + } + + /** + * UC-ClientState-22: Test the transition from Wait to Animation. + */ + @Test + public void testWaitToAnimation() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the client in WaitState + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //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); + + //sends the client in WaitState + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //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); + + //sends the client in WaitState + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //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); + } + + /** + * UC-ClientState-23: Test the transition from Wait to Turn. + */ + @Test + public void testWaitToTurn() { + //sends client in gameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Waiting + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); + + //the client receives the message ActivePlayer + clientGameLogic.receive(activePlayer); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //tests if Client is in Turn + assertTrue(gameStateMachine.getState() instanceof Turn); + + //tests if Client is in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //tests if Client is in ChoosePowerCard + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + } + + /** + * UC-ClientState-24: Test the transition from Wait to GameEndState. + */ + @Test + public void testWaitToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-25: Test the transition from Turn substates to GameEndState. + */ + @Test + public void testTurnSubStatesToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-26: Test the transition from Turn sub-states to Wait. + */ + @Test + public void testTurnSubStatesToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-27: Test the transition from Turn sub-states to Spectator. + */ + @Test + public void testTurnSubStatesToSpectator() { + // Implementation goes here + } + + /** + * UC-ClientState-28: Test the transition from Spectator to GameEndState. + */ + @Test + public void testSpectatorToGameEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-29: Test the transition from PowerCard sub-states to PlayPowerCard. + */ + @Test + public void testPowerCardSubStatesToPlayPowerCard() { + // Implementation goes here + } + + /** + * UC-ClientState-30: Test the transition from PowerCard sub-states to RollDice. + */ + @Test + public void testPowerCardSubStatesToRollDice() { + // Implementation goes here + } + + /** + * UC-ClientState-31: Test staying in the PlayPowerCard state. + */ + @Test + public void testStayInPlayPowerCard() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.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); + } + + /** + * UC-ClientState-32: Test the transition from PlayPowerCard to RollDice. + */ + @Test + public void testPlayPowerCardToRollDice() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.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); + } + + /** + * UC-ClientState-33: Test staying in the RollDice state. + */ + @Test + public void testStayInRollDice() { + // Implementation goes here + } + + /** + * UC-ClientState-34: Test the transition from RollDice to ChoosePiece. + */ + @Test + public void testRollDiceToChoosePiece() { + // Implementation goes here + } + + /** + * UC-ClientState-35: Test the transition from RollDice to Wait. + */ + @Test + public void testRollDiceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-36: Test the transition from ChoosePiece to Wait. + */ + @Test + public void testChoosePieceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-37: Test the transition from ChoosePiece to MovePiece. + */ + @Test + public void testChoosePieceToMovePiece() { + // Implementation goes here + } + + /** + * UC-ClientState-38: Test the transition from MovePiece to Wait. + */ + @Test + public void testMovePieceToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-39: Test the transition from MovePiece to Spectator. + */ + @Test + public void testMovePieceToSpectator() { + // Implementation goes here + } + + /** + * UC-ClientState-40: Test the transition from MovePiece to Ceremony. + */ + @Test + public void testMovePieceToCeremony() { + // Implementation goes here + } + + /** + * UC-ClientState-41: Test staying in the ChoosePowerCard state. + */ + @Test + public void testStayInChoosePowerCard() { + // Implementation goes here + } + + /** + * UC-ClientState-42: Test the transition from ChoosePowerCard to RollDice. + */ + @Test + public void testChoosePowerCardToRollDice() { + + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(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); + } + + /** + * UC-ClientState-43: Test the transition from ChoosePowerCard to Swap. + */ + @Test + public void testChoosePowerCardToSwap() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(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); + } + + /** + * UC-ClientState-44: Test the transition from ChoosePowerCard to Shield. + */ + @Test + public void testChoosePowerCardToShield() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + powerCardStateMachine.gotoState(choosePowerCard); + assertTrue(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); + } + + /** + * UC-ClientState-45: Test staying in the Shield state. + */ + @Test + public void testStayInShield() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in Shield + powerCardStateMachine.gotoState(shield); + assertTrue(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); + } + + /** + * UC-ClientState-46: Test the transition from Shield to PowerCardEndState. + */ + @Test + public void testShieldToPowerCardEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in Shield + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(shield); + assertTrue(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); + } + + /** + * UC-ClientState-47: Test the transition from Swap to PowerCardEndState. + */ + @Test + public void testSwapToPowerCardEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //sends the turnStatemachine in Swap + powerCardStateMachine.gotoState(swap); + assertTrue(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); + } + + /** + * UC-ClientState-48: Test no piece in WaitingPiece state. + */ + @Test + public void testNoPieceInWaitingPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + turnStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message WaitPiece + clientGameLogic.receive(waitPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + } + + /** + * UC-ClientState-49: Test no piece in SelectedPiece state. + */ + @Test + public void testNoPieceInSelectedPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message SelectPiece + clientGameLogic.receive(selectPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + } + + /** + * UC-ClientState-50: Test no piece in StartPiece state. + */ + @Test + public void testNoPieceInStartPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message StartPiece + clientGameLogic.receive(startPiece); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + } + + /** + * UC-ClientState-51: Test no piece in Wait state. + */ + @Test + public void testNoPieceInWait() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message NoTurn + clientGameLogic.receive(noTurn); + + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof Waiting); + } + + /** + * UC-ClientState-52: Test staying in the WaitingPiece state. + */ + @Test + public void testStayInWaitingPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof 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); + } + + /** + * UC-ClientState-53: Test the WaitingPiece to ChoosePiece end state. + */ + @Test + public void testWaitingPieceInChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof 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); + } + + /** + * UC-ClientState-54: Test staying in the SelectedPiece state. + */ + @Test + public void testStayInSelectedPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece; + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.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); + } + + /** + * UC-ClientState-55: Test the SelectedPiece to ChoosePiece end state. + */ + @Test + public void testSelectedPieceInChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.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); + } + + /** + * UC-ClientState-56: Test staying in the StartPiece state. + */ + @Test + public void testStayInStartPiece() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.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); + } + + /** + * UC-ClientState-57: Test the StartPiece to ChoosePiece end state. + */ + @Test + public void testStartPieceToChoosePieceEndState() { + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.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); + } + + /** + * UC-ClientState-58: Test the transition from RollRankingDice to WaitRanking. + */ + @Test + public void testRollRankingDiceToWaitRanking() { + // Implementation goes here + } + + /** + * UC-ClientState-59: Test the transition from WaitRanking to RollRankingDice. + */ + @Test + public void testWaitRankingToRollRankingDice() { + // Implementation goes here + } + + /** + * UC-ClientState-60: Test the transition from WaitRanking to the EndState of determining the starting player. + */ + @Test + public void testWaitRankingToEndStateDetermineStartingPlayer() { + // Implementation goes here + } + + /** + * UC-ClientState-61: Test the transition from Podium to Statistics. + */ + @Test + public void testPodiumToStatistics() { + // Implementation goes here + } + + /** + * UC-ClientState-62: Test the transition from Statistics to the Ceremony end state. + */ + @Test + public void testStatisticsToCeremonyEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-63: Test the transition from MainSettings to VideoSettings. + */ + @Test + public void testMainSettingsToVideoSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-64: Test the transition from MainSettings to AudioSettings. + */ + @Test + public void testMainSettingsToAudioSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-65: Test the transition from MainSettings to ClientState. + */ + @Test + public void testMainSettingsToClientState() { + // Implementation goes here + } + + /** + * UC-ClientState-66: Test staying in the VideoSettings state. + */ + @Test + public void testStayInVideoSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-67: Test the transition from VideoSettings to MainSettings. + */ + @Test + public void testVideoSettingsToMainSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-68: Test staying in the AudioSettings state. + */ + @Test + public void testStayInAudioSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-69: Test the transition from AudioSettings to MainSettings. + */ + @Test + public void testAudioSettingsToMainSettings() { + // Implementation goes here + } + + /** + * UC-ClientState-70: Test the transition from ClientState substates to MainSettings. + */ + @Test + public void testClientStateSubStatesToMainSettings() { + // Implementation goes here + } + +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java new file mode 100644 index 00000000..225e0db2 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java @@ -0,0 +1,106 @@ +package pp.mdga.game; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T001-T016 + */ +public class GameTest { + + @Before + public void setup() { + + } + + @Test + public void testStartLineUp() { + // TODO: Implement test logic for starting line-up + } + + @Test + public void testCreatePowerCardDeck() { + // TODO: Implement test logic for creating power card deck + } + + // UC-Game-02 + @Test + public void testGameFinishes() { + // TODO: Implement test logic for game finishes + } + + // UC-Game-03 + @Test + public void testPlayerFinishes() { + // TODO: Implement test logic for player finishes + } + + // UC-Game-04 + @Test + public void testAllPiecesInWaitingArea() { + // TODO: Implement test logic for checking if all pieces are in the waiting area + } + + @Test + public void test3TriesFor6() { + // TODO: Implement test logic for checking 3 tries for rolling a 6 + } + + // UC-Game-05 + @Test + public void testGameTerminates() { + // TODO: Implement test logic for game termination + } + + // UC-Game-06 + @Test + public void testStartingOrder() { + // TODO: Implement test logic for verifying starting order of players + } + + // UC-Game-07 + @Test + public void testDouble() { + // TODO: Implement test logic for testing the double rule + } + + // UC-Game-08 + @Test + public void testChangeActivePlayer() { + // TODO: Implement test logic for changing the active player + } + + // UC-Game-09 + @Test + public void testUseTurbo() { + // TODO: Implement test logic for using a turbo power-up + } + + @Test + public void testMuliplicationChance() { + // TODO: Implement test logic for testing multiplication chance power-up + } + + // UC-Game-10 + @Test + public void testTurboOn6() { + // TODO: Implement test logic for turbo activation on rolling a 6 + } + + // UC-Game-11 + @Test + public void testAwardCeremony() { + // TODO: Implement test logic for award ceremony + } + + @Test + public void testStatistics() { + // TODO: Implement test logic for gathering or displaying game statistics + } + + // UC-Game-12 + @Test + public void testRefillPowerCardDeck() { + // TODO: Implement test logic for refilling the power card deck + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java new file mode 100644 index 00000000..30c770c1 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java @@ -0,0 +1,147 @@ +package pp.mdga.game; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T035-T058 + */ +public class PieceTest { + + @Before + public void Setup() { + + } + + // UC-Piece-01 + @Test + public void testMove() { + // TODO: Implement test logic for moving a piece + } + + // UC-Piece-02 + @Test + public void testCantMove() { + // TODO: Implement test logic for when a piece can't move + } + + // UC-Piece-03 + @Test + public void testNoPossibleMove() { + // TODO: Implement test logic for when no possible moves are available + } + + @Test + public void testThrow() { + // TODO: Implement test logic for throwing a piece off the board + } + + // UC-Piece-04 + @Test + public void testGetThrown() { + // TODO: Implement test logic for when a piece gets thrown + } + + // UC-Piece-05 + @Test + public void testLeaveWaitingArea() { + // TODO: Implement test logic for a piece leaving the waiting area + } + + // UC-Piece-06 + @Test + public void testMustLeaveStartingField() { + // TODO: Implement test logic for a piece that must leave the starting field + } + + // UC-Piece-07 + @Test + public void testDontHaveToLeaveStartingField() { + // TODO: Implement test logic for when a piece doesn't have to leave the starting field + } + + // UC-Piece-08 + @Test + public void testCantLeaveStartingField() { + // TODO: Implement test logic for when a piece can't leave the starting field + } + + // UC-Piece-09 + @Test + public void testReachBonusField() { + // TODO: Implement test logic for when a piece reaches a bonus field + } + + @Test + public void testNoPowerCards() { + // TODO: Implement test logic for when there are no power cards available + } + + @Test + public void testShufflePile() { + // TODO: Implement test logic for shuffling the pile of power cards + } + + // UC-Piece-10 + @Test + public void testEnterHouse() { + // TODO: Implement test logic for entering the house area + } + + @Test + public void testOnlyEnterOwnHouse() { + // TODO: Implement test logic to ensure a piece can only enter its own house + } + + // UC-Piece-11 + @Test + public void testActiveHomePiece() { + // TODO: Implement test logic for activating a piece in the home area + } + + @Test + public void testCantJumpOverFigureInHouse() { + // TODO: Implement test logic to prevent jumping over another piece in the house + } + + // UC-Piece-12 + @Test + public void testActiveHomePieceBlocked() { + // TODO: Implement test logic for when an active home piece is blocked + } + + @Test + public void testOnStartingFieldWithShield() { + // TODO: Implement test logic for a piece on the starting field with a shield + } + + // UC-Piece-13 + @Test + public void testThrowFigureWithShield() { + // TODO: Implement test logic for attempting to throw a figure with a shield + } + + // UC-Piece-14 + @Test + public void testUseSwap() { + // TODO: Implement test logic for using a swap power-up + } + + // UC-Piece-15 + @Test + public void testUseShield() { + // TODO: Implement test logic for using a shield power-up + } + + // UC-Piece-16 + @Test + public void testLoseShield() { + // TODO: Implement test logic for when a piece loses its shield + } + + // UC-Piece-17 + @Test + public void testFinishedPiece() { + // TODO: Implement test logic for a piece that has finished the game + } +} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java new file mode 100644 index 00000000..52a04bc3 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java @@ -0,0 +1,49 @@ +package pp.mdga.server; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T059-T065 + */ +public class ServerTest { + @Before + public void Setup() { + + } + + @Test + public void testServerStart() { + + } + + @Test + public void testServerDoesntStart() { + + } + + @Test + public void testAcceptRequest() { + + } + + @Test + public void testTerminateServer() { + + } + + @Test + public void testServerEndsGame() { + + } + + @Test + public void testDeclineConnection() { + + } + + @Test + public void testDeclineRequest() { + + } +} 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 new file mode 100644 index 00000000..5d11bbce --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -0,0 +1,1094 @@ +package pp.mdga.server.serverState; + +import org.junit.Before; +import org.junit.Test; +import pp.mdga.game.Game; +import pp.mdga.message.client.*; +import pp.mdga.message.server.ServerMessage; +import pp.mdga.message.server.WaitPiece; +import pp.mdga.server.*; +import static org.junit.Assert.*; + +/** + * this test-class tests the Testcases T132-T169 + */ +public class ServerStateTest { + + //Todo + private ServerGameLogic logic; + private AnimationEnd animationEnd; + private ClientStartGame clientStartGame; + private DeselectTSK deselectTSK; + private ForceContinueGame forceContinueGame; + private ForceStartGame forceStartGame; + private JoinServer joinServer; + private LeaveGame leaveGame; + private LobbyNotReady lobbyNotReady; + private LobbyReady lobbyReady; + private NoPowerCard noPowerCard; + private RequestBriefing requestBriefing; + private RequestDice requestDice; + private RequestMove requestMove; + private RequestPlayCard requestPlayCard; + private SelectCard selectCard; + private SelectedPieces selectedPieces; + private SelectTSK selectTSK; + private ClientMessage[] clientMessages; + + //Todo + private int from; + private int fromHost; + + //Todo + private GameStateMachine gameStateMachine; + private TurnStateMachine turnStateMachine; + private RollDiceMachine rollDiceMachine; + private ChoosePieceStateMachine choosePieceStateMachine; + private ServerAutomaton serverAutomaton; + + //TODO + private Animation animation; + private Ceremony ceremony; + private ChoosePiece choosePiece; + private DetermineStartPlayer determineStartPlayer; + private FirstRoll firstRoll; + private GameState gameState; + private Interrupt interrupt; + private Lobby lobby; + private MovePiece movePiece; + private NoPiece noPiece; + private NoTurn noTurn; + private PlayPowerCard playPowerCard; + private PowerCard powerCard; + private RollDice rollDice; + private SecondRoll secondRoll; + private SelectPiece selectPiece; + private StartPiece startPiece; + private ThirdRoll thirdRoll; + private Turn turn; + private WaitingPiece waitingPiece; + + /** + * TODO + */ + @Before + public void setUp() { + + logic = new ServerGameLogic(new Game(), new ServerSender() { + @Override + public void send(int id, ServerMessage msg) { + + } + }); + animationEnd = new AnimationEnd(); + clientStartGame = new ClientStartGame(); + deselectTSK = new DeselectTSK(); + forceContinueGame = new ForceContinueGame(); + forceStartGame = new ForceStartGame(); + joinServer = new JoinServer(); + leaveGame = new LeaveGame(); + lobbyReady = new LobbyReady(); + noPowerCard = new NoPowerCard(); + requestBriefing = new RequestBriefing(); + requestDice = new RequestDice(); + 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 + }; + from = 1234; + fromHost = 2345; + + choosePieceStateMachine = choosePiece.getChoosePieceMachine(); + rollDiceMachine = rollDice.getRollDicemachine(); + turnStateMachine = turn.getTurnStatemachine(); + serverAutomaton = logic.getServerAutomaton(); + gameStateMachine = gameState.getGameStatemachine(); + + thirdRoll = new ThirdRoll(rollDiceMachine, logic); + secondRoll = new SecondRoll(rollDiceMachine, logic); + firstRoll = new FirstRoll(rollDiceMachine, logic); + + noPiece = new NoPiece(choosePieceStateMachine, logic); + noTurn = new NoTurn(choosePieceStateMachine, logic); + waitingPiece = new WaitingPiece(choosePieceStateMachine, logic); + startPiece = new StartPiece(choosePieceStateMachine, logic); + selectPiece = new SelectPiece(choosePieceStateMachine, logic); + + powerCard = new PowerCard(turnStateMachine, logic); + playPowerCard = new PlayPowerCard(turnStateMachine, logic); + rollDice = new RollDice(turnStateMachine, logic); + choosePiece = new ChoosePiece(turnStateMachine, logic); + movePiece = new MovePiece(turnStateMachine, logic); + + determineStartPlayer = new DetermineStartPlayer(gameStateMachine, logic); + turn = new Turn(gameStateMachine, logic); + animation = new Animation(gameStateMachine, logic); + + lobby = new Lobby(serverAutomaton, logic); + gameState = new GameState(serverAutomaton, logic); + ceremony = new Ceremony(serverAutomaton, logic); + interrupt = new Interrupt(serverAutomaton, logic, gameState); + } + + /** + * this test-method tests, that the server, when initialized, is in the Lobby-state + */ + @Test + public void testInitialStateServerState() { + assertTrue(serverAutomaton.getState() instanceof Lobby); + } + + /** + * this method tests that the server, if all players are ready and the startGameMessage is issued, + * changes into the DetermineStartPlayer-state + */ + @Test + public void testLobbyToDetermineStartPlayer() { + //sends the server in the lobby-state + serverAutomaton.gotoState(lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); + + //sends the startGame message from the Host to the server + logic.received(clientStartGame, from); + + //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 DetermineStartPlayer); + } + + /** + * this method tests, that the server stays in the Lobby + */ + @Test + public void testStayInLobby() { + //sends the server in the lobby-state + serverAutomaton.gotoState(lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); + + //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); + + //tests if Server is still in Lobby + assertTrue(serverAutomaton.getState() instanceof Lobby); + } + + /** + * this method tests, that the server can go into the interrupt-state + */ + @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 + + //TODO create interrupt + + //tests if the server is in the Interrupt-state + assertTrue(serverAutomaton.getState() instanceof Interrupt); + } + + /** + * tests the state-change from Game to Ceremony if the Game is finished + */ + @Test + public void testServerGameToCeremony() { + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //Todo game is finished + + //tests if the server is in the Ceremony-state + assertTrue(serverAutomaton.getState() instanceof Ceremony); + } + + /** + * this method tests that the server goes back to the Game, when the ForceStartGame-message is issued + */ + @Test + public void testInterruptToGameContinue() { + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //sends the continue-message to the server + logic.received(forceContinueGame, from); + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); + } + + /** + * this method tests, that the server goes back to the game, if the missing client has reconnected + */ + @Test + public void testInterruptToGameReconnect() { + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); + } + + /** + * this method tests, that th e server continues with the game, if there is no time left on the timer + */ + @Test + public void testInterruptToGameTimer() { + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //Todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); + } + + /** + * this method tests, that the server closes, if the ceremony has ended + */ + @Test + public void testCeremonyToServerStateEndState() { + // TODO: Implement test logic for transition from Ceremony to Server State End State + // TODO how???? + } + + /** + * this method tests that the server stays in DetermineStartPlayer, when issued messages + */ + @Test + public void testDetermineStartPlayerToDetermineStartPlayer1() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + //TODO sends messages to the server + + //tests if the server is still in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + } + + /** + * this method tests that the server stays in DetermineStartPlayer, when all players are ranked and two of the highest are even + */ + @Test + public void testDetermineStartPlayerToDetermineStartPlayer2() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + //TODO sends messages 2 RequestDiceMessage, die gleich geränkt werden to the server + + //tests if the server is still in DSP-state + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + } + + /** + * this method tests that the server goes into Animation-state, if there is an order + */ + @Test + public void testDetermineStartPlayerToAnimation() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in DSP-state + gameStateMachine.gotoState(determineStartPlayer); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + //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); + } + + /** + * tests that the server goes from the animation-state into PowerCardState, if the animation in the client has ended + * and all players have issued a animationEndMessage + */ + @Test + public void testAnimationToPowerCard() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Animation + gameStateMachine.gotoState(animation); + assertTrue(gameStateMachine.getState() 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); + + //receives another animation endMessage + logic.received(animationEnd, from); + + //tests if the server is in the PowerCard-state + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + Turn turn1 = (Turn) gameStateMachine.getState(); + TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine(); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + } + + /** + * this method tests that the server changes it's state from the turn-state to the animation-state, if there are at + * least two player left + */ + @Test + public void testTurnToAnimation() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there are still two players left + + //tests if the server is in the AnimationState + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); + } + + /** + * this method tests that the server changes it's state from the turn-state to the ceremony-state, + * if there is only one player left + */ + @Test + public void testTurnToGameEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there is only one players left + + //tests if the server is in the end-state of game, Ceremony + assertTrue(serverAutomaton.getState() instanceof Ceremony); + } + + /** + * this method tests that the server don't change it's state whe issued with messages, + * which don't implicate a statechange + */ + @Test + public void testStayInPowerCard() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //Todo: receive messages which dont lead to a state change + + //tests if the server is in PowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + } + + /** + * Tests the transition from PowerCard state to PlayPowerCard state. + * UC-ServerState-17 + */ + @Test + public void testPowerCardToPlayPowerCard() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //todo + + //tests if the server is in PlayPowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + } + + /** + * Tests the transition from PlayPowerCard state to RollDice state. + * UC-ServerState-18 + */ + @Test + public void testPlayPowerCardToRollDice() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive first AnimationEndMessage from the host + logic.received(animationEnd, fromHost); + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive second AnimationEndMessage + logic.received(animationEnd, from); + + //tests if the server is in RollDice and in FirstRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + RollDice rollDice = (RollDice) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); + } + + /** + * Tests the transition from ChoosePiece state to MovePiece state. + * UC-ServerState-19 + */ + @Test + public void testChoosePieceToMovePiece() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //Todo ??? + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + } + + /** + * Tests the transition from MovePiece state to TurnEndState. + * UC-ServerState-20 + */ + @Test + public void testMovePieceToTurnEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePiece); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + + //Todo no 6 was rolled, so the server looks, if there are 2 or less player are still in the game + //TODO + + } + + /** + * Tests the transition from MovePiece state to FirstRoll state. + * UC-ServerState-21 + */ + @Test + public void testMovePieceToFirstRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in MovePiece + turnStateMachine.gotoState(movePiece); + assertTrue(turnStateMachine.getState() instanceof MovePiece); + + //Todo the player rolled a 6 and the player is not finished + + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + RollDice rollDice = (RollDice) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); + } + + /** + * Tests the transition from FirstRoll state to RollDiceEndState. + * UC-ServerState-22 + */ + @Test + public void testFirstRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRoll); + assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + + //TODO 2 Möglichkeiten + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + } + + /** + * Tests the transition from FirstRoll state to SecondRoll state. + * UC-ServerState-23 + */ + @Test + public void testFirstRollToSecondRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in FirstRoll + rollDiceMachine.gotoState(firstRoll); + assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + + //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 Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); + } + + /** + * Tests the transition from SecondRoll state to RollDiceEndState. + * UC-ServerState-24 + */ + @Test + public void testSecondRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + } + + /** + * Tests the transition from SecondRoll state to ThirdRoll state. + * UC-ServerState-25 + */ + @Test + public void testSecondRollToThirdRoll() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); + + //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 Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); + } + + /** + * Tests the transition from ThirdRoll state to RollDiceEndState. + * UC-ServerState-26 + */ + @Test + public void testThirdRollToRollDiceEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); + + //Todo + + //tests if the server is in NoPiece of ChoosePiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + ChoosePiece choosePiece1 = (ChoosePiece) turnStateMachine.getState(); + ChoosePieceStateMachine choosePieceStateMachine = choosePiece1.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + } + + /** + * Tests the transition from ThirdRoll state to TurnEndState. + * UC-ServerState-27 + */ + @Test + public void testThirdRollToTurnEndState() { + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in RollDice + turnStateMachine.gotoState(rollDice); + assertTrue(turnStateMachine.getState() instanceof RollDice); + + //sends the RollDiceMachine in ThirdRoll + rollDiceMachine.gotoState(thirdRoll); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); + + //Todo + } + + /** + * Tests the transition from NoPiece state to WaitingPiece state. + * UC-ServerState-28 + */ + @Test + public void testNoPieceToWaitingPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + + } + + /** + * Tests the transition from NoPiece state to NoTurn state. + * UC-ServerState-29 + */ + @Test + public void testNoPieceToNoTurn() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in NoTurn + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); + } + + /** + * Tests the transition from NoTurn state to TurnEndState. + * UC-ServerState-30 + */ + @Test + public void testNoTurnToTurnEndState() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoTurn + choosePieceStateMachine.gotoState(noTurn); + assertTrue(choosePieceStateMachine.getState() instanceof NoTurn); + + //TODO + } + + /** + * Tests that the system stays in the WaitingPiece state. + * UC-ServerState-31 + */ + @Test + public void testStayInWaitingPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + + //TODO + + //tests if the server is in WaitingPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + } + + /** + * Tests the transition from WaitingPiece state to MovePiece state. + * UC-ServerState-32 + */ + @Test + public void testWaitingPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in WaitingPiece + choosePieceStateMachine.gotoState(waitingPiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); + + //TODO + } + + /** + * Tests the transition from NoPiece state to SelectPiece state. + * UC-ServerState-33 + */ + @Test + public void testNoPieceToSelectPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + } + + /** + * Tests the transition from NoPiece state to StartPiece state. + * UC-ServerState-34 + */ + @Test + public void testNoPieceToStartPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in NoPiece + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + } + + /** + * Tests that the system stays in the SelectPiece state. + * UC-ServerState-35 + */ + @Test + public void testStayInSelectPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + + //TODO + + //tests if the server is in SelectPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + } + + /** + * Tests the transition from SelectPiece state to MovePiece state. + * UC-ServerState-36 + */ + @Test + public void testSelectPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in SelectPiece + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); + + //TODO + } + + /** + * Tests that the system stays in the StartPiece state. + * UC-ServerState-37 + */ + @Test + public void testStayInStartPiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + + //TODO + + //tests if the server is in StartPiece + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + } + + /** + * Tests the transition from StartPiece state to MovePiece state. + * UC-ServerState-38 + */ + @Test + public void testStartPieceToMovePiece() { + //sends the server in GameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the server in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the server in ChoosePiece + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + + //sends the server in StartPiece + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); + + //TODO + } +}