From 68b078a90c52ed55705e00a3097d36b86754302a Mon Sep 17 00:00:00 2001 From: Yannik Bretschneider Date: Fri, 4 Jun 2021 00:00:06 +0200 Subject: [PATCH] test: fixed GameStateSegmentTest to work with new API --- .../server/lobby/pipelining/GameStateSegmentTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/GameStateSegmentTest.java b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/GameStateSegmentTest.java index f2dc4a0..4e98222 100644 --- a/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/GameStateSegmentTest.java +++ b/Server/src/test/java/uulm/teamname/marvelous/server/lobby/pipelining/GameStateSegmentTest.java @@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import uulm.teamname.marvelous.gamelibrary.events.Event; import uulm.teamname.marvelous.gamelibrary.events.EventBuilder; +import uulm.teamname.marvelous.gamelibrary.requests.GameRequest; import uulm.teamname.marvelous.gamelibrary.requests.RequestBuilder; import uulm.teamname.marvelous.gamelibrary.events.EventType; import uulm.teamname.marvelous.gamelibrary.events.GameEvent; @@ -12,6 +13,7 @@ import uulm.teamname.marvelous.gamelibrary.requests.Request; import uulm.teamname.marvelous.gamelibrary.requests.RequestType; import uulm.teamname.marvelous.server.lobbymanager.Participant; +import java.util.Collections; import java.util.List; import java.util.ArrayList; import java.util.Optional; @@ -28,7 +30,7 @@ class GameStateSegmentTest { var game = mock(GameInstance.class); var request = new RequestBuilder(RequestType.DisconnectRequest).buildGameRequest(); var event = new EventBuilder(EventType.DisconnectEvent).buildGameEvent(); - when(game.checkRequestsAndApply(any(Request.class))).thenReturn(Optional.of(List.of(event))); + when(game.checkRequestsAndApply(any(ArrayList.class))).thenReturn(Optional.of(List.of(event))); var abort = new AtomicBoolean(false); var segment = new GameStateSegment(game); @@ -42,8 +44,9 @@ class GameStateSegmentTest { segment.processRequests(packet, carrier, abort); - assertThat(carrier.contains(event)).isTrue(); - verify(game).checkRequestsAndApply(request); + assertThat(packet).isEmpty(); + assertThat(carrier).contains(event); + verify(game).checkRequestsAndApply(any(Packet.class)); assertThat(abort.get()).isFalse(); } }