added some more tests andd edited some mor

This commit is contained in:
Benjamin Feyer
2024-11-29 16:49:11 +01:00
parent c6462a50ca
commit 838beee345

View File

@@ -93,6 +93,7 @@ public class ClientStateTest {
private UpdateTSKMessage updateTSK; private UpdateTSKMessage updateTSK;
private WaitPieceMessage waitPiece; private WaitPieceMessage waitPiece;
private SpectatorMessage spectatorMessage; private SpectatorMessage spectatorMessage;
private SelectPieceMessage selectPieceMessage;
private int from; private int from;
private String name; private String name;
@@ -154,6 +155,7 @@ public void send(ClientMessage msg) {
waitPiece = new WaitPieceMessage(); waitPiece = new WaitPieceMessage();
interruptMessage = new PauseGameMessage(); interruptMessage = new PauseGameMessage();
spectatorMessage = new SpectatorMessage(); spectatorMessage = new SpectatorMessage();
selectPieceMessage = new SelectPieceMessage();
//initialize the settings //initialize the settings
mainSettings = settings.getMainSettings(); mainSettings = settings.getMainSettings();
@@ -244,12 +246,13 @@ public void testDialogsToGame() {
clientGameLogic.received(rankingRollAgain); clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing); clientGameLogic.received(reconnectBriefing);
clientGameLogic.received(resumeGame); clientGameLogic.received(resumeGame);
//clientGameLogic.received(startGame); Todo rightful message //clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage); clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady); clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in lobby //tests if the client is still in lobby
assertEquals(clientGameLogic.getState(), dialogs); assertEquals(clientGameLogic.getState(), dialogs);
@@ -273,7 +276,14 @@ public void testDialogsToGame() {
*/ */
@Test @Test
public void testDialogsToClientStateEndState() { public void testDialogsToClientStateEndState() {
//Todo Implementation goes here //sends the client in dialogs
clientGameLogic.setState(dialogs);
assertEquals(clientGameLogic.getState(), dialogs);
//sends dialogs in startDialog-state
dialogs.setState(startDialog);
assertEquals(dialogs.getState(),startDialog);
//TODO how????????? //TODO how?????????
} }
@@ -289,7 +299,7 @@ public void testClientGameToCeremony() {
clientGameLogic.received(activePlayer); clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece); clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing); clientGameLogic.received(briefing);
//clientGameLogic.received(ceremonyMessage); todo rightful message //clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die); clientGameLogic.received(die);
clientGameLogic.received(diceAgain); clientGameLogic.received(diceAgain);
clientGameLogic.received(diceNow); clientGameLogic.received(diceNow);
@@ -316,6 +326,7 @@ public void testClientGameToCeremony() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in game-state //tests if the client is still in game-state
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -395,13 +406,14 @@ public void testStayInInterrupt() {
clientGameLogic.received(rankingResponce); clientGameLogic.received(rankingResponce);
clientGameLogic.received(rankingRollAgain); clientGameLogic.received(rankingRollAgain);
clientGameLogic.received(reconnectBriefing); clientGameLogic.received(reconnectBriefing);
//clientGameLogic.received(resumeGame); Todo rightful message //clientGameLogic.received(resumeGame); commented out, because it indicates a state-change to gameState
clientGameLogic.received(startGame); clientGameLogic.received(startGame);
clientGameLogic.received(startPieceMessage); clientGameLogic.received(startPieceMessage);
clientGameLogic.received(updateReady); clientGameLogic.received(updateReady);
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is in the interrupt //tests if the client is in the interrupt
assertEquals(clientGameLogic.getState(), interrupt); assertEquals(clientGameLogic.getState(), interrupt);
@@ -433,7 +445,9 @@ public void testInterruptToDialogs() {
assertEquals(clientGameLogic.getState(), interrupt); assertEquals(clientGameLogic.getState(), interrupt);
//Todo send the server-closed //Todo send the server-closed
clientGameLogic.received();
//tests if the client is in the startDialog
assertEquals(clientGameLogic.getState(), dialogs); assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), startDialog); assertEquals(dialogs.getState(), startDialog);
} }
@@ -573,7 +587,7 @@ public void testNetworkDialogToNetworkDialog1() {
clientGameLogic.selectReady(true); clientGameLogic.selectReady(true);
clientGameLogic.selectHost(name); clientGameLogic.selectHost(name);
//clientGameLogic.selectLeave(); commented because it indicate a state-change to start-dialog //clientGameLogic.selectLeave(); commented because it indicate a state-change to start-dialog
//clientGameLogic.selectJoin(name); commented because it indicate a state-change to lobby TODO //clientGameLogic.selectJoin(name); commented because it indicate a state-change to lobby
clientGameLogic.selectAnimationEnd(); clientGameLogic.selectAnimationEnd();
clientGameLogic.selectStart(); clientGameLogic.selectStart();
@@ -703,6 +717,7 @@ public void testStayInLobby() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
assertEquals(clientGameLogic.getState(), dialogs); assertEquals(clientGameLogic.getState(), dialogs);
assertEquals(dialogs.getState(), lobby); assertEquals(dialogs.getState(), lobby);
@@ -907,6 +922,7 @@ public void testTurnSubStatesToGameEndState() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state //clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in MovePiece //tests if the client is still in MovePiece
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -926,7 +942,192 @@ public void testTurnSubStatesToGameEndState() {
*/ */
@Test @Test
public void testTurnSubStatesToWait() { public void testTurnSubStatesToWait() {
// todo Implementation goes here /**
* tests the transition from MovePiece to Wait
*/
//sends the clientGameLogic in gameState
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//sends the gameState in turnState
gameState.setState(turnState);
assertEquals(gameState.getState(),turnState);
//sends the turnState in movePiece
turnState.setState(movePiece);
assertEquals(turnState.getState(),movePiece);
//tests all messages, that don't indicate a state-change
clientGameLogic.received(activePlayer);
clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing);
//clientGameLogic.received(ceremonyMessage); commented because it indicate a state-change to ceremony-state
clientGameLogic.received(die);
clientGameLogic.received(diceAgain);
//clientGameLogic.received(diceNow); commented because it indicate a state-change to rollDice-state
//clientGameLogic.received(endOfTurn); commented because it indicate a state-change to wait-state
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
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);
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in MovePiece
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),turnState);
assertEquals(turnState.getState(),movePiece);
//sends the endOfTurn message
clientGameLogic.received(endOfTurn);
//tests if the client is in waiting-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),waiting);
/**
* tests thr transition from choosePiece to Wait
*/
//sends the clientGameLogic in gameState
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//sends the gameState in turnState
gameState.setState(turnState);
assertEquals(gameState.getState(),turnState);
//sends the turnState in choosePiece
turnState.setState(movePiece);
assertEquals(turnState.getState(),choosePiece);
//sends the choosePiece in NoPiece
choosePiece.setState(noPiece);
assertEquals(choosePiece.getState(),noPiece);
//tests 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); commented because it indicate a state-change to wait-state
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
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);
clientGameLogic.received(spectatorMessage);
//clientGameLogic.received(selectPieceMessage);
//tests if the client is still in MovePiece
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),turnState);
assertEquals(turnState.getState(),choosePiece);
assertEquals(choosePiece.getState(),noPiece);
//sends the endOfTurn message
clientGameLogic.received(endOfTurn);
//tests if the client is in waiting-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),waiting);
/**
* tests the transition from RollDice to Wait
*/
//sends the clientGameLogic in gameState
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//sends the gameState in turnState
gameState.setState(turnState);
assertEquals(gameState.getState(),turnState);
//sends the turnState in movePiece
turnState.setState(movePiece);
assertEquals(turnState.getState(),rollDice);
//tests 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); commented because it indicate a state-change to wait-state
clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny);
clientGameLogic.received(lobbyPlayerJoin);
clientGameLogic.received(lobbyPlayerLeave);
clientGameLogic.received(moveMessage);
clientGameLogic.received(noTurn);
//clientGameLogic.received(interruptMessage); commented because it indicate a state-change to interrupt-state
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);
clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in MovePiece
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),turnState);
assertEquals(turnState.getState(),rollDice);
//sends the endOfTurn message
clientGameLogic.received(endOfTurn);
//tests if the client is in waiting-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),waiting);
} }
/** /**
@@ -977,6 +1178,7 @@ public void testTurnSubStatesToSpectator() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
//clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state //clientGameLogic.received(spectatorMessage); commented because it indicate a state-change to spectator-state
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in MovePiece //tests if the client is still in MovePiece
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1035,6 +1237,7 @@ public void testSpectatorToGameEndState() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in spectator //tests if the client is still in spectator
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1162,7 +1365,7 @@ public void testStayInPlayPowerCard() {
clientGameLogic.received(anyPiece); clientGameLogic.received(anyPiece);
clientGameLogic.received(briefing); clientGameLogic.received(briefing);
clientGameLogic.received(ceremonyMessage); clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die); todo rightful message clientGameLogic.received(die);
clientGameLogic.received(diceAgain); clientGameLogic.received(diceAgain);
//clientGameLogic.received(diceNow); //clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn); clientGameLogic.received(endOfTurn);
@@ -1188,6 +1391,7 @@ public void testStayInPlayPowerCard() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1219,7 +1423,7 @@ public void testPlayPowerCardToRollDice() {
clientGameLogic.received(ceremonyMessage); clientGameLogic.received(ceremonyMessage);
clientGameLogic.received(die); clientGameLogic.received(die);
clientGameLogic.received(diceAgain); clientGameLogic.received(diceAgain);
//clientGameLogic.received(diceNow); todo rightful message //clientGameLogic.received(diceNow);
clientGameLogic.received(endOfTurn); clientGameLogic.received(endOfTurn);
clientGameLogic.received(lobbyAccept); clientGameLogic.received(lobbyAccept);
clientGameLogic.received(lobbyDeny); clientGameLogic.received(lobbyDeny);
@@ -1243,6 +1447,7 @@ public void testPlayPowerCardToRollDice() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is in RollDice //tests if the client is in RollDice
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1306,6 +1511,7 @@ public void testStayInRollDice() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is in RollDice //tests if the client is in RollDice
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1383,7 +1589,12 @@ public void testChoosePieceToWait() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece); assertEquals(turnState.getState(), choosePiece);
//TODO //sends the choosePiece into noTurn
choosePiece.setState(noPiece);
assertEquals(choosePiece.getState(),noPiece);
//send the noTurnMessage
clientGameLogic.received(noTurn);
//tests if the client is in the wait-state //tests if the client is in the wait-state
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1397,6 +1608,9 @@ public void testChoosePieceToWait() {
*/ */
@Test @Test
public void testChoosePieceToMovePiece() { public void testChoosePieceToMovePiece() {
/**
* tests the transition from waitingPiece to MovePiece
*/
//sends the client into noPiece //sends the client into noPiece
clientGameLogic.setState(gameState); clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1409,7 +1623,9 @@ public void testChoosePieceToMovePiece() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece); assertEquals(turnState.getState(), choosePiece);
//Todo //sends the choosePiece into waitingPiece
choosePiece.setState(waitingPiece);
assertEquals(choosePiece.getState(),waitingPiece);
//sends the movePieceMessage //sends the movePieceMessage
clientGameLogic.received(moveMessage); clientGameLogic.received(moveMessage);
@@ -1418,6 +1634,60 @@ public void testChoosePieceToMovePiece() {
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), movePiece); assertEquals(turnState.getState(), movePiece);
/**
* tests the transition from startPiece to MovePiece
*/
//sends the client into noPiece
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//sends the gameState into Turn
gameState.setState(turnState);
assertEquals(gameState.getState(), turnState);
//sends the turnState into choosePiece
turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece);
//sends the choosePiece into startPiece
choosePiece.setState(startPiece);
assertEquals(choosePiece.getState(),startPiece);
//sends the movePieceMessage
clientGameLogic.received(moveMessage);
//tests if the client is in the movePiece-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), movePiece);
/**
* tests the transition from selectPiece to MovePiece
*/
//sends the client into noPiece
clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState);
//sends the gameState into Turn
gameState.setState(turnState);
assertEquals(gameState.getState(), turnState);
//sends the turnState into choosePiece
turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece);
//sends the choosePiece into selectPiece
choosePiece.setState(selectPiece);
assertEquals(choosePiece.getState(),selectPiece);
//sends the movePieceMessage
clientGameLogic.received(moveMessage);
//tests if the client is in the movePiece-state
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), sele);
} }
/** /**
@@ -1437,10 +1707,8 @@ public void testMovePieceToWait() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), movePiece); assertEquals(turnState.getState(), movePiece);
// Todo Implementation goes here //sends the endOfTurnMessage
clientGameLogic.received(endOfTurn);
//sends the noTurnMessage
clientGameLogic.received(noTurn);
//tests if the client is in the movePiece-state //tests if the client is in the movePiece-state
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1465,8 +1733,6 @@ public void testMovePieceToSpectator() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), movePiece); assertEquals(turnState.getState(), movePiece);
// Todo Implementation goes here
//sends the spectator-message //sends the spectator-message
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
@@ -1492,8 +1758,6 @@ public void testMovePieceToCeremony() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), movePiece); assertEquals(turnState.getState(), movePiece);
// Todo Implementation goes here
//sends the spectator-message //sends the spectator-message
clientGameLogic.received(ceremonyMessage); clientGameLogic.received(ceremonyMessage);
@@ -1515,12 +1779,45 @@ public void testStayInChoosePowerCard() {
gameState.setState(turnState); gameState.setState(turnState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
//sends the turnState into movePiece //sends the turnState into choosePowerCardPiece
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePowerCard); assertEquals(turnState.getState(), choosePowerCard);
// Todo Implementation goes here
//tests if the client is still in the choosePowercard-State //send 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);
clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//TODO selectable pieces
//tests if the client is still in the choosePowerCard-State
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(),turnState); assertEquals(gameState.getState(),turnState);
assertEquals(turnState.getState(),choosePowerCard); assertEquals(turnState.getState(),choosePowerCard);
@@ -1547,7 +1844,8 @@ public void testChoosePowerCardToRollDice() {
powerCard.setState(choosePowerCard); powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard);
//todo send the messages, to force a state change to rollDice //sends the rollDice-Message
clientGameLogic.received(diceNow);
//tests if the turnState is in RollDice //tests if the turnState is in RollDice
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1576,7 +1874,8 @@ public void testChoosePowerCardToSwap() {
powerCard.setState(choosePowerCard); powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard);
//todo send the messages, to force a state change to swap //sends the TODO selectable Pieces
clientGameLogic.received();
//tests if the client is in Swap //tests if the client is in Swap
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1606,7 +1905,8 @@ public void testChoosePowerCardToShield() {
powerCard.setState(choosePowerCard); powerCard.setState(choosePowerCard);
assertEquals(powerCard.getState(), choosePowerCard); assertEquals(powerCard.getState(), choosePowerCard);
//todo send the messages, to force a state change to shield //sends the TODO
clientGameLogic.received();
//tests if the client is in Shield //tests if the client is in Shield
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1636,7 +1936,38 @@ public void testStayInShield() {
powerCard.setState(shield); powerCard.setState(shield);
assertEquals(powerCard.getState(), shield); assertEquals(powerCard.getState(), shield);
//todo send the messages, which dont force a statechange //send the messages, which don't force 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); commented out, because it indicate a state-change to interrupt
//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);
clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1650,7 +1981,7 @@ public void testStayInShield() {
*/ */
@Test @Test
public void testShieldToPowerCardEndState() { public void testShieldToPowerCardEndState() {
//sends the ClientAutomaton in GameState //sends the ClientGameLogic in GameState
clientGameLogic.setState(gameState); clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1658,15 +1989,55 @@ public void testShieldToPowerCardEndState() {
gameState.setState(turnState); gameState.setState(turnState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
//sends the turnStatemachine in PowerCard //sends the turnState in PowerCard
turnState.setState(powerCard); turnState.setState(powerCard);
assertEquals(turnState.getState(), powerCard); assertEquals(turnState.getState(), powerCard);
//sends the turnStatemachine in Shield //sends the turnState in Shield
powerCard.setState(shield); powerCard.setState(shield);
assertEquals(powerCard.getState(), shield); assertEquals(powerCard.getState(), shield);
//todo send the message to force the statechange //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);
clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client is still in shield
assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState);
assertEquals(turnState.getState(), powerCard);
assertEquals(powerCard.getState(), shield);
//sends the playPowerCardMessage
clientGameLogic.received(playCardShield);
//tests if the client is in PlayPowerCard //tests if the client is in PlayPowerCard
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1687,11 +2058,11 @@ public void testSwapToPowerCardEndState() {
gameState.setState(turnState); gameState.setState(turnState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
//sends the turnStatemachine in PowerCard //sends the turnState in PowerCard
turnState.setState(powerCard); turnState.setState(powerCard);
assertEquals(turnState.getState(), powerCard); assertEquals(turnState.getState(), powerCard);
//sends the turnStatemachine in Swap //sends the turnState in Swap
powerCard.setState(swap); powerCard.setState(swap);
assertEquals(powerCard.getState(), swap); assertEquals(powerCard.getState(), swap);
@@ -1720,11 +2091,42 @@ public void testNoPieceInWaitingPiece() {
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece); assertEquals(turnState.getState(), choosePiece);
//sends the choosePiecemachine in NoPiece //sends the choosePiece in NoPiece
turnState.setState(noPiece); turnState.setState(noPiece);
assertEquals(choosePiece.getState(), noPiece); assertEquals(choosePiece.getState(), noPiece);
//Todo test other messages, that there is no state change //send other messages, that there is no 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); commented out, because it indicate a statechange to interrupt
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);
clientGameLogic.received(spectatorMessage);
//clientGameLogic.received(selectPieceMessage);
//sends to the clientGameLogic the message WaitPiece //sends to the clientGameLogic the message WaitPiece
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
@@ -1748,18 +2150,49 @@ public void testNoPieceInSelectedPiece() {
gameState.setState(turnState); gameState.setState(turnState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
//sends the turnStatemachine in ChoosePiece //sends the turnState in ChoosePiece
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece); assertEquals(turnState.getState(), choosePiece);
//sends the choosePiecemachine in NoPiece //sends the choosePiece in NoPiece
choosePiece.setState(noPiece); choosePiece.setState(noPiece);
assertEquals(choosePiece.getState(), noPiece); assertEquals(choosePiece.getState(), noPiece);
//Todo test other messages, that there is no state change //send other messages, to test that there is no 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);
clientGameLogic.received(spectatorMessage);
//clientGameLogic.received(selectPieceMessage);
//sends to the clientGameLogic the message SelectPiece //sends to the clientGameLogic the message SelectPiece
clientGameLogic.received(selectPiece); clientGameLogic.received(selectPieceMessage);
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
@@ -1772,7 +2205,7 @@ public void testNoPieceInSelectedPiece() {
*/ */
@Test @Test
public void testNoPieceInStartPiece() { public void testNoPieceInStartPiece() {
//sends the ClientAutomaton in GameState //sends the ClientGameLogic in GameState
clientGameLogic.setState(gameState); clientGameLogic.setState(gameState);
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -1780,15 +2213,46 @@ public void testNoPieceInStartPiece() {
gameState.setState(turnState); gameState.setState(turnState);
assertEquals(gameState.getState(), turnState); assertEquals(gameState.getState(), turnState);
//sends the turnStatemachine in ChoosePiece //sends the turnState in ChoosePiece
turnState.setState(choosePiece); turnState.setState(choosePiece);
assertEquals(turnState.getState(), choosePiece); assertEquals(turnState.getState(), choosePiece);
//sends the choosePiecemachine in NoPiece //sends the choosePiece in NoPiece
choosePiece.setState(noPiece); choosePiece.setState(noPiece);
assertEquals(choosePiece.getState(), noPiece); assertEquals(choosePiece.getState(), noPiece);
//Todo test other messages, that there is no state change //sends other messages, that there is no 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);
clientGameLogic.received(spectatorMessage);
//clientGameLogic.received(selectPieceMessage);
//sends to the clientGameLogic the message StartPiece //sends to the clientGameLogic the message StartPiece
clientGameLogic.received(startPieceMessage); clientGameLogic.received(startPieceMessage);
@@ -2025,6 +2489,7 @@ public void testStartPieceToChoosePieceEndState() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//tests if the client ist still in StartPiece //tests if the client ist still in StartPiece
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -2089,6 +2554,7 @@ public void testRollRankingDiceToWaitRanking() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//test if the client is still in rollRankingDice //test if the client is still in rollRankingDice
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -2152,6 +2618,7 @@ public void testWaitRankingToRollRankingDice() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//test if the client is still in waitRanking //test if the client is still in waitRanking
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);
@@ -2215,6 +2682,7 @@ public void testWaitRankingToEndStateDetermineStartingPlayer() {
clientGameLogic.received(updateTSK); clientGameLogic.received(updateTSK);
clientGameLogic.received(waitPiece); clientGameLogic.received(waitPiece);
clientGameLogic.received(spectatorMessage); clientGameLogic.received(spectatorMessage);
clientGameLogic.received(selectPieceMessage);
//test if the client is still in waitRanking //test if the client is still in waitRanking
assertEquals(clientGameLogic.getState(), gameState); assertEquals(clientGameLogic.getState(), gameState);