From 33dbbdbe5ce5bdd669b8b76cf647c03af72ec35f Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Thu, 14 Nov 2024 18:07:36 +0100 Subject: [PATCH 01/15] initial test commit, added all testclasses except Playertest, Viewtest, Cameratest, SettingsTest, SoundTest, ReactionTest and ClientStateTest. And filled all created testclasses with empty testmethods, except ServerStateTest. --- .../test/java/pp/mdga/client/ClientTest.java | 44 ++++++ .../java/pp/mdga/client/Dialog/LobbyTest.java | 88 +++++++++++ .../Dialog/NetworkDialogClientTest.java | 45 ++++++ .../client/Dialog/NetworkDialogHostTest.java | 35 +++++ .../mdga/client/Dialog/StartDialogTest.java | 39 +++++ .../client/clientState/SettingsStateTest.java | 64 ++++++++ .../src/test/java/pp/mdga/game/GameTest.java | 106 +++++++++++++ .../src/test/java/pp/mdga/game/PieceTest.java | 147 ++++++++++++++++++ .../test/java/pp/mdga/server/ServerTest.java | 49 ++++++ .../server/serverState/ServerStateTest.java | 4 + 10 files changed, 621 insertions(+) create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/ClientTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/LobbyTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogClientTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/NetworkDialogHostTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/Dialog/StartDialogTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/game/GameTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/game/PieceTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/server/ServerTest.java create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java 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/SettingsStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java new file mode 100644 index 00000000..43444c3f --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java @@ -0,0 +1,64 @@ +package pp.mdga.client.clientState; + +import org.junit.Before; +import org.junit.Test; + +/** + * this test-class tests the testcases T232-T239 + */ +public class SettingsStateTest { + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Client State transitions. + } + + // UC-ClientState-63 + @Test + public void testMainSettingsToVideoSettings() { + // TODO: Implement test logic for transitioning from Main Settings to Video Settings + } + + // UC-ClientState-64 + @Test + public void testMainSettingsToAudioSettings() { + // TODO: Implement test logic for transitioning from Main Settings to Audio Settings + } + + // UC-ClientState-65 + @Test + public void testMainSettingsToClientState() { + // TODO: Implement test logic for transitioning from Main Settings to a generic Client State + } + + // UC-ClientState-66 + @Test + public void testStayInVideoSettings() { + // TODO: Implement test logic for staying in Video Settings + } + + // UC-ClientState-67 + @Test + public void testVideoSettingsToMainSettings() { + // TODO: Implement test logic for transitioning from Video Settings to Main Settings + } + + // UC-ClientState-68 + @Test + public void testStayInAudioSettings() { + // TODO: Implement test logic for staying in Audio Settings + } + + // UC-ClientState-69 + @Test + public void testAudioSettingsToMainSettings() { + // TODO: Implement test logic for transitioning from Audio Settings to Main Settings + } + + // UC-ClientState-70 + @Test + public void testClientStateSubStatesToMainSettings() { + // TODO: Implement test logic for transitioning from any sub-state of the client to Main Settings + } +} 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..53e9af8d --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -0,0 +1,4 @@ +package pp.mdga.server.serverState; + +public class ServerStateTest { +} -- 2.43.0 From 6790be782ec4cd55b972dfcefa7579df00aff0de Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Tue, 19 Nov 2024 12:42:11 +0100 Subject: [PATCH 02/15] added empty serverstatetests --- .../server/serverState/ServerStateTest.java | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 53e9af8d..8b76956c 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -1,4 +1,94 @@ package pp.mdga.server.serverState; +import org.junit.Before; +import org.junit.Test; +import pp.mdga.server.ServerGameLogic; +import pp.mdga.server.ServerState; + public class ServerStateTest { + + @Before + public void setUp(){ + ServerGameLogic logic = new ServerGameLogic(); + } + + @Test + public void testInitialStateServerState() { + + } + + @Test + public void testLobbyToDetermineStartPlayer() { + // TODO: Implement test logic for transition from Lobby to Determine Start Player + } + + @Test + public void testStayInLobby() { + // TODO: Implement test logic for staying in the Lobby + } + + @Test + public void testServerGameSubStatesToInterrupt() { + // TODO: Implement test logic for transition from Server Game Sub-States to Interrupt + } + + @Test + public void testServerGameToCeremony() { + // TODO: Implement test logic for transition from Server Game to Ceremony + } + + @Test + public void testInterruptToGameContinue() { + // TODO: Implement test logic for transition from Interrupt to Game Continue + } + + @Test + public void testInterruptToGameReconnect() { + // TODO: Implement test logic for transition from Interrupt to Game Reconnect + } + + @Test + public void testInterruptToGameTimer() { + // TODO: Implement test logic for transition from Interrupt to Game Timer + } + + @Test + public void testCeremonyToServerStateEndState() { + // TODO: Implement test logic for transition from Ceremony to Server State End State + } + + @Test + public void testDeterminStartPlayerToDetermineStartPlayer1() { + // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + } + + @Test + public void testDeterminStartPlayerToDetermineStartPlayer2() { + // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + } + + @Test + public void testDeterminStartPlayerToAnimation() { + // TODO: Implement test logic for Determine Start Player to Animation + } + + @Test + public void testAnimationToPowerCard() { + // TODO: Implement test logic for transition from Animation to Power Card + } + + @Test + public void testTurnToAnimation() { + // TODO: Implement test logic for transition from Turn to Animation + } + + @Test + public void testTurnToGameEndState() { + // TODO: Implement test logic for transition from Turn to Game End State + } + + @Test + public void testStayInPowerCard() { + // TODO: Implement test logic for staying in Power Card state + } } -- 2.43.0 From 2095ea5866e4d190eca71370f0325fce976eb8dc Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 15:49:01 +0100 Subject: [PATCH 03/15] editet tests for the server and client statemachines --- .../client/clientState/ClientStateTest.java | 1001 +++++++++++++++++ .../client/clientState/SettingsStateTest.java | 64 -- .../server/serverState/ServerStateTest.java | 303 ++++- 3 files changed, 1291 insertions(+), 77 deletions(-) create mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java delete mode 100644 Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java 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..8d8d23c7 --- /dev/null +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -0,0 +1,1001 @@ +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.Game; +import pp.mdga.message.server.*; + + + +import static org.junit.Assert.assertTrue; + +/** + * this test-class tests the testcases T232-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 Ceremony 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 PlayCard playCard; + private PossibleCard possibleCard; + private PossiblePiece possiblePiece; + private RankingResponce rankingResponce; + private RankingRollAgain rankingRollAgain; + private ReconnectBriefing reconnectBriefing; + private ResumeGame resumeGame; + private StartPiece startPieceMessage; + private UpdateReady updateReady; + private UpdateTSK updateTSK; + private WaitPiece waitPiece; + + @Before + public void setUp() { + // This method will be executed before each test. + // Initialize common objects or setup required state for Client State transitions. + + //initialize the messages from the server + activePlayer = new ActivePlayer(); + anyPiece = new AnyPiece(); + briefing = new Briefing(); + ceremonyMessage = new Ceremony(); + dice = new Dice(); + diceAgain = new DiceAgain(); + diceNow = new DiceNow(); + endOfTurn = new EndOfTurn(); + lobbyAccept = new LobbyAccept(); + lobbyDeny = new LobbyDeny(); + lobbyPlayerJoin = new LobbyPlayerJoin(); + lobbyPlayerLeave = new LobbyPlayerLeave(); + moveMessage = new MoveMessage(); + noTurn = new NoTurn(); + pauseGame = new PauseGame(); + playCard = new PlayCard(); + possibleCard = new PossibleCard(); + possiblePiece = new PossiblePiece(); + rankingResponce = new RankingResponce(); + rankingRollAgain = new RankingRollAgain(); + reconnectBriefing = new ReconnectBriefing(); + resumeGame = new ResumeGame(); + startPieceMessage = new StartPiece(); + updateReady = new UpdateReady(); + updateTSK = new UpdateTSK(); + waitPiece = new WaitPiece(); + + //initialize the clientGameLogic + clientGameLogic = new ClientGameLogic(); + clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); + + //initialize the settings + mainSettings = new MainSettings(); + videoSettings = new VideoSettings(); + audioSettings = new AudioSettings(); + settings = new Settings(); + + + //initialize the stateMachines + ceremonyStateMachine =ceremony.getCeremonyStateMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerMachine(); + dialogsStateMachine = dialogs.getDialogsStateMachine(); + gameStateMachine = gameState.getGameStateMachine(); + powerCardStateMachine = powerCard.getPowerCardMachine(); + settingsStateMachine = settings.getSettingsStateMachine(); + turnStateMachine = turn.getTurnMachine(); + + + //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 + assertTrue(clientAutomaton.getState() instanceof Dialogs); + //tests if the statemachine is in StartDialog + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + } + + /** + * UC-ClientState-02: Test the transition from dialogs to the game state. + */ + @Test + public void testDialogsToGame() { + //TODO + //tests if the client is in 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= clientAutomaton.getState(); + GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.getState(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the new State of DetermineStartPlayer is RollRankingDice + DetermineStartPlayer determineStartPlayer1=(DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = (DetermineStartPlayerStateMachine) determineStartPlayer1.getState(); + assertTrue(DetermineStartPlayerStateMachine.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 + } + + /** + * UC-ClientState-04: Test the transition from ClientGame to Ceremony. + */ + @Test + public void testClientGameToCeremony() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + + //tests if the client is in 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 = (CeremonyStateMachine) ceremony1.getState(); + 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.goto(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() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-08: Test the transition from ClientInterrupt to the game state. + */ + @Test + public void testClientInterruptToGame() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-09: Test the transition from Interrupt to dialogs. + */ + @Test + public void testInterruptToDialogs() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(interrupt); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof Interrupt); + + //Todo + } + + /** + * UC-ClientState-10: Test the transition from Ceremony to dialogs. + */ + @Test + public void testCeremonyToDialogs() { + // Todo Implementation goes here + //send the client in the ceremony + clientAutomaton.goto(ceremony); + assertTrue(clientAutomaton.getStates() instanceof Ceremony); + + //Todo + } + + /** + * UC-ClientState-11: Test the transition from StartDialog to NetworkDialog1. + */ + @Test + public void testStartDialogToNetworkDialog1() { + // Implementation goes here + } + + /** + * UC-ClientState-12: Test the transition from StartDialog to NetworkDialog2. + */ + @Test + public void testStartDialogToNetworkDialog2() { + // Implementation goes here + } + + /** + * UC-ClientState-13: Test the transition from StartDialog to the dialogs end state. + */ + @Test + public void testStartDialogToDialogsEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-14: Test the transition from NetworkDialog to StartDialog. + */ + @Test + public void testNetworkDialogToStartDialog() { + // Implementation goes here + } + + /** + * UC-ClientState-15: Test the transition from NetworkDialog to NetworkDialog1. + */ + @Test + public void testNetworkDialogToNetworkDialog1() { + // Implementation goes here + } + + /** + * UC-ClientState-16: Test the transition from NetworkDialog to NetworkDialog2. + */ + @Test + public void testNetworkDialogToNetworkDialog2() { + // Implementation goes here + } + + /** + * UC-ClientState-17: Test the transition from NetworkDialog to Lobby. + */ + @Test + public void testNetworkDialogToLobby() { + // Implementation goes here + } + + /** + * UC-ClientState-18: Test the transition from Lobby to StartDialog. + */ + @Test + public void testLobbyToStartDialog() { + // Implementation goes here + } + + /** + * UC-ClientState-19: Test remaining in the Lobby state. + */ + @Test + public void testStayInLobby() { + // Implementation goes here + } + + /** + * UC-ClientState-20: Test the transition from Lobby to RollRankingDice. + */ + @Test + public void testLobbyToRollRankingDice() { + // Implementation goes here + } + + /** + * UC-ClientState-21: Test the transition from DetermineStartPlayer to Wait. + */ + @Test + public void testDetermineStartPlayerToWait() { + // Implementation goes here + } + + /** + * UC-ClientState-22: Test the transition from Wait to Animation. + */ + @Test + public void testWaitToAnimation() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + + //tests if the client is in GameState + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the client in WaitState + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a piece is moved,that the client goes into Animation + clientGameLogic.receive(moveMessage); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + + //sends the client in WaitState + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a powerCard is played,that the client goes into Animation + clientGameLogic.receive(playCard); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + + //sends the client in WaitState + gameStateMachine1.goto(waiting); + assertTrue(gameStateMachine1.getState() instanceof Waiting); + + //tests if a die is rolled,that the client goes into Animation + clientGameLogic.receive(dice); //Todo ??? richtige message + assertTrue(gameStateMachine1.getState() instanceof Animation); + } + + /** + * UC-ClientState-23: Test the transition from Wait to Turn. + */ + @Test + public void testWaitToTurn() { + //TODo + //sends client in gameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(wait); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //the client receives the message ActivePlayer + clientGameLogic.receive(activePlayer); + + //tests if Client is in Turn + assertTrue(gameStateMachine1.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() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(playPowerCard); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + + //Todo send messages to test to stay in playPowerCard + + } + + /** + * UC-ClientState-32: Test the transition from PlayPowerCard to RollDice. + */ + @Test + public void testPlayPowerCardToRollDice() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PlayPowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(playPowerCard); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + + //Todo send messages to test the transition in rollDice + //Todo test other messages, that there is no state change + + } + + /** + * 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() { + // Implementation goes here + } + + /** + * UC-ClientState-43: Test the transition from ChoosePowerCard to Swap. + */ + @Test + public void testChoosePowerCardToSwap() { + // Implementation goes here + } + + /** + * UC-ClientState-44: Test the transition from ChoosePowerCard to Shield. + */ + @Test + public void testChoosePowerCardToShield() { + // Implementation goes here + } + + /** + * UC-ClientState-45: Test staying in the Shield state. + */ + @Test + public void testStayInShield() { + // Implementation goes here + } + + /** + * UC-ClientState-46: Test the transition from Shield to PowerCardEndState. + */ + @Test + public void testShieldToPowerCardEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-47: Test the transition from Swap to PowerCardEndState. + */ + @Test + public void testSwapToPowerCardEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-48: Test no piece in WaitingPiece state. + */ + @Test + public void testNoPieceInWaitingPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message WaitPiece + clientGameLogic.receive(waitPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + } + + /** + * UC-ClientState-49: Test no piece in SelectedPiece state. + */ + @Test + public void testNoPieceInSelectedPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message SelectPiece + clientGameLogic.receive(selectPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + } + + /** + * UC-ClientState-50: Test no piece in StartPiece state. + */ + @Test + public void testNoPieceInStartPiece() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message StartPiece + clientGameLogic.receive(startPiece); + + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + } + + /** + * UC-ClientState-51: Test no piece in Wait state. + */ + @Test + public void testNoPieceInWait() { + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in NoPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + + //Todo test other messages, that there is no state change + + //sends to the clientGameLogic the message NoTurn + clientGameLogic.receive(noTurn); + + assertTrue(turnStateMachine1.getState() instanceof Waiting); + } + + /** + * UC-ClientState-52: Test staying in the WaitingPiece state. + */ + @Test + public void testStayInWaitingPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-53: Test the WaitingPiece to ChoosePiece end state. + */ + @Test + public void testWaitingPieceInChoosePieceEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-54: Test staying in the SelectedPiece state. + */ + @Test + public void testStayInSelectedPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-55: Test the SelectedPiece to ChoosePiece end state. + */ + @Test + public void testSelectedPieceInChoosePieceEndState() { + // Implementation goes here + } + + /** + * UC-ClientState-56: Test staying in the StartPiece state. + */ + @Test + public void testStayInStartPiece() { + // Implementation goes here + } + + /** + * UC-ClientState-57: Test the StartPiece to ChoosePiece end state. + */ + @Test + public void testStartPieceToChoosePieceEndState() { + // Implementation goes here + } + + /** + * 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/client/clientState/SettingsStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java deleted file mode 100644 index 43444c3f..00000000 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/SettingsStateTest.java +++ /dev/null @@ -1,64 +0,0 @@ -package pp.mdga.client.clientState; - -import org.junit.Before; -import org.junit.Test; - -/** - * this test-class tests the testcases T232-T239 - */ -public class SettingsStateTest { - - @Before - public void setUp() { - // This method will be executed before each test. - // Initialize common objects or setup required state for Client State transitions. - } - - // UC-ClientState-63 - @Test - public void testMainSettingsToVideoSettings() { - // TODO: Implement test logic for transitioning from Main Settings to Video Settings - } - - // UC-ClientState-64 - @Test - public void testMainSettingsToAudioSettings() { - // TODO: Implement test logic for transitioning from Main Settings to Audio Settings - } - - // UC-ClientState-65 - @Test - public void testMainSettingsToClientState() { - // TODO: Implement test logic for transitioning from Main Settings to a generic Client State - } - - // UC-ClientState-66 - @Test - public void testStayInVideoSettings() { - // TODO: Implement test logic for staying in Video Settings - } - - // UC-ClientState-67 - @Test - public void testVideoSettingsToMainSettings() { - // TODO: Implement test logic for transitioning from Video Settings to Main Settings - } - - // UC-ClientState-68 - @Test - public void testStayInAudioSettings() { - // TODO: Implement test logic for staying in Audio Settings - } - - // UC-ClientState-69 - @Test - public void testAudioSettingsToMainSettings() { - // TODO: Implement test logic for transitioning from Audio Settings to Main Settings - } - - // UC-ClientState-70 - @Test - public void testClientStateSubStatesToMainSettings() { - // TODO: Implement test logic for transitioning from any sub-state of the client to Main Settings - } -} diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 8b76956c..10bf1239 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -2,29 +2,243 @@ import org.junit.Before; import org.junit.Test; +import pp.mdga.game.Game; +import pp.mdga.message.client.AnimationEnd; +import pp.mdga.message.client.ClientMessage; +import pp.mdga.message.client.ClientStartGame; +import pp.mdga.message.client.DeselectTSK; +import pp.mdga.message.client.ForceContinueGame; +import pp.mdga.message.client.ForceStartGame; +import pp.mdga.message.client.JoinServer; +import pp.mdga.message.client.LeaveGame; +import pp.mdga.message.client.LobbyNotReady; +import pp.mdga.message.client.LobbyReady; +import pp.mdga.message.client.NoPowerCard; +import pp.mdga.message.client.RequestBriefing; +import pp.mdga.message.client.RequestDice; +import pp.mdga.message.client.RequestMove; +import pp.mdga.message.client.RequestPlayCard; +import pp.mdga.message.client.SelectCard; +import pp.mdga.message.client.SelectTSK; +import pp.mdga.message.client.SelectedPieces; +import pp.mdga.message.server.ServerMessage; +import pp.mdga.server.Animation; +import pp.mdga.server.Ceremony; +import pp.mdga.server.ChoosePiece; +import pp.mdga.server.ChoosePieceStateMachine; +import pp.mdga.server.DetermineStartPlayer; +import pp.mdga.server.FirstRoll; +import pp.mdga.server.GameState; +import pp.mdga.server.GameStateMachine; +import pp.mdga.server.Interrupt; +import pp.mdga.server.Lobby; +import pp.mdga.server.MovePiece; +import pp.mdga.server.NoPiece; +import pp.mdga.server.PlayPowerCard; +import pp.mdga.server.PowerCard; +import pp.mdga.server.RollDice; +import pp.mdga.server.RollDiceMachine; +import pp.mdga.server.SecondRoll; +import pp.mdga.server.SelectPiece; +import pp.mdga.server.ServerAutomaton; import pp.mdga.server.ServerGameLogic; +import pp.mdga.server.ServerSender; +import pp.mdga.server.NoTurn; import pp.mdga.server.ServerState; +import pp.mdga.server.StartPiece; +import pp.mdga.server.ThirdRoll; +import pp.mdga.server.Turn; +import pp.mdga.server.TurnStateMachine; +import pp.mdga.server.WaitingPiece; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; public class ServerStateTest { + 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; + private int from; + + 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; + @Before - public void setUp(){ - ServerGameLogic logic = new ServerGameLogic(); + 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; + + choosePieceStateMachine = choosePiece.getChoosePieceMachine(); + rollDiceMachine = rollDice.getRollDicemachine(); + turnStateMachine = turn.getTurnStatemachine(); + serverAutomaton = new ServerAutomaton(logic); + 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); } @Test public void testInitialStateServerState() { - + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); } @Test public void testLobbyToDetermineStartPlayer() { - // TODO: Implement test logic for transition from Lobby to Determine Start Player + //tests if Server is in State Lobby + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + Lobby lobby = (Lobby) automaton.getState(); + //tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby + //TODO set one player not ready + lobby.receivedStartGame(clientStartGame, from); + assertTrue(automaton.getState() instanceof Lobby); + //tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP + //TODO set all player Ready + lobby.receivedStartGame(clientStartGame, from); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof DetermineStartPlayer); } @Test public void testStayInLobby() { - // TODO: Implement test logic for staying in the Lobby + //tests if Server is in State Lobby + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + + //lobby gets all possible messages + Lobby lobby = (Lobby) automaton.getState(); + + //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(automaton.getState() instanceof Lobby); } @Test @@ -35,11 +249,26 @@ public void testServerGameSubStatesToInterrupt() { @Test public void testServerGameToCeremony() { // TODO: Implement test logic for transition from Server Game to Ceremony + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof Lobby); + Lobby lobby = (Lobby) automaton.getState(); + //Todo set all players ready + logic.received(clientStartGame, from); + assertTrue(automaton.getState() instanceof GameState); + //Todo game is finished + assertTrue(automaton.getState() instanceof Ceremony); } @Test public void testInterruptToGameContinue() { - // TODO: Implement test logic for transition from Interrupt to Game Continue + //sends the server into the interrupt + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + automaton.gotoState(interrupt); + assertTrue(automaton.getState() instanceof Interrupt); + //sends the continue-message to the server + logic.received(forceContinueGame, from); + //tests if new Stet is in GameState + assertTrue(automaton.getState() instanceof GameState); } @Test @@ -58,23 +287,71 @@ public void testCeremonyToServerStateEndState() { } @Test - public void testDeterminStartPlayerToDetermineStartPlayer1() { - // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + public void testDetermineStartPlayerToDetermineStartPlayer1() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 1) + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + + logic.received(requestDice, from); + + assertTrue(automaton.getState() instanceof DetermineStartPlayer); + } @Test - public void testDeterminStartPlayerToDetermineStartPlayer2() { - // TODO: Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + public void testDetermineStartPlayerToDetermineStartPlayer2() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + // sends the server in determineStartPlayer + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input same dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof DetermineStartPlayer); } @Test - public void testDeterminStartPlayerToAnimation() { - // TODO: Implement test logic for Determine Start Player to Animation + public void testDetermineStartPlayerToAnimation() { + // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) + // sends the server in determineStartPlayer + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input different dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof Animation); } @Test public void testAnimationToPowerCard() { - // TODO: Implement test logic for transition from Animation to Power Card + ServerAutomaton automaton = (ServerAutomaton) logic.getState(); + assertTrue(automaton.getState() instanceof GameState); + GameState gameState = (GameState) automaton.getState(); + assertTrue(gameState.getState() instanceof GameStateMachine); + GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); + //Todo: input different dices for both players + logic.received(requestDice, from); + logic.received(requestDice, 1235); + assertTrue(automaton.getState() instanceof Animation); + logic.received(animationEnd, from); + assertTrue(gameStateMachine.getState() instanceof Animation); + logic.received(animationEnd, 1235); + assertTrue(gameStateMachine.getState() instanceof Turn); + TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState(); + assertTrue(turnStateMachine.getState() instanceof PowerCard); } @Test -- 2.43.0 From c204984a74e41d79346261596ebf95ca74d1eadd Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 16:03:12 +0100 Subject: [PATCH 04/15] edited a test in the clientStateTest --- .../client/clientState/ClientStateTest.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 8d8d23c7..bccd9618 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -414,7 +414,28 @@ public void testStayInLobby() { */ @Test public void testLobbyToRollRankingDice() { - // Implementation goes here + //sends the clientStatemachine in Lobby + assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); + dialogsStateMachine1.goto(lobby); + assertTrue(dialogsStateMachine1.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.getgameSatateMachine(); + assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); + + //tests if the clientStateMachine is in the RollRankingDice + DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = gameStateMachine1.getDetermineStartPlayerMachine(); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } /** -- 2.43.0 From a71619612a6fd347ad6cd60cd6239416ba55eb70 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 18:21:26 +0100 Subject: [PATCH 05/15] added the empty testmethods in serverstateTest and edited the testmethods for substates of choocePiece in Client into MovePiece --- .../client/clientState/ClientStateTest.java | 144 ++++++++++++- .../server/serverState/ServerStateTest.java | 198 ++++++++++++++++++ 2 files changed, 333 insertions(+), 9 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index bccd9618..cca467c6 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -13,7 +13,7 @@ import static org.junit.Assert.assertTrue; /** - * this test-class tests the testcases T232-T239 + * this test-class tests the testcases T232-T239 TODO */ public class ClientStateTest { @@ -211,7 +211,7 @@ public void testDialogsToGame() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1= clientAutomaton.getState(); + GameState gameState1 = clientAutomaton.getState(); GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.getState(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); @@ -840,7 +840,7 @@ public void testNoPieceInStartPiece() { */ @Test public void testNoPieceInWait() { - //TODO + //sends the ClientAutomaton in GameState clientAutomaton.goto(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); @@ -872,7 +872,28 @@ public void testNoPieceInWait() { */ @Test public void testStayInWaitingPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(waitingPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + + //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change + + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } /** @@ -880,7 +901,28 @@ public void testStayInWaitingPiece() { */ @Test public void testWaitingPieceInChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in WaitingPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(waitingPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + + //Todo send the message to the clientGameLogic to force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** @@ -888,7 +930,28 @@ public void testWaitingPieceInChoosePieceEndState() { */ @Test public void testStayInSelectedPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(selectPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + + //Todo send all server messages which dont force a state change here + + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } /** @@ -896,7 +959,28 @@ public void testStayInSelectedPiece() { */ @Test public void testSelectedPieceInChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in SelectPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(selectPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + + //Todo send the message which force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** @@ -904,7 +988,28 @@ public void testSelectedPieceInChoosePieceEndState() { */ @Test public void testStayInStartPiece() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(startPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + + //todo send all messages which dont force a state change + + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } /** @@ -912,7 +1017,28 @@ public void testStayInStartPiece() { */ @Test public void testStartPieceToChoosePieceEndState() { - // Implementation goes here + //sends the ClientAutomaton in GameState + clientAutomaton.goto(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.goto(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in ChoosePiece + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.goto(choosePiece); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + + //sends the choosePieceStatemachine in StartPiece + ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); + choosePieceStateMachine1.goto(startPiece); + assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + + //Todo send the message which force a state change + + assertTrue(turnStateMachine1.getState() instanceof MovePiece); } /** diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 10bf1239..601ce827 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -368,4 +368,202 @@ public void testTurnToGameEndState() { public void testStayInPowerCard() { // TODO: Implement test logic for staying in Power Card state } + + /** + * Tests the transition from PowerCard state to PlayPowerCard state. + * UC-ServerState-17 + */ + @Test + public void testPowerCardToPlayPowerCard() { + // UC-ServerState-17 + } + + /** + * Tests the transition from PlayPowerCard state to RollDice state. + * UC-ServerState-18 + */ + @Test + public void testPlayPowerCardToRollDice() { + // UC-ServerState-18 + } + + /** + * Tests the transition from ChoosePiece state to MovePiece state. + * UC-ServerState-19 + */ + @Test + public void testChoosePieceToMovePiece() { + // UC-ServerState-19 + } + + /** + * Tests the transition from MovePiece state to TurnEndState. + * UC-ServerState-20 + */ + @Test + public void testMovePiecetoTurnEndState() { + // UC-ServerState-20 + } + + /** + * Tests the transition from MovePiece state to FirstRoll state. + * UC-ServerState-21 + */ + @Test + public void testMovePieceToFirstRoll() { + // UC-ServerState-21 + } + + /** + * Tests the transition from FirstRoll state to RollDiceEndState. + * UC-ServerState-22 + */ + @Test + public void testFirstRollToRollDiceEndState() { + // UC-ServerState-22 + } + + /** + * Tests the transition from FirstRoll state to SecondRoll state. + * UC-ServerState-23 + */ + @Test + public void testFirstRollToSecondRoll() { + // UC-ServerState-23 + } + + /** + * Tests the transition from SecondRoll state to RollDiceEndState. + * UC-ServerState-24 + */ + @Test + public void testSecondRollToRollDiceEndState() { + // UC-ServerState-24 + } + + /** + * Tests the transition from SecondRoll state to ThirdRoll state. + * UC-ServerState-25 + */ + @Test + public void testSecondRollToThirdRoll() { + // UC-ServerState-25 + } + + /** + * Tests the transition from ThirdRoll state to RollDiceEndState. + * UC-ServerState-26 + */ + @Test + public void testThirdRollToRollDiceEndState() { + // UC-ServerState-26 + } + + /** + * Tests the transition from ThirdRoll state to TurnEndState. + * UC-ServerState-27 + */ + @Test + public void testThirdRollToTurnEndState() { + // UC-ServerState-27 + } + + /** + * Tests the transition from NoPiece state to WaitingPiece state. + * UC-ServerState-28 + */ + @Test + public void testNoPieceToWaitingPiece() { + // UC-ServerState-28 + } + + /** + * Tests the transition from NoPiece state to NoTurn state. + * UC-ServerState-29 + */ + @Test + public void testNoPieceToNoTurn() { + // UC-ServerState-29 + } + + /** + * Tests the transition from NoTurn state to TurnEndState. + * UC-ServerState-30 + */ + @Test + public void testNoTurnToTurnEndState() { + // UC-ServerState-30 + } + + /** + * Tests that the system stays in the WaitingPiece state. + * UC-ServerState-31 + */ + @Test + public void testStayInWaitingPiece() { + // UC-ServerState-31 + } + + /** + * Tests the transition from WaitingPiece state to MovePiece state. + * UC-ServerState-32 + */ + @Test + public void testWaitingPieceToMovePiece() { + // UC-ServerState-32 + } + + /** + * Tests the transition from NoPiece state to SelectPiece state. + * UC-ServerState-33 + */ + @Test + public void testNoPieceToSelectPiece() { + // UC-ServerState-33 + } + + /** + * Tests the transition from NoPiece state to StartPiece state. + * UC-ServerState-34 + */ + @Test + public void testNoPieceToStartPiece() { + // UC-ServerState-34 + } + + /** + * Tests that the system stays in the SelectPiece state. + * UC-ServerState-35 + */ + @Test + public void testStayInSelectPiece() { + // UC-ServerState-35 + } + + /** + * Tests the transition from SelectPiece state to MovePiece state. + * UC-ServerState-36 + */ + @Test + public void testSelectPieceToMovePiece() { + // UC-ServerState-36 + } + + /** + * Tests that the system stays in the StartPiece state. + * UC-ServerState-37 + */ + @Test + public void testStayInStartPiece() { + // UC-ServerState-37 + } + + /** + * Tests the transition from StartPiece state to MovePiece state. + * UC-ServerState-38 + */ + @Test + public void testStartPieceToMovePiece() { + // UC-ServerState-38 + } } -- 2.43.0 From 56492cdda608278309e123c14f98448e876eb560 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 18:40:10 +0100 Subject: [PATCH 06/15] added some mor testcases for the clientstatemachine --- .../client/clientState/ClientStateTest.java | 264 ++++++++++++++---- 1 file changed, 203 insertions(+), 61 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index cca467c6..7482ede1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -236,7 +236,7 @@ public void testDialogsToClientStateEndState() { public void testClientGameToCeremony() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); @@ -259,7 +259,7 @@ public void testClientGameToCeremony() { @Test public void testClientGameSubStatesToInterrupt() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); @@ -286,7 +286,7 @@ public void testGameToDialogs() { public void testStayInInterrupt() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -301,7 +301,7 @@ public void testStayInInterrupt() { public void testClientInterruptToGame() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -316,7 +316,7 @@ public void testClientInterruptToGame() { public void testInterruptToDialogs() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(interrupt); + clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); @@ -331,7 +331,7 @@ public void testInterruptToDialogs() { public void testCeremonyToDialogs() { // Todo Implementation goes here //send the client in the ceremony - clientAutomaton.goto(ceremony); + clientAutomaton.gotoState(ceremony); assertTrue(clientAutomaton.getStates() instanceof Ceremony); //Todo @@ -418,7 +418,7 @@ public void testLobbyToRollRankingDice() { assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); - dialogsStateMachine1.goto(lobby); + dialogsStateMachine1.gotoState(lobby); assertTrue(dialogsStateMachine1.getState() instanceof Lobby); //sends the message to start the game @@ -453,14 +453,14 @@ public void testDetermineStartPlayerToWait() { public void testWaitToAnimation() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); //sends the client in WaitState GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a piece is moved,that the client goes into Animation @@ -468,7 +468,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation @@ -476,7 +476,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.goto(waiting); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Waiting); //tests if a die is rolled,that the client goes into Animation @@ -491,12 +491,12 @@ public void testWaitToAnimation() { public void testWaitToTurn() { //TODo //sends client in gameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(wait); + gameStateMachine1.gotoState(wait); assertTrue(gameStateMachine1.getState() instanceof Turn); //the client receives the message ActivePlayer @@ -577,17 +577,17 @@ public void testPowerCardSubStatesToRollDice() { public void testStayInPlayPowerCard() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(playPowerCard); + turnStateMachine1.gotoState(playPowerCard); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); //Todo send messages to test to stay in playPowerCard @@ -601,17 +601,17 @@ public void testStayInPlayPowerCard() { public void testPlayPowerCardToRollDice() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(playPowerCard); + turnStateMachine1.gotoState(playPowerCard); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); //Todo send messages to test the transition in rollDice @@ -696,7 +696,31 @@ public void testStayInChoosePowerCard() { */ @Test public void testChoosePowerCardToRollDice() { - // Implementation goes here + + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to rollDice + + //tests if the turnStateMachine is in RollDice + assertTrue(turnStateMachine1.getState() instanceof RollDice); } /** @@ -704,7 +728,31 @@ public void testChoosePowerCardToRollDice() { */ @Test public void testChoosePowerCardToSwap() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to swap + + //tests if the client is in Swap + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof Swap); } /** @@ -712,7 +760,31 @@ public void testChoosePowerCardToSwap() { */ @Test public void testChoosePowerCardToShield() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in ChoosePiece + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(choosePowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + + //todo send the messages, to force a state change to shield + + //tests if the client is in Shield + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof Shield); } /** @@ -720,7 +792,31 @@ public void testChoosePowerCardToShield() { */ @Test public void testStayInShield() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in Shield + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(shield); + assertTrue(powerCardStateMachine1.getState() instanceof Shield); + + //todo send the messages, which dont force a statechange + + //tests if the client is in PlayPowerCard + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -728,7 +824,30 @@ public void testStayInShield() { */ @Test public void testShieldToPowerCardEndState() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.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(turnStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -736,7 +855,30 @@ public void testShieldToPowerCardEndState() { */ @Test public void testSwapToPowerCardEndState() { - // Implementation goes here + //TODO + //sends the ClientAutomaton in GameState + clientAutomaton.gotoState(gameState); + assertTrue(clientAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in the Turn + GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); + gameStateMachine1.gotoState(turn); + assertTrue(gameStateMachine1.getState() instanceof Turn); + + //sends the turnStatemachine in PowerCard + TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); + turnStateMachine1.gotoState(powerCard); + assertTrue(turnStateMachine1.getState() instanceof PowerCard); + + //sends the turnStatemachine in Swap + PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); + powerCardStateMachine1.gotoState(swap); + assertTrue(powerCardStateMachine1.getState() instanceof Swap); + + //todo send the message to force the statechange + + //tests if the client is in PlayPowerCard + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } /** @@ -746,17 +888,17 @@ public void testSwapToPowerCardEndState() { public void testNoPieceInWaitingPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -778,17 +920,17 @@ public void testNoPieceInWaitingPiece() { public void testNoPieceInSelectedPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -810,17 +952,17 @@ public void testNoPieceInSelectedPiece() { public void testNoPieceInStartPiece() { //TODO //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -842,17 +984,17 @@ public void testNoPieceInStartPiece() { public void testNoPieceInWait() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece @@ -873,22 +1015,22 @@ public void testNoPieceInWait() { @Test public void testStayInWaitingPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(waitingPiece); + choosePieceStateMachine1.gotoState(waitingPiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change @@ -902,22 +1044,22 @@ public void testStayInWaitingPiece() { @Test public void testWaitingPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(waitingPiece); + choosePieceStateMachine1.gotoState(waitingPiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); //Todo send the message to the clientGameLogic to force a state change @@ -931,22 +1073,22 @@ public void testWaitingPieceInChoosePieceEndState() { @Test public void testStayInSelectedPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(selectPiece); + choosePieceStateMachine1.gotoState(selectPiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); //Todo send all server messages which dont force a state change here @@ -960,22 +1102,22 @@ public void testStayInSelectedPiece() { @Test public void testSelectedPieceInChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(selectPiece); + choosePieceStateMachine1.gotoState(selectPiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); //Todo send the message which force a state change @@ -989,22 +1131,22 @@ public void testSelectedPieceInChoosePieceEndState() { @Test public void testStayInStartPiece() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(startPiece); + choosePieceStateMachine1.gotoState(startPiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); //todo send all messages which dont force a state change @@ -1018,22 +1160,22 @@ public void testStayInStartPiece() { @Test public void testStartPieceToChoosePieceEndState() { //sends the ClientAutomaton in GameState - clientAutomaton.goto(gameState); + clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.goto(turn); + gameStateMachine1.gotoState(turn); assertTrue(gameStateMachine1.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.goto(choosePiece); + turnStateMachine1.gotoState(choosePiece); assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.goto(startPiece); + choosePieceStateMachine1.gotoState(startPiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); //Todo send the message which force a state change -- 2.43.0 From 2a97ede98514d4df4eb289fd42f597023d2f7d41 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 19:03:19 +0100 Subject: [PATCH 07/15] added some testmethods for the client testing the statechanges in the dialogs --- .../client/clientState/ClientStateTest.java | 142 ++++++++++++++++-- 1 file changed, 128 insertions(+), 14 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 7482ede1..eb67dc7a 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -314,14 +314,17 @@ public void testClientInterruptToGame() { */ @Test public void testInterruptToDialogs() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //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); } /** @@ -329,12 +332,21 @@ public void testInterruptToDialogs() { */ @Test public void testCeremonyToDialogs() { - // Todo Implementation goes here //send the client in the ceremony clientAutomaton.gotoState(ceremony); - assertTrue(clientAutomaton.getStates() instanceof Ceremony); + assertTrue(clientAutomaton.getState() instanceof Ceremony); - //Todo + //sends the ceremony machine in the statistics + CeremonyStateMachine ceremonyStateMachine1 = ceremony.getCeremonyStateMachine(); + ceremonyStateMachine1.gotoState(statistics); + assertTrue(ceremonyStateMachine1.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); } /** @@ -342,7 +354,19 @@ public void testCeremonyToDialogs() { */ @Test public void testStartDialogToNetworkDialog1() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(startDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -350,7 +374,19 @@ public void testStartDialogToNetworkDialog1() { */ @Test public void testStartDialogToNetworkDialog2() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in StartDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(startDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + + //todo simulate pushBtn as client or host + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -359,6 +395,7 @@ public void testStartDialogToNetworkDialog2() { @Test public void testStartDialogToDialogsEndState() { // Implementation goes here + //TODO how to test? } /** @@ -366,7 +403,19 @@ public void testStartDialogToDialogsEndState() { */ @Test public void testNetworkDialogToStartDialog() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate pushBtn + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -374,7 +423,19 @@ public void testNetworkDialogToStartDialog() { */ @Test public void testNetworkDialogToNetworkDialog1() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo test receiving all messages and making input + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -382,7 +443,24 @@ public void testNetworkDialogToNetworkDialog1() { */ @Test public void testNetworkDialogToNetworkDialog2() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate try connect to server ith wrong variables + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate try connect to server with send: join-lobby and receive lobby-refuse-message + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); } /** @@ -390,7 +468,19 @@ public void testNetworkDialogToNetworkDialog2() { */ @Test public void testNetworkDialogToLobby() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in NetworkDialog + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(networkDialog); + assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + + //todo simulate connect to server with send lobby request + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); } /** @@ -398,7 +488,19 @@ public void testNetworkDialogToLobby() { */ @Test public void testLobbyToStartDialog() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(lobby); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //todo simulate leave the lobby + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -406,7 +508,19 @@ public void testLobbyToStartDialog() { */ @Test public void testStayInLobby() { - // Implementation goes here + // sends the clientAutomaton in StartDialog + clientAutomaton.gotoState(dialogs); + assertTrue(clientAutomaton.getState() instanceof Dialogs); + + //sends the DialogsStateMachine in Lobby + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); + dialogsStateMachine1.gotoState(lobby); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //todo send all messages that dont indicate a change-state + + assertTrue(clientAutomaton.getState() instanceof Dialogs); + assertTrue(dialogsStateMachine1.getState() instanceof Lobby); } /** -- 2.43.0 From 4c078ab0e25543dd1bf84e70d3312394671db9eb Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 19:37:03 +0100 Subject: [PATCH 08/15] added some testmethods and corrected other in the clientStatemachineTests --- .../client/clientState/ClientStateTest.java | 77 ++++++++++++++++--- 1 file changed, 67 insertions(+), 10 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index eb67dc7a..96fd2f57 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -191,8 +191,10 @@ public void setUp() { public void testInitialStateClientState() { //tests if the clientAutomaton is in Dialogs assertTrue(clientAutomaton.getState() instanceof Dialogs); + Dialogs dialogs = (Dialogs) clientAutomaton.getState(); + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); //tests if the statemachine is in StartDialog - assertTrue(dialogsStateMachine.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } /** @@ -200,8 +202,8 @@ public void testInitialStateClientState() { */ @Test public void testDialogsToGame() { - //TODO //tests if the client is in Dialogs + clientAutomaton.gotoState(dialogs); assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the startGame-Message to the client @@ -212,12 +214,12 @@ public void testDialogsToGame() { //tests if the new State of the GameStateMachine is in DetermineStartPlayer GameState gameState1 = clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = (GameStateMachine) gameState1.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 = (DetermineStartPlayerStateMachine) determineStartPlayer1.getState(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); assertTrue(DetermineStartPlayerStateMachine.getState() instanceof RollRankingDice); } @@ -234,7 +236,6 @@ public void testDialogsToClientStateEndState() { */ @Test public void testClientGameToCeremony() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); @@ -249,7 +250,7 @@ public void testClientGameToCeremony() { //tests if the state of ceremony is Podium Ceremony ceremony1 = (Ceremony) clientAutomaton.getState(); - CeremonyStateMachine ceremonyStateMachine1 = (CeremonyStateMachine) ceremony1.getState(); + CeremonyStateMachine ceremonyStateMachine1 = ceremony1.getCeremonyStateMachine(); assertTrue(ceremonyStateMachine1.getState() instanceof Podium); } @@ -284,14 +285,15 @@ public void testGameToDialogs() { */ @Test public void testStayInInterrupt() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //Todo send all messages except the continue-message + + assertTrue(clientAutomaton.getState() instanceof Interrupt); } /** @@ -299,14 +301,16 @@ public void testStayInInterrupt() { */ @Test public void testClientInterruptToGame() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(interrupt); //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); - //Todo + //Todo sends the continue-message + + //tests if the client is in the game + assertTrue(clientAutomaton.getState() instanceof GameState); } /** @@ -579,6 +583,7 @@ public void testWaitToAnimation() { //tests if a piece is moved,that the client goes into Animation clientGameLogic.receive(moveMessage); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState @@ -587,6 +592,7 @@ public void testWaitToAnimation() { //tests if a powerCard is played,that the client goes into Animation clientGameLogic.receive(playCard); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); //sends the client in WaitState @@ -595,6 +601,7 @@ public void testWaitToAnimation() { //tests if a die is rolled,that the client goes into Animation clientGameLogic.receive(dice); //Todo ??? richtige message + assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine1.getState() instanceof Animation); } @@ -616,6 +623,9 @@ public void testWaitToTurn() { //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(gameStateMachine1.getState() instanceof Turn); @@ -706,6 +716,11 @@ public void testStayInPlayPowerCard() { //Todo send messages to test to stay in playPowerCard + //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + } /** @@ -731,6 +746,10 @@ public void testPlayPowerCardToRollDice() { //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(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof RollDice); } /** @@ -834,6 +853,8 @@ public void testChoosePowerCardToRollDice() { //todo send the messages, to force a state change to rollDice //tests if the turnStateMachine is in RollDice + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof RollDice); } @@ -865,6 +886,8 @@ public void testChoosePowerCardToSwap() { //todo send the messages, to force a state change to swap //tests if the client is in Swap + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof Swap); } @@ -897,6 +920,8 @@ public void testChoosePowerCardToShield() { //todo send the messages, to force a state change to shield //tests if the client is in Shield + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof Shield); } @@ -929,6 +954,8 @@ public void testStayInShield() { //todo send the messages, which dont force a statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PowerCard); assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); } @@ -961,6 +988,8 @@ public void testShieldToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } @@ -992,6 +1021,8 @@ public void testSwapToPowerCardEndState() { //todo send the message to force the statechange //tests if the client is in PlayPowerCard + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); } @@ -1024,6 +1055,9 @@ public void testNoPieceInWaitingPiece() { //sends to the clientGameLogic the message WaitPiece clientGameLogic.receive(waitPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } @@ -1056,6 +1090,9 @@ public void testNoPieceInSelectedPiece() { //sends to the clientGameLogic the message SelectPiece clientGameLogic.receive(selectPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } @@ -1088,6 +1125,9 @@ public void testNoPieceInStartPiece() { //sends to the clientGameLogic the message StartPiece clientGameLogic.receive(startPiece); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } @@ -1120,6 +1160,8 @@ public void testNoPieceInWait() { //sends to the clientGameLogic the message NoTurn clientGameLogic.receive(noTurn); + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof Waiting); } @@ -1149,6 +1191,9 @@ public void testStayInWaitingPiece() { //TODO send all sever-messages except ... to the clientGameLogic to test there are no state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); } @@ -1178,6 +1223,8 @@ public void testWaitingPieceInChoosePieceEndState() { //Todo send the message to the clientGameLogic to force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } @@ -1207,6 +1254,9 @@ public void testStayInSelectedPiece() { //Todo send all server messages which dont force a state change here + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); } @@ -1236,6 +1286,8 @@ public void testSelectedPieceInChoosePieceEndState() { //Todo send the message which force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } @@ -1265,6 +1317,9 @@ public void testStayInStartPiece() { //todo send all messages which dont force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); } @@ -1294,6 +1349,8 @@ public void testStartPieceToChoosePieceEndState() { //Todo send the message which force a state change + assertTrue(clientAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine1.getState() instanceof Turn); assertTrue(turnStateMachine1.getState() instanceof MovePiece); } -- 2.43.0 From 1821a222e9bf958267cd8aaf693fbb39e4622555 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Sun, 24 Nov 2024 22:24:39 +0100 Subject: [PATCH 09/15] minor changes --- .../client/clientState/ClientStateTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 96fd2f57..2e943d98 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -67,7 +67,7 @@ public class ClientStateTest { private ActivePlayer activePlayer; private AnyPiece anyPiece; private Briefing briefing; - private Ceremony ceremonyMessage; + private CeremonyMessage ceremonyMessage; private Dice dice; private DiceAgain diceAgain; private DiceNow diceNow; @@ -82,7 +82,7 @@ public class ClientStateTest { private PlayCard playCard; private PossibleCard possibleCard; private PossiblePiece possiblePiece; - private RankingResponce rankingResponce; + private RankingResponse rankingResponce; private RankingRollAgain rankingRollAgain; private ReconnectBriefing reconnectBriefing; private ResumeGame resumeGame; @@ -100,7 +100,7 @@ public void setUp() { activePlayer = new ActivePlayer(); anyPiece = new AnyPiece(); briefing = new Briefing(); - ceremonyMessage = new Ceremony(); + ceremonyMessage = new CeremonyMessage(); dice = new Dice(); diceAgain = new DiceAgain(); diceNow = new DiceNow(); @@ -115,7 +115,7 @@ public void setUp() { playCard = new PlayCard(); possibleCard = new PossibleCard(); possiblePiece = new PossiblePiece(); - rankingResponce = new RankingResponce(); + rankingResponce = new RankingResponse(); rankingRollAgain = new RankingRollAgain(); reconnectBriefing = new ReconnectBriefing(); resumeGame = new ResumeGame(); @@ -137,13 +137,13 @@ public void setUp() { //initialize the stateMachines ceremonyStateMachine =ceremony.getCeremonyStateMachine(); - choosePieceStateMachine = choosePiece.getChoosePieceMachine(); - determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerMachine(); + choosePieceStateMachine = choosePiece.getChoosePieceStateMachine(); + determineStartPlayerStateMachine = determineStartPlayer.getDetermineStartPlayerStateMachine(); dialogsStateMachine = dialogs.getDialogsStateMachine(); gameStateMachine = gameState.getGameStateMachine(); - powerCardStateMachine = powerCard.getPowerCardMachine(); + powerCardStateMachine = powerCard.getPowerCardStateMachine(); settingsStateMachine = settings.getSettingsStateMachine(); - turnStateMachine = turn.getTurnMachine(); + turnStateMachine = turn.getTurnStateMachine(); //initialize the states @@ -213,14 +213,14 @@ public void testDialogsToGame() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if the new State of the GameStateMachine is in DetermineStartPlayer - GameState gameState1 = clientAutomaton.getState(); + 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(DetermineStartPlayerStateMachine.getState() instanceof RollRankingDice); + assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } /** @@ -547,12 +547,12 @@ public void testLobbyToRollRankingDice() { //tests if the clientStateMachine is in the DetermineStartPlayer GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getgameSatateMachine(); + GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the clientStateMachine is in the RollRankingDice DetermineStartPlayer determineStartPlayer1 = (DetermineStartPlayer) gameStateMachine1.getState(); - DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = gameStateMachine1.getDetermineStartPlayerMachine(); + DetermineStartPlayerStateMachine determineStartPlayerStateMachine1 = determineStartPlayer1.getDetermineStartPlayerStateMachine(); assertTrue(determineStartPlayerStateMachine1.getState() instanceof RollRankingDice); } @@ -617,7 +617,7 @@ public void testWaitToTurn() { //sends the gameStateMachine in the Turn GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(wait); + gameStateMachine1.gotoState(waiting); assertTrue(gameStateMachine1.getState() instanceof Turn); //the client receives the message ActivePlayer -- 2.43.0 From f7bd9a0f389603c6abdb5503752cf4ab9abc59cb Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 00:20:47 +0100 Subject: [PATCH 10/15] edited some tests in ServerStateTest --- .../client/clientState/ClientStateTest.java | 64 +++- .../server/serverState/ServerStateTest.java | 338 ++++++++++++------ 2 files changed, 274 insertions(+), 128 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 2e943d98..c5ad8c70 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -5,10 +5,13 @@ 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.assertTrue; @@ -79,59 +82,88 @@ public class ClientStateTest { private MoveMessage moveMessage; private NoTurn noTurn; private PauseGame pauseGame; - private PlayCard playCard; 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() { - // This method will be executed before each test. - // Initialize common objects or setup required state for Client State transitions. + //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(); + activePlayer = new ActivePlayer(color); anyPiece = new AnyPiece(); briefing = new Briefing(); ceremonyMessage = new CeremonyMessage(); - dice = new Dice(); + dice = new Dice(6,new ArrayList<>()); diceAgain = new DiceAgain(); diceNow = new DiceNow(); endOfTurn = new EndOfTurn(); lobbyAccept = new LobbyAccept(); lobbyDeny = new LobbyDeny(); - lobbyPlayerJoin = new LobbyPlayerJoin(); - lobbyPlayerLeave = new LobbyPlayerLeave(); + lobbyPlayerJoin = new LobbyPlayerJoin(name); + lobbyPlayerLeave = new LobbyPlayerLeave(name,color); moveMessage = new MoveMessage(); noTurn = new NoTurn(); pauseGame = new PauseGame(); - playCard = new PlayCard(); + playCardSwap = new PlayCard(swapCard); + playCardShield = new PlayCard(shieldCard); + playCardTurbo = new PlayCard(turboCard); possibleCard = new PossibleCard(); possiblePiece = new PossiblePiece(); rankingResponce = new RankingResponse(); rankingRollAgain = new RankingRollAgain(); - reconnectBriefing = new ReconnectBriefing(); + reconnectBriefing = new ReconnectBriefing(game); resumeGame = new ResumeGame(); + startGame = new ServerStartGame(); startPieceMessage = new StartPiece(); updateReady = new UpdateReady(); updateTSK = new UpdateTSK(); waitPiece = new WaitPiece(); //initialize the clientGameLogic - clientGameLogic = new ClientGameLogic(); + clientGameLogic = new ClientGameLogic(game, new ClientSender() { + @Override + public void send(ClientMessage msg) { + + } + }); clientAutomaton = (ClientAutomaton) clientGameLogic.getState(); //initialize the settings - mainSettings = new MainSettings(); - videoSettings = new VideoSettings(); - audioSettings = new AudioSettings(); + mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); + videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); + audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); settings = new Settings(); @@ -535,7 +567,7 @@ public void testLobbyToRollRankingDice() { //sends the clientStatemachine in Lobby assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = lobby.getDialogsStatemachine(); + DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); dialogsStateMachine1.gotoState(lobby); assertTrue(dialogsStateMachine1.getState() instanceof Lobby); @@ -547,7 +579,7 @@ public void testLobbyToRollRankingDice() { //tests if the clientStateMachine is in the DetermineStartPlayer GameState gameState1 = (GameState) clientAutomaton.getState(); - GameStateMachine gameStateMachine1 = gameState1.getGameSatateMachine(); + GameStateMachine gameStateMachine1 = gameState1.getGameStateMachine(); assertTrue(gameStateMachine1.getState() instanceof DetermineStartPlayer); //tests if the clientStateMachine is in the RollRankingDice diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 601ce827..a4c22254 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -51,7 +51,6 @@ import pp.mdga.server.TurnStateMachine; import pp.mdga.server.WaitingPiece; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -79,7 +78,9 @@ public class ServerStateTest { private SelectedPieces selectedPieces; private SelectTSK selectTSK; private ClientMessage[] clientMessages; + private int from; + private int fromHost; private GameStateMachine gameStateMachine; private TurnStateMachine turnStateMachine; @@ -152,74 +153,69 @@ public void send(int id, ServerMessage msg) { selectedPieces, selectTSK }; - from=1234; + from = 1234; + fromHost = 2345; choosePieceStateMachine = choosePiece.getChoosePieceMachine(); rollDiceMachine = rollDice.getRollDicemachine(); turnStateMachine = turn.getTurnStatemachine(); - serverAutomaton = new ServerAutomaton(logic); + serverAutomaton = logic.getServerAutomaton(); gameStateMachine = gameState.getGameStatemachine(); - thirdRoll = new ThirdRoll(rollDiceMachine,logic); - secondRoll = new SecondRoll(rollDiceMachine,logic); - firstRoll = new FirstRoll(rollDiceMachine,logic); + 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); + 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); + 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); + 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); + lobby = new Lobby(serverAutomaton, logic); + gameState = new GameState(serverAutomaton, logic); + ceremony = new Ceremony(serverAutomaton, logic); + interrupt = new Interrupt(serverAutomaton, logic, gameState); } @Test public void testInitialStateServerState() { - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); } @Test public void testLobbyToDetermineStartPlayer() { - //tests if Server is in State Lobby - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); - Lobby lobby = (Lobby) automaton.getState(); - //tests, when not all players are ready and the hosts send clientStartGame, that the Server stays in Lobby - //TODO set one player not ready - lobby.receivedStartGame(clientStartGame, from); - assertTrue(automaton.getState() instanceof Lobby); - //tests, when all players are ready and the hosts send clientStartGame, that the Server changes to DSP - //TODO set all player Ready - lobby.receivedStartGame(clientStartGame, from); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof DetermineStartPlayer); + //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); } @Test public void testStayInLobby() { - //tests if Server is in State Lobby - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); + //sends the server in the lobby-state + serverAutomaton.gotoState(lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); - //lobby gets all possible messages - Lobby lobby = (Lobby) automaton.getState(); - - //logic gets all messages + //TODO logic gets all messages logic.received(animationEnd, from); logic.received(clientStartGame, from); logic.received(deselectTSK, from); @@ -238,135 +234,209 @@ public void testStayInLobby() { logic.received(selectTSK, from); //tests if Server is still in Lobby - assertTrue(automaton.getState() instanceof Lobby); + assertTrue(serverAutomaton.getState() instanceof Lobby); } @Test public void testServerGameSubStatesToInterrupt() { - // TODO: Implement test logic for transition from Server Game Sub-States to Interrupt + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); //TODO könnte auch auf gleichheit prüfen + + //TODO create interrupt + + //tests if the server is in the Interrupt-state + assertTrue(serverAutomaton.getState() instanceof Interrupt); } + /** + * tests the state-change from Game to Ceremony if the Game is finished + */ @Test public void testServerGameToCeremony() { - // TODO: Implement test logic for transition from Server Game to Ceremony - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof Lobby); - Lobby lobby = (Lobby) automaton.getState(); - //Todo set all players ready - logic.received(clientStartGame, from); - assertTrue(automaton.getState() instanceof GameState); + //sends the server in the gameState + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + //Todo game is finished - assertTrue(automaton.getState() instanceof Ceremony); + + //tests if the server is in the Ceremony-state + assertTrue(serverAutomaton.getState() instanceof Ceremony); } @Test public void testInterruptToGameContinue() { - //sends the server into the interrupt - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - automaton.gotoState(interrupt); - assertTrue(automaton.getState() instanceof Interrupt); + //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(automaton.getState() instanceof GameState); + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testInterruptToGameReconnect() { - // TODO: Implement test logic for transition from Interrupt to Game Reconnect + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testInterruptToGameTimer() { - // TODO: Implement test logic for transition from Interrupt to Game Timer + //sends the server in the Interrupt-State + serverAutomaton.gotoState(interrupt); + assertTrue(serverAutomaton.getState() instanceof Interrupt); + + //Todo implement the timer + + //tests if new Stet is in GameState + assertTrue(serverAutomaton.getState() instanceof GameState); } @Test public void testCeremonyToServerStateEndState() { // TODO: Implement test logic for transition from Ceremony to Server State End State + // TODO how???? } @Test public void testDetermineStartPlayerToDetermineStartPlayer1() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 1) - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //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); - logic.received(requestDice, from); - - assertTrue(automaton.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); } @Test public void testDetermineStartPlayerToDetermineStartPlayer2() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) - // sends the server in determineStartPlayer - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //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); - //Todo: input same dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof DetermineStartPlayer); } @Test public void testDetermineStartPlayerToAnimation() { - // Implement test logic for Determine Start Player to Determine Start Player (Variant 2) - // sends the server in determineStartPlayer - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); + //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: input different dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof Animation); + + //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); } @Test public void testAnimationToPowerCard() { - ServerAutomaton automaton = (ServerAutomaton) logic.getState(); - assertTrue(automaton.getState() instanceof GameState); - GameState gameState = (GameState) automaton.getState(); - assertTrue(gameState.getState() instanceof GameStateMachine); - GameStateMachine gameStateMachine = (GameStateMachine) gameState.getState(); - assertTrue(gameStateMachine.getState() instanceof DetermineStartPlayer); - //Todo: input different dices for both players - logic.received(requestDice, from); - logic.received(requestDice, 1235); - assertTrue(automaton.getState() instanceof Animation); - logic.received(animationEnd, from); + //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); - logic.received(animationEnd, 1235); + + //receives one animation endMessage and tests if the server is still in the Animation-state + logic.received(animationEnd, fromHost); + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); + + //receives another animation endMessage + logic.received(animationEnd, from); + + //tests if the server is in the PowerCard-state + assertTrue(serverAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine.getState() instanceof Turn); - TurnStateMachine turnStateMachine = (TurnStateMachine) automaton.getState(); + Turn turn1 = (Turn) gameStateMachine.getState(); + TurnStateMachine turnStateMachine = (TurnStateMachine) turn1.getTurnStateMachine(); assertTrue(turnStateMachine.getState() instanceof PowerCard); } @Test public void testTurnToAnimation() { - // TODO: Implement test logic for transition from Turn to Animation + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there are still two players left + + //tests if the server is in the AnimationState + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Animation); } @Test public void testTurnToGameEndState() { - // TODO: Implement test logic for transition from Turn to Game End State + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //todo set the turn finished and there is only one players left + + //tests if the server is in the end-state of game, Ceremony + assertTrue(serverAutomaton.getState() instanceof Ceremony); } @Test public void testStayInPowerCard() { - // TODO: Implement test logic for staying in Power Card state + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //Todo: receive messages which dont lead to a state change + + //tests if the server is in PowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); } /** @@ -375,7 +445,24 @@ public void testStayInPowerCard() { */ @Test public void testPowerCardToPlayPowerCard() { - // UC-ServerState-17 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + + //todo + + //tests if the server is in PlayPowerCard + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -384,7 +471,34 @@ public void testPowerCardToPlayPowerCard() { */ @Test public void testPlayPowerCardToRollDice() { - // UC-ServerState-18 + //sends the server in Game-State + serverAutomaton.gotoState(gameState); + assertTrue(serverAutomaton.getState() instanceof GameState); + + //sends the gameStateMachine in Turn + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); + + //sends the TurnStateMachine in PowerCard + turnStateMachine.gotoState(playPowerCard); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive first AnimationEndMessage from the host + logic.received(animationEnd, fromHost); + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); + + //receive second AnimationEndMessage + logic.received(animationEnd, from); + + //tests if the server is in RollDice and in FirstRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + RollDice rollDice = (RollDice) turnStateMachine.getState(); + RollDiceMachine rollDiceMachine1 = rollDice.getRollDiceStateMachine(); + assertTrue(rollDiceMachine1.getState() instanceof FirstRoll); } /** -- 2.43.0 From aa88dff56607e3b995f98b24e77b329e2201da7b Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 00:36:59 +0100 Subject: [PATCH 11/15] added tests in the serverStateTest added the testmethods for rolldice and movepiece --- .../server/serverState/ServerStateTest.java | 124 ++++++++++++++++-- 1 file changed, 116 insertions(+), 8 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index a4c22254..edf40cd1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -44,7 +44,6 @@ import pp.mdga.server.ServerGameLogic; import pp.mdga.server.ServerSender; import pp.mdga.server.NoTurn; -import pp.mdga.server.ServerState; import pp.mdga.server.StartPiece; import pp.mdga.server.ThirdRoll; import pp.mdga.server.Turn; @@ -507,7 +506,23 @@ public void testPlayPowerCardToRollDice() { */ @Test public void testChoosePieceToMovePiece() { - // UC-ServerState-19 + //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); } /** @@ -515,8 +530,22 @@ public void testChoosePieceToMovePiece() { * UC-ServerState-20 */ @Test - public void testMovePiecetoTurnEndState() { - // UC-ServerState-20 + 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 + } /** @@ -525,7 +554,26 @@ public void testMovePiecetoTurnEndState() { */ @Test public void testMovePieceToFirstRoll() { - // UC-ServerState-21 + //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); } /** @@ -534,7 +582,23 @@ public void testMovePieceToFirstRoll() { */ @Test public void testFirstRollToRollDiceEndState() { - // UC-ServerState-22 + //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 } /** @@ -543,7 +607,29 @@ public void testFirstRollToRollDiceEndState() { */ @Test public void testFirstRollToSecondRoll() { - // UC-ServerState-23 + //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); } /** @@ -561,7 +647,29 @@ public void testSecondRollToRollDiceEndState() { */ @Test public void testSecondRollToThirdRoll() { - // UC-ServerState-25 + //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 ThirdRoll + assertTrue(serverAutomaton.getState() instanceof GameState); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); + assertTrue(rollDiceMachine.getState() instanceof ThirdRoll); } /** -- 2.43.0 From 928304fb4bb9c15a3284d0eefd16749c6cf4ef06 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 01:24:11 +0100 Subject: [PATCH 12/15] corrected testmethods in clientStateTest --- .../client/clientState/ClientStateTest.java | 477 ++++++++---------- 1 file changed, 199 insertions(+), 278 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index c5ad8c70..25fe769a 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -261,6 +261,7 @@ public void testDialogsToGame() { @Test public void testDialogsToClientStateEndState() { //Todo Implementation goes here + //TODO how????????? } /** @@ -270,8 +271,6 @@ public void testDialogsToClientStateEndState() { public void testClientGameToCeremony() { //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 @@ -317,10 +316,8 @@ public void testGameToDialogs() { */ @Test public void testStayInInterrupt() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo send all messages except the continue-message @@ -333,10 +330,8 @@ public void testStayInInterrupt() { */ @Test public void testClientInterruptToGame() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo sends the continue-message @@ -350,9 +345,8 @@ public void testClientInterruptToGame() { */ @Test public void testInterruptToDialogs() { - //sends the ClientAutomaton in GameState + //sends the ClientAutomaton in Interrupt clientAutomaton.gotoState(interrupt); - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof Interrupt); //Todo send the server-closed message and the leave option @@ -373,9 +367,8 @@ public void testCeremonyToDialogs() { assertTrue(clientAutomaton.getState() instanceof Ceremony); //sends the ceremony machine in the statistics - CeremonyStateMachine ceremonyStateMachine1 = ceremony.getCeremonyStateMachine(); - ceremonyStateMachine1.gotoState(statistics); - assertTrue(ceremonyStateMachine1.getState() instanceof Statistics); + ceremonyStateMachine.gotoState(statistics); + assertTrue(ceremonyStateMachine.getState() instanceof Statistics); //Todo simulate the button next @@ -395,14 +388,13 @@ public void testStartDialogToNetworkDialog1() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in StartDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(startDialog); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); //todo simulate pushBtn as client or host assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -415,14 +407,13 @@ public void testStartDialogToNetworkDialog2() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in StartDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(startDialog); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + dialogsStateMachine.gotoState(startDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); //todo simulate pushBtn as client or host assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -444,14 +435,13 @@ public void testNetworkDialogToStartDialog() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate pushBtn assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); } /** @@ -464,14 +454,13 @@ public void testNetworkDialogToNetworkDialog1() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo test receiving all messages and making input assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -484,19 +473,18 @@ public void testNetworkDialogToNetworkDialog2() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate try connect to server ith wrong variables assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + 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(dialogsStateMachine1.getState() instanceof NetworkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); } /** @@ -509,14 +497,13 @@ public void testNetworkDialogToLobby() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in NetworkDialog - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(networkDialog); - assertTrue(dialogsStateMachine1.getState() instanceof NetworkDialog); + dialogsStateMachine.gotoState(networkDialog); + assertTrue(dialogsStateMachine.getState() instanceof NetworkDialog); //todo simulate connect to server with send lobby request assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); } /** @@ -529,14 +516,13 @@ public void testLobbyToStartDialog() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in Lobby - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); //todo simulate leave the lobby assertTrue(clientAutomaton.getState() instanceof Dialogs); - assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); + assertTrue(dialogsStateMachine.getState() instanceof StartDialog); } /** @@ -549,14 +535,13 @@ public void testStayInLobby() { assertTrue(clientAutomaton.getState() instanceof Dialogs); //sends the DialogsStateMachine in Lobby - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof 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(dialogsStateMachine1.getState() instanceof Lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); } /** @@ -564,12 +549,13 @@ public void testStayInLobby() { */ @Test public void testLobbyToRollRankingDice() { - //sends the clientStatemachine in Lobby + //sends the clientStatemachine in Dialogs + clientAutomaton.gotoState(dialogs); assertTrue(clientAutomaton.getState() instanceof Dialogs); - Dialogs dialogs1 = (Dialogs) clientAutomaton.getState(); - DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); - dialogsStateMachine1.gotoState(lobby); - assertTrue(dialogsStateMachine1.getState() instanceof Lobby); + + //sends the clientStatemachine in Lobby + dialogsStateMachine.gotoState(lobby); + assertTrue(dialogsStateMachine.getState() instanceof Lobby); //sends the message to start the game clientGameLogic.receive();//TODO message @@ -593,7 +579,7 @@ public void testLobbyToRollRankingDice() { */ @Test public void testDetermineStartPlayerToWait() { - // Implementation goes here + // Todo Implementation goes here } /** @@ -601,40 +587,36 @@ public void testDetermineStartPlayerToWait() { */ @Test public void testWaitToAnimation() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); - - //tests if the client is in GameState assertTrue(clientAutomaton.getState() instanceof GameState); //sends the client in WaitState - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + 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(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation clientGameLogic.receive(playCard); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); //sends the client in WaitState - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Waiting); + 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(gameStateMachine1.getState() instanceof Animation); + assertTrue(gameStateMachine.getState() instanceof Animation); } /** @@ -642,15 +624,13 @@ public void testWaitToAnimation() { */ @Test public void testWaitToTurn() { - //TODo //sends client in gameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); - //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(waiting); - assertTrue(gameStateMachine1.getState() instanceof Turn); + //sends the gameStateMachine in the Waiting + gameStateMachine.gotoState(waiting); + assertTrue(gameStateMachine.getState() instanceof Waiting); //the client receives the message ActivePlayer clientGameLogic.receive(activePlayer); @@ -659,7 +639,7 @@ public void testWaitToTurn() { assertTrue(clientAutomaton.getState() instanceof GameState); //tests if Client is in Turn - assertTrue(gameStateMachine1.getState() instanceof Turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //tests if Client is in PowerCard TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); @@ -731,28 +711,24 @@ public void testPowerCardSubStatesToRollDice() { */ @Test public void testStayInPlayPowerCard() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(playPowerCard); - assertTrue(turnStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); - + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -760,28 +736,25 @@ public void testStayInPlayPowerCard() { */ @Test public void testPlayPowerCardToRollDice() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PlayPowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(playPowerCard); - assertTrue(turnStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof RollDice); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); } /** @@ -868,26 +841,23 @@ public void testChoosePowerCardToRollDice() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof RollDice); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof RollDice); } /** @@ -895,33 +865,29 @@ public void testChoosePowerCardToRollDice() { */ @Test public void testChoosePowerCardToSwap() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof Swap); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Swap); } /** @@ -929,33 +895,29 @@ public void testChoosePowerCardToSwap() { */ @Test public void testChoosePowerCardToShield() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in ChoosePiece - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(choosePowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof ChoosePowerCard); + 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof Shield); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof Shield); } /** @@ -963,33 +925,29 @@ public void testChoosePowerCardToShield() { */ @Test public void testStayInShield() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof 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); + 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); - assertTrue(powerCardStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PowerCard); + assertTrue(powerCardStateMachine.getState() instanceof PlayPowerCard); } /** @@ -997,20 +955,17 @@ public void testStayInShield() { */ @Test public void testShieldToPowerCardEndState() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in Shield PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); @@ -1021,8 +976,8 @@ public void testShieldToPowerCardEndState() { //tests if the client is in PlayPowerCard assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -1030,32 +985,28 @@ public void testShieldToPowerCardEndState() { */ @Test public void testSwapToPowerCardEndState() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in PowerCard - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(powerCard); - assertTrue(turnStateMachine1.getState() instanceof PowerCard); + turnStateMachine.gotoState(powerCard); + assertTrue(turnStateMachine.getState() instanceof PowerCard); //sends the turnStatemachine in Swap - PowerCardStateMachine powerCardStateMachine1 = powerCard.getPowerCardStateMachine(); - powerCardStateMachine1.gotoState(swap); - assertTrue(powerCardStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof PlayPowerCard); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof PlayPowerCard); } /** @@ -1063,24 +1014,21 @@ public void testSwapToPowerCardEndState() { */ @Test public void testNoPieceInWaitingPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + turnStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1088,9 +1036,9 @@ public void testNoPieceInWaitingPiece() { clientGameLogic.receive(waitPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); } /** @@ -1098,24 +1046,21 @@ public void testNoPieceInWaitingPiece() { */ @Test public void testNoPieceInSelectedPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1123,9 +1068,9 @@ public void testNoPieceInSelectedPiece() { clientGameLogic.receive(selectPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -1133,24 +1078,21 @@ public void testNoPieceInSelectedPiece() { */ @Test public void testNoPieceInStartPiece() { - //TODO //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1158,9 +1100,9 @@ public void testNoPieceInStartPiece() { clientGameLogic.receive(startPiece); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -1168,24 +1110,21 @@ public void testNoPieceInStartPiece() { */ @Test public void testNoPieceInWait() { - //sends the ClientAutomaton in GameState clientAutomaton.gotoState(gameState); assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in NoPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - assertTrue(choosePieceStateMachine1.getState() instanceof NoPiece); + choosePieceStateMachine.gotoState(noPiece); + assertTrue(choosePieceStateMachine.getState() instanceof NoPiece); //Todo test other messages, that there is no state change @@ -1193,8 +1132,8 @@ public void testNoPieceInWait() { clientGameLogic.receive(noTurn); assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof Waiting); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof Waiting); } /** @@ -1207,26 +1146,23 @@ public void testStayInWaitingPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof WaitingPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof WaitingPiece); } /** @@ -1239,25 +1175,22 @@ public void testWaitingPieceInChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in WaitingPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(waitingPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** @@ -1270,26 +1203,23 @@ public void testStayInSelectedPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); - //sends the choosePieceStatemachine in SelectPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(selectPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + //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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); } /** @@ -1302,25 +1232,22 @@ public void testSelectedPieceInChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in SelectPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(selectPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof SelectPiece); + choosePieceStateMachine.gotoState(selectPiece); + assertTrue(choosePieceStateMachine.getState() instanceof SelectPiece); //Todo send the message which force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** @@ -1333,26 +1260,23 @@ public void testStayInStartPiece() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(startPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof 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(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); } /** @@ -1365,25 +1289,22 @@ public void testStartPieceToChoosePieceEndState() { assertTrue(clientAutomaton.getState() instanceof GameState); //sends the gameStateMachine in the Turn - GameStateMachine gameStateMachine1 = gameState.getGameStateMachine(); - gameStateMachine1.gotoState(turn); - assertTrue(gameStateMachine1.getState() instanceof Turn); + gameStateMachine.gotoState(turn); + assertTrue(gameStateMachine.getState() instanceof Turn); //sends the turnStatemachine in ChoosePiece - TurnStateMachine turnStateMachine1 = turn.getTurnStateMachine(); - turnStateMachine1.gotoState(choosePiece); - assertTrue(turnStateMachine1.getState() instanceof ChoosePiece); + turnStateMachine.gotoState(choosePiece); + assertTrue(turnStateMachine.getState() instanceof ChoosePiece); //sends the choosePieceStatemachine in StartPiece - ChoosePieceStateMachine choosePieceStateMachine1 = choosePiece.getChoosePieceStateMachine(); - choosePieceStateMachine1.gotoState(startPiece); - assertTrue(choosePieceStateMachine1.getState() instanceof StartPiece); + choosePieceStateMachine.gotoState(startPiece); + assertTrue(choosePieceStateMachine.getState() instanceof StartPiece); //Todo send the message which force a state change assertTrue(clientAutomaton.getState() instanceof GameState); - assertTrue(gameStateMachine1.getState() instanceof Turn); - assertTrue(turnStateMachine1.getState() instanceof MovePiece); + assertTrue(gameStateMachine.getState() instanceof Turn); + assertTrue(turnStateMachine.getState() instanceof MovePiece); } /** -- 2.43.0 From 2cfa328c4cd5313fb05361fff4fb77d0698442dc Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 01:50:02 +0100 Subject: [PATCH 13/15] added some more testmethods --- .../client/clientState/ClientStateTest.java | 2 - .../server/serverState/ServerStateTest.java | 389 +++++++++++++++--- 2 files changed, 321 insertions(+), 70 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 25fe769a..13833527 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -20,8 +20,6 @@ */ public class ClientStateTest { - - //sets the variables for the states private Animation animation; private AudioSettings audioSettings; diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index edf40cd1..15b1c7b1 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -3,61 +3,18 @@ import org.junit.Before; import org.junit.Test; import pp.mdga.game.Game; -import pp.mdga.message.client.AnimationEnd; -import pp.mdga.message.client.ClientMessage; -import pp.mdga.message.client.ClientStartGame; -import pp.mdga.message.client.DeselectTSK; -import pp.mdga.message.client.ForceContinueGame; -import pp.mdga.message.client.ForceStartGame; -import pp.mdga.message.client.JoinServer; -import pp.mdga.message.client.LeaveGame; -import pp.mdga.message.client.LobbyNotReady; -import pp.mdga.message.client.LobbyReady; -import pp.mdga.message.client.NoPowerCard; -import pp.mdga.message.client.RequestBriefing; -import pp.mdga.message.client.RequestDice; -import pp.mdga.message.client.RequestMove; -import pp.mdga.message.client.RequestPlayCard; -import pp.mdga.message.client.SelectCard; -import pp.mdga.message.client.SelectTSK; -import pp.mdga.message.client.SelectedPieces; +import pp.mdga.message.client.*; import pp.mdga.message.server.ServerMessage; -import pp.mdga.server.Animation; -import pp.mdga.server.Ceremony; -import pp.mdga.server.ChoosePiece; -import pp.mdga.server.ChoosePieceStateMachine; -import pp.mdga.server.DetermineStartPlayer; -import pp.mdga.server.FirstRoll; -import pp.mdga.server.GameState; -import pp.mdga.server.GameStateMachine; -import pp.mdga.server.Interrupt; -import pp.mdga.server.Lobby; -import pp.mdga.server.MovePiece; -import pp.mdga.server.NoPiece; -import pp.mdga.server.PlayPowerCard; -import pp.mdga.server.PowerCard; -import pp.mdga.server.RollDice; -import pp.mdga.server.RollDiceMachine; -import pp.mdga.server.SecondRoll; -import pp.mdga.server.SelectPiece; -import pp.mdga.server.ServerAutomaton; -import pp.mdga.server.ServerGameLogic; -import pp.mdga.server.ServerSender; -import pp.mdga.server.NoTurn; -import pp.mdga.server.StartPiece; -import pp.mdga.server.ThirdRoll; -import pp.mdga.server.Turn; -import pp.mdga.server.TurnStateMachine; -import pp.mdga.server.WaitingPiece; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import pp.mdga.message.server.WaitPiece; +import pp.mdga.server.*; +import static org.junit.Assert.*; +/** + * TODO + */ public class ServerStateTest { + //Todo private ServerGameLogic logic; private AnimationEnd animationEnd; private ClientStartGame clientStartGame; @@ -78,9 +35,11 @@ public class ServerStateTest { private SelectTSK selectTSK; private ClientMessage[] clientMessages; + //Todo private int from; private int fromHost; + //Todo private GameStateMachine gameStateMachine; private TurnStateMachine turnStateMachine; private RollDiceMachine rollDiceMachine; @@ -109,6 +68,9 @@ public class ServerStateTest { private Turn turn; private WaitingPiece waitingPiece; + /** + * TODO + */ @Before public void setUp() { @@ -599,6 +561,14 @@ public void testFirstRollToRollDiceEndState() { 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); } /** @@ -638,7 +608,31 @@ public void testFirstRollToSecondRoll() { */ @Test public void testSecondRollToRollDiceEndState() { - // UC-ServerState-24 + //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); } /** @@ -659,9 +653,9 @@ public void testSecondRollToThirdRoll() { turnStateMachine.gotoState(rollDice); assertTrue(turnStateMachine.getState() instanceof RollDice); - //sends the RollDiceMachine in FirstRoll - rollDiceMachine.gotoState(firstRoll); - assertTrue(rollDiceMachine.getState() instanceof FirstRoll); + //sends the RollDiceMachine in SecondRoll + rollDiceMachine.gotoState(secondRoll); + assertTrue(rollDiceMachine.getState() instanceof SecondRoll); //Todo player has no figures to move and had no 6 @@ -678,7 +672,31 @@ public void testSecondRollToThirdRoll() { */ @Test public void testThirdRollToRollDiceEndState() { - // UC-ServerState-26 + //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); } /** @@ -687,7 +705,23 @@ public void testThirdRollToRollDiceEndState() { */ @Test public void testThirdRollToTurnEndState() { - // UC-ServerState-27 + //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 } /** @@ -696,7 +730,30 @@ public void testThirdRollToTurnEndState() { */ @Test public void testNoPieceToWaitingPiece() { - // UC-ServerState-28 + //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); + } /** @@ -705,7 +762,29 @@ public void testNoPieceToWaitingPiece() { */ @Test public void testNoPieceToNoTurn() { - // UC-ServerState-29 + //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); } /** @@ -714,7 +793,23 @@ public void testNoPieceToNoTurn() { */ @Test public void testNoTurnToTurnEndState() { - // UC-ServerState-30 + //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 } /** @@ -723,7 +818,29 @@ public void testNoTurnToTurnEndState() { */ @Test public void testStayInWaitingPiece() { - // UC-ServerState-31 + //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); } /** @@ -732,7 +849,23 @@ public void testStayInWaitingPiece() { */ @Test public void testWaitingPieceToMovePiece() { - // UC-ServerState-32 + //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 } /** @@ -741,7 +874,29 @@ public void testWaitingPieceToMovePiece() { */ @Test public void testNoPieceToSelectPiece() { - // UC-ServerState-33 + //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); } /** @@ -750,7 +905,29 @@ public void testNoPieceToSelectPiece() { */ @Test public void testNoPieceToStartPiece() { - // UC-ServerState-34 + //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); } /** @@ -759,7 +936,29 @@ public void testNoPieceToStartPiece() { */ @Test public void testStayInSelectPiece() { - // UC-ServerState-35 + //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); } /** @@ -768,7 +967,23 @@ public void testStayInSelectPiece() { */ @Test public void testSelectPieceToMovePiece() { - // UC-ServerState-36 + //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 } /** @@ -777,7 +992,29 @@ public void testSelectPieceToMovePiece() { */ @Test public void testStayInStartPiece() { - // UC-ServerState-37 + //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); } /** @@ -786,6 +1023,22 @@ public void testStayInStartPiece() { */ @Test public void testStartPieceToMovePiece() { - // UC-ServerState-38 + //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 } } -- 2.43.0 From ce528457a5b9e8feb4f401771b1e1a6a303c3a50 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 02:30:43 +0100 Subject: [PATCH 14/15] added javadocs --- .../client/clientState/ClientStateTest.java | 2 +- .../server/serverState/ServerStateTest.java | 52 ++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 13833527..7d45305e 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -16,7 +16,7 @@ import static org.junit.Assert.assertTrue; /** - * this test-class tests the testcases T232-T239 TODO + * this test-class tests the testcases T170-T239 */ public class ClientStateTest { diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java index 15b1c7b1..5d11bbce 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/server/serverState/ServerStateTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.*; /** - * TODO + * this test-class tests the Testcases T132-T169 */ public class ServerStateTest { @@ -149,11 +149,18 @@ public void send(int id, ServerMessage msg) { 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 @@ -170,6 +177,9 @@ public void testLobbyToDetermineStartPlayer() { 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 @@ -198,6 +208,9 @@ public void testStayInLobby() { 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 @@ -225,6 +238,9 @@ public void testServerGameToCeremony() { 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 @@ -238,6 +254,9 @@ public void testInterruptToGameContinue() { 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 @@ -250,6 +269,9 @@ public void testInterruptToGameReconnect() { 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 @@ -262,12 +284,18 @@ public void testInterruptToGameTimer() { 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 @@ -285,6 +313,9 @@ public void testDetermineStartPlayerToDetermineStartPlayer1() { 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 @@ -302,6 +333,9 @@ public void testDetermineStartPlayerToDetermineStartPlayer2() { 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 @@ -319,6 +353,10 @@ public void testDetermineStartPlayerToAnimation() { 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 @@ -345,6 +383,10 @@ public void testAnimationToPowerCard() { 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 @@ -362,6 +404,10 @@ public void testTurnToAnimation() { 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 @@ -378,6 +424,10 @@ public void testTurnToGameEndState() { 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 -- 2.43.0 From 1803fb55496f0594bfa071875900993acf362094 Mon Sep 17 00:00:00 2001 From: Benjamin Feyer Date: Mon, 25 Nov 2024 16:32:51 +0100 Subject: [PATCH 15/15] edted some tests with null tests --- .../client/clientState/ClientStateTest.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java index 7d45305e..468f87b7 100644 --- a/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java +++ b/Projekte/mdga/model/src/test/java/pp/mdga/client/clientState/ClientStateTest.java @@ -13,6 +13,8 @@ import java.util.ArrayList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertTrue; /** @@ -131,12 +133,12 @@ public void setUp() { lobbyDeny = new LobbyDeny(); lobbyPlayerJoin = new LobbyPlayerJoin(name); lobbyPlayerLeave = new LobbyPlayerLeave(name,color); - moveMessage = new MoveMessage(); + moveMessage = new MoveMessage("www");//Todo noTurn = new NoTurn(); pauseGame = new PauseGame(); - playCardSwap = new PlayCard(swapCard); - playCardShield = new PlayCard(shieldCard); - playCardTurbo = new PlayCard(turboCard); + 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(); @@ -144,9 +146,9 @@ public void setUp() { reconnectBriefing = new ReconnectBriefing(game); resumeGame = new ResumeGame(); startGame = new ServerStartGame(); - startPieceMessage = new StartPiece(); - updateReady = new UpdateReady(); - updateTSK = new UpdateTSK(); + startPieceMessage = new StartPiece(); //Todo wrong class + updateReady = new UpdateReady(color,true); + updateTSK = new UpdateTSK(name,color); waitPiece = new WaitPiece(); //initialize the clientGameLogic @@ -162,7 +164,7 @@ public void send(ClientMessage msg) { mainSettings = new MainSettings(settingsStateMachine,clientGameLogic); videoSettings = new VideoSettings(settingsStateMachine,clientGameLogic); audioSettings = new AudioSettings(settingsStateMachine,clientGameLogic); - settings = new Settings(); + settings = new Settings(clientAutomaton,clientGameLogic); //initialize the stateMachines @@ -220,10 +222,12 @@ public void send(ClientMessage msg) { @Test public void testInitialStateClientState() { //tests if the clientAutomaton is in Dialogs + assertNotEquals(clientAutomaton.getState() , null); assertTrue(clientAutomaton.getState() instanceof Dialogs); Dialogs dialogs = (Dialogs) clientAutomaton.getState(); DialogsStateMachine dialogsStateMachine1 = dialogs.getDialogsStateMachine(); //tests if the statemachine is in StartDialog + assertNotEquals(dialogsStateMachine1.getState(), null); assertTrue(dialogsStateMachine1.getState() instanceof StartDialog); } @@ -603,7 +607,7 @@ public void testWaitToAnimation() { assertTrue(gameStateMachine.getState() instanceof Waiting); //tests if a powerCard is played,that the client goes into Animation - clientGameLogic.receive(playCard); //Todo ??? richtige message + clientGameLogic.receive(playCardTurbo); //Todo ??? richtige message assertTrue(clientAutomaton.getState() instanceof GameState); assertTrue(gameStateMachine.getState() instanceof Animation); -- 2.43.0