editet tests for the server and client statemachines
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user