test: refactored tests
This commit is contained in:
parent
7653f5217c
commit
c4badaf4ef
@ -9,7 +9,6 @@ import uulm.teamname.marvelous.gamelibrary.config.CharacterConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.FieldType;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig;
|
||||
import uulm.teamname.marvelous.gamelibrary.entities.EntityType;
|
||||
import uulm.teamname.marvelous.gamelibrary.events.EventBuilder;
|
||||
import uulm.teamname.marvelous.gamelibrary.events.EventType;
|
||||
import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
|
||||
@ -22,9 +21,7 @@ import uulm.teamname.marvelous.server.netconnector.Client;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
class LobbyTest {
|
||||
|
||||
@ -64,7 +61,7 @@ class LobbyTest {
|
||||
new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
|
||||
};
|
||||
var playerConnection = mock(WebSocket.class);
|
||||
doNothing().when(lobby).updateTimer();
|
||||
doNothing().when(lobby).updateTurnTimer();
|
||||
|
||||
Participant playerOne = new Participant(
|
||||
new Client(playerConnection), "LobbyOne", ParticipantType.PlayerOne);
|
||||
@ -75,7 +72,7 @@ class LobbyTest {
|
||||
@Disabled
|
||||
void soonTimeoutTest(){
|
||||
var participant = mock(Participant.class);
|
||||
lobby.soonTimeout(participant);
|
||||
lobby.soonTimeout(participant, 15);
|
||||
verify(connection).sendEvents(participant, new EventBuilder(EventType.TimeoutWarningEvent).buildGameStateEvent());
|
||||
}
|
||||
|
||||
@ -84,7 +81,7 @@ class LobbyTest {
|
||||
void generateWinPlayer1Test(){
|
||||
var webSoc = mock(WebSocket.class);
|
||||
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
||||
lobby.generateWin(winner);
|
||||
lobby.triggerWin(winner);
|
||||
verify(connection).broadcastEvents(
|
||||
new EventBuilder(EventType.WinEvent)
|
||||
.withPlayerWon(1)
|
||||
@ -99,7 +96,7 @@ class LobbyTest {
|
||||
void generateWinPlayer2Test(){
|
||||
var webSoc = mock(WebSocket.class);
|
||||
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
||||
lobby.generateWin(winner);
|
||||
lobby.triggerWin(winner);
|
||||
verify(connection).broadcastEvents(
|
||||
new EventBuilder(EventType.WinEvent)
|
||||
.withPlayerWon(2)
|
||||
|
@ -12,20 +12,20 @@ import java.util.function.Consumer;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class TimeoutTimerTest {
|
||||
TimeoutTimer timeoutTimer;
|
||||
class TurnTimeoutTimerTest {
|
||||
TurnTimeoutTimer turnTimeoutTimer;
|
||||
|
||||
@BeforeEach
|
||||
void beforeEach(){
|
||||
var callback = mock(Consumer.class);
|
||||
timeoutTimer = new TimeoutTimer(20, callback);
|
||||
turnTimeoutTimer = new TurnTimeoutTimer(20, callback);
|
||||
}
|
||||
|
||||
@Test
|
||||
void startTurnTimerTest(){
|
||||
var connection = mock(WebSocket.class);
|
||||
var participant = new Participant(new Client(connection), "lobby", ParticipantType.Spectator);
|
||||
assertThatIllegalStateException().describedAs("Spectators don't have TurnTime").isThrownBy(() -> timeoutTimer.startTurnTimer(participant));
|
||||
assertThatIllegalStateException().describedAs("Spectators don't have TurnTime").isThrownBy(() -> turnTimeoutTimer.startTurnTimer(participant));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
class RequestGameStateSegmentTest {
|
||||
class RequestGameLogicSegmentTest {
|
||||
|
||||
@Test
|
||||
void requestGamestateTest(){
|
||||
@ -42,4 +42,4 @@ class RequestGameStateSegmentTest {
|
||||
verify(game).getGameStateEvent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user