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.FieldType;
|
||||||
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
|
import uulm.teamname.marvelous.gamelibrary.config.PartyConfig;
|
||||||
import uulm.teamname.marvelous.gamelibrary.config.ScenarioConfig;
|
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.EventBuilder;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.EventType;
|
import uulm.teamname.marvelous.gamelibrary.events.EventType;
|
||||||
import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
|
import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
|
||||||
@ -22,9 +21,7 @@ import uulm.teamname.marvelous.server.netconnector.Client;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.assertj.core.api.Assertions.*;
|
|
||||||
|
|
||||||
class LobbyTest {
|
class LobbyTest {
|
||||||
|
|
||||||
@ -64,7 +61,7 @@ class LobbyTest {
|
|||||||
new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
|
new RequestBuilder(RequestType.MoveRequest).buildGameRequest()
|
||||||
};
|
};
|
||||||
var playerConnection = mock(WebSocket.class);
|
var playerConnection = mock(WebSocket.class);
|
||||||
doNothing().when(lobby).updateTimer();
|
doNothing().when(lobby).updateTurnTimer();
|
||||||
|
|
||||||
Participant playerOne = new Participant(
|
Participant playerOne = new Participant(
|
||||||
new Client(playerConnection), "LobbyOne", ParticipantType.PlayerOne);
|
new Client(playerConnection), "LobbyOne", ParticipantType.PlayerOne);
|
||||||
@ -75,7 +72,7 @@ class LobbyTest {
|
|||||||
@Disabled
|
@Disabled
|
||||||
void soonTimeoutTest(){
|
void soonTimeoutTest(){
|
||||||
var participant = mock(Participant.class);
|
var participant = mock(Participant.class);
|
||||||
lobby.soonTimeout(participant);
|
lobby.soonTimeout(participant, 15);
|
||||||
verify(connection).sendEvents(participant, new EventBuilder(EventType.TimeoutWarningEvent).buildGameStateEvent());
|
verify(connection).sendEvents(participant, new EventBuilder(EventType.TimeoutWarningEvent).buildGameStateEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +81,7 @@ class LobbyTest {
|
|||||||
void generateWinPlayer1Test(){
|
void generateWinPlayer1Test(){
|
||||||
var webSoc = mock(WebSocket.class);
|
var webSoc = mock(WebSocket.class);
|
||||||
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
||||||
lobby.generateWin(winner);
|
lobby.triggerWin(winner);
|
||||||
verify(connection).broadcastEvents(
|
verify(connection).broadcastEvents(
|
||||||
new EventBuilder(EventType.WinEvent)
|
new EventBuilder(EventType.WinEvent)
|
||||||
.withPlayerWon(1)
|
.withPlayerWon(1)
|
||||||
@ -99,7 +96,7 @@ class LobbyTest {
|
|||||||
void generateWinPlayer2Test(){
|
void generateWinPlayer2Test(){
|
||||||
var webSoc = mock(WebSocket.class);
|
var webSoc = mock(WebSocket.class);
|
||||||
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
Participant winner = new Participant(new Client(webSoc), "someLobby", ParticipantType.PlayerOne);
|
||||||
lobby.generateWin(winner);
|
lobby.triggerWin(winner);
|
||||||
verify(connection).broadcastEvents(
|
verify(connection).broadcastEvents(
|
||||||
new EventBuilder(EventType.WinEvent)
|
new EventBuilder(EventType.WinEvent)
|
||||||
.withPlayerWon(2)
|
.withPlayerWon(2)
|
||||||
|
@ -12,20 +12,20 @@ import java.util.function.Consumer;
|
|||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
class TimeoutTimerTest {
|
class TurnTimeoutTimerTest {
|
||||||
TimeoutTimer timeoutTimer;
|
TurnTimeoutTimer turnTimeoutTimer;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach(){
|
void beforeEach(){
|
||||||
var callback = mock(Consumer.class);
|
var callback = mock(Consumer.class);
|
||||||
timeoutTimer = new TimeoutTimer(20, callback);
|
turnTimeoutTimer = new TurnTimeoutTimer(20, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void startTurnTimerTest(){
|
void startTurnTimerTest(){
|
||||||
var connection = mock(WebSocket.class);
|
var connection = mock(WebSocket.class);
|
||||||
var participant = new Participant(new Client(connection), "lobby", ParticipantType.Spectator);
|
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.junit.jupiter.api.Assertions.*;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
class RequestGameStateSegmentTest {
|
class RequestGameLogicSegmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void requestGamestateTest(){
|
void requestGamestateTest(){
|
||||||
|
Loading…
Reference in New Issue
Block a user