test: fixed GameStateSegment test

This commit is contained in:
Yannik Bretschneider 2021-06-02 17:51:48 +02:00
parent 50bd0f2a19
commit d27bc6326c

View File

@ -26,6 +26,7 @@ class GameStateSegmentTest {
@Test @Test
void processRequests() { void processRequests() {
var game = mock(GameInstance.class); var game = mock(GameInstance.class);
var request = new RequestBuilder(RequestType.DisconnectRequest).buildGameRequest();
var event = new EventBuilder(EventType.DisconnectEvent).buildGameEvent(); var event = new EventBuilder(EventType.DisconnectEvent).buildGameEvent();
when(game.checkRequestsAndApply(any(Request.class))).thenReturn(Optional.of(List.of(event))); when(game.checkRequestsAndApply(any(Request.class))).thenReturn(Optional.of(List.of(event)));
var abort = new AtomicBoolean(false); var abort = new AtomicBoolean(false);
@ -34,7 +35,7 @@ class GameStateSegmentTest {
// note that DisconnectRequests are actually never passed to the GameLogic, ever. // note that DisconnectRequests are actually never passed to the GameLogic, ever.
var packet = new Packet( var packet = new Packet(
new Request[] {new RequestBuilder(RequestType.DisconnectRequest).buildGameRequest()}, new Request[] {request},
null); null);
var carrier = new ArrayList<Event>(1); var carrier = new ArrayList<Event>(1);
@ -42,7 +43,7 @@ class GameStateSegmentTest {
segment.processRequests(packet, carrier, abort); segment.processRequests(packet, carrier, abort);
assertThat(carrier.contains(event)).isTrue(); assertThat(carrier.contains(event)).isTrue();
verify(game).checkRequestsAndApply(packet.get(0)); verify(game).checkRequestsAndApply(request);
assertThat(abort.get()).isFalse(); assertThat(abort.get()).isFalse();
} }
} }