processed some Todo in the Client State, to test unwanted statechanged

This commit is contained in:
Benjamin Feyer
2024-11-28 22:46:50 +01:00
parent 6d58ceee3d
commit 4a89c4fa65

View File

@@ -87,11 +87,9 @@ public class ClientStateTest {
private MoveMessage moveMessage;
private NoTurnMessage noTurn;
private PauseGameMessage interruptMessage;
private PlayCardMessage playCardSwap;
private PlayCardMessage playCardShield;
private PlayCardMessage playCardTurbo;
private PossibleCardMessage possibleCard;
private PossiblePieceMessage possiblePiece;
private RankingResponseMessage rankingResponce;
@@ -104,7 +102,6 @@ public class ClientStateTest {
private UpdateTSKMessage updateTSK;
private WaitPieceMessage waitPiece;
private int from;
private String name;
private Color color;
@@ -112,7 +109,6 @@ public class ClientStateTest {
private BonusCard shieldCard;
private BonusCard turboCard;
@Before
public void setUp() {
//initialize the game
@@ -166,15 +162,11 @@ public void send(ClientMessage msg) {
waitPiece = new WaitPieceMessage();
interruptMessage = new PauseGameMessage();
//initialize the settings
mainSettings = settings.getMainSettings();
videoSettings = settings.getVideoSettings();
audioSettings = settings.getAudioSettings();
settings = new SettingsState(clientGameLogic);
settings = new SettingsState();
//initialize the states
dialogs = clientGameLogic.getDialogs();
@@ -234,7 +226,40 @@ public void testDialogsToGame() {
clientGameLogic.setState(dialogs);
assertEquals(clientGameLogic.getState(), dialogs);
//TODO
//sends all messages, which don't indicate a statechange
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
//clientGameLogic.received(startGame); Todo rightful message
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is still in lobby
assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), lobby);
//sends the startGame-Message to the client
clientGameLogic.received(startGame);
@@ -267,7 +292,38 @@ public void testClientGameToCeremony() {
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//TODO
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
//clientGameLogic.received(ceremonyMessage); todo rightful message
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is still in game-state
assertEquals(clientGameLogic.getState(), gameState);
//sends the Ceremony-Message to the client
clientGameLogic.received(ceremonyMessage);
@@ -288,8 +344,6 @@ public void testClientGameSubStatesToInterrupt() {
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//TODO
//sends the Ceremony-Message to the client
clientGameLogic.received(interruptMessage);
@@ -321,8 +375,38 @@ public void testStayInInterrupt() {
clientGameLogic.setState(interrupt);
assertEquals(clientGameLogic.getState(), interrupt);
//Todo send all messages except the continue-message
//sends all messages, which don't indicate a statechange
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
//clientGameLogic.received(resumeGame); Todo rightful message
clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is in the interrupt
assertEquals(clientGameLogic.getState(), interrupt);
}
@@ -335,7 +419,8 @@ public void testClientInterruptToGame() {
clientGameLogic.setState(interrupt);
assertEquals(clientGameLogic.getState(), interrupt);
//Todo sends the continue-message
//sends the continue message
clientGameLogic.received(resumeGame);
//tests if the client is in the game
assertEquals(clientGameLogic.getState(), gameState);
@@ -454,7 +539,7 @@ public void testNetworkDialogToNetworkDialog1() {
dialogs.setState(networkDialog);
assertEquals(dialogs.getState(), networkDialog);
//todo test receiving all messages and making input
//todo test input
assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), networkDialog);
@@ -535,7 +620,37 @@ public void testStayInLobby() {
dialogs.setState(lobby);
assertEquals(dialogs.getState(), lobby);
//todo send all messages that dont indicate a change-state
//sends all messages, which don't indicate a statechange
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);//Todo rightful message
clientGameLogic.received(lobbyDeny);//Todo rightful message
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
//clientGameLogic.received(startGame); Todo rightful message
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), lobby);
@@ -555,7 +670,7 @@ public void testLobbyToRollRankingDice() {
assertEquals(dialogs.getState(), lobby);
//sends the message to start the game
clientGameLogic.received();//TODO message
clientGameLogic.received(startGame);
//tests if the clientStateMachine is in the GameState
assertEquals(clientGameLogic.getState(), gameState);
@@ -580,7 +695,8 @@ public void testDetermineStartPlayerToWait() {
gameState.setState(determineStartPlayer);
assertEquals(gameState.getState(), determineStartPlayer);
//TODO
//sends the message, that indicate a statechange to wait
clientGameLogic.received(noTurn);
//tests if the client is in the Wait-State
assertEquals(clientGameLogic.getState(), gameState);
@@ -601,7 +717,7 @@ public void testWaitToAnimation() {
assertEquals(gameState.getState(), waiting);
//sends the moveMessage
clientGameLogic.received(moveMessage); //Todo ??? richtige message
clientGameLogic.received(moveMessage);
//tests if a piece is moved,that the client goes into Animation
assertEquals(clientGameLogic.getState(), gameState);
@@ -612,7 +728,7 @@ public void testWaitToAnimation() {
assertEquals(gameState.getState(), waiting);
//sends the playTurboCard-message
clientGameLogic.received(playCardTurbo); //Todo ??? richtige message
clientGameLogic.received(playCardTurbo);
//tests if a powerCard is played,that the client goes into Animation
assertEquals(clientGameLogic.getState(), gameState);
@@ -623,7 +739,18 @@ public void testWaitToAnimation() {
assertEquals(gameState.getState(), waiting);
//sends the playTurboCard-message
clientGameLogic.received(die); //Todo ??? richtige message
clientGameLogic.received(die);
//tests if a die is rolled,that the client goes into Animation
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), animation);
//sends the client in WaitState
gameState.setState(waiting);
assertEquals(gameState.getState(), waiting);
//sends the activePlayer-message
clientGameLogic.received(activePlayer);
//tests if a die is rolled,that the client goes into Animation
assertEquals(clientGameLogic.getState(), gameState);
@@ -672,7 +799,8 @@ public void testWaitToGameEndState() {
gameState.setState(waiting);
assertEquals(gameState.getState(), waiting);
//Todo
//send the ceremony-Message
clientGameLogic.received(ceremonyMessage);
//tests if the client is in the ceremony
assertEquals(clientGameLogic.getState(), ceremony);
@@ -716,8 +844,9 @@ public void testSpectatorToGameEndState() {
*/
@Test
public void testPowerCardSubStatesToPlayPowerCard() {
//sends the client in th e swap-state
/**
* sends the client in the swap-state
*/
//sends the ClientAutomaton in GameState
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
@@ -734,17 +863,17 @@ public void testPowerCardSubStatesToPlayPowerCard() {
powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), swap);
//TODO
//sends the playCardMessage
clientGameLogic.received(playCardShield);
//tests if the client is in rollDice
//tests if the client is in playPowerCard
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), playPowerCard);
//send the client in the shield-state
/**
* send the client in the shield-state
*/
//sends the ClientAutomaton in GameState
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
@@ -761,9 +890,10 @@ public void testPowerCardSubStatesToPlayPowerCard() {
powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), shield);
//TODO
//sends the playCardMessage
clientGameLogic.received(playCardShield);
//tests if the client is in rollDice
//tests if the client is in playPowerCard
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), playPowerCard);
@@ -792,7 +922,8 @@ public void testPowerCardSubStatesToRollDice() {
powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), choosePowerCard);
//TODO
//sends RollDiceMessage
clientGameLogic.received(diceNow);
//tests if the client is in rollDice
assertEquals(clientGameLogic.getState(), gameState);
@@ -817,7 +948,36 @@ public void testStayInPlayPowerCard() {
turnState.setState(playPowerCard);
assertEquals(turnState.getState(), playPowerCard);
//Todo send messages to test to stay in playPowerCard
//sends all messages that don't indicate a state-change
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die); todo rightful message
clientGameLogic.received(diceAgain);
//clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is in PlayPowerCard
assertEquals(clientGameLogic.getState(), gameState);
@@ -842,8 +1002,44 @@ public void testPlayPowerCardToRollDice() {
turnState.setState(playPowerCard);
assertEquals(turnState.getState(), playPowerCard);
//Todo send messages to test the transition in rollDice
//Todo test other messages, that there is no state change
//sends all messages that don't indicate a state-change
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
//clientGameLogic.received(diceNow); todo rightful message
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is in RollDice
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), playPowerCard);
//sends the die-message
clientGameLogic.received(diceNow);
//tests if the client is in RollDice
assertEquals(clientGameLogic.getState(), gameState);
@@ -868,7 +1064,36 @@ public void testStayInRollDice() {
turnState.setState(rollDice);
assertEquals(turnState.getState(), rollDice);
//TODO
//sends all messages, that don't indicate a state-change
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage);
//clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
//clientGameLogic.received(noTurn);
clientGameLogic.received(interruptMessage);
clientGameLogic.received(playCardSwap);
clientGameLogic.received(playCardShield);
clientGameLogic.received(playCardTurbo);
clientGameLogic.received(possibleCard);
clientGameLogic.received(possiblePiece);
clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame);
clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece);
//tests if the client is in RollDice
assertEquals(clientGameLogic.getState(), gameState);
@@ -899,7 +1124,6 @@ public void testRollDiceToChoosePiece() {
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), choosePiece);
assertEquals(choosePiece.getState(), noPiece);
}
/**
@@ -927,7 +1151,7 @@ public void testRollDiceToWait() {
/**
* UC-ClientState-36: Test the transition from ChoosePiece to Wait.
*
* <p>
* this method tests the transition from noPiece to Wait
*/
@Test
@@ -949,12 +1173,11 @@ public void testChoosePieceToWait() {
//tests if the client is in the wait-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), waiting);
}
/**
* UC-ClientState-37: Test the transition from ChoosePiece to MovePiece.
*
* <p>
* this method tests the transition from noPiece to Wait
*/
@Test
@@ -977,7 +1200,6 @@ public void testChoosePieceToMovePiece() {
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), movePiece);
}
/**
@@ -1645,5 +1867,4 @@ public void testAudioSettingsToMainSettings() {
public void testClientStateSubStatesToMainSettings() {
// todo Implementation goes here
}
}