test: fixed GameStateSegmentTest to work with new API
This commit is contained in:
parent
f82bdcbfbe
commit
68b078a90c
@ -4,6 +4,7 @@ import org.junit.jupiter.api.BeforeEach;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
import uulm.teamname.marvelous.gamelibrary.events.Event;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.EventBuilder;
|
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.requests.RequestBuilder;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.EventType;
|
import uulm.teamname.marvelous.gamelibrary.events.EventType;
|
||||||
import uulm.teamname.marvelous.gamelibrary.events.GameEvent;
|
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.gamelibrary.requests.RequestType;
|
||||||
import uulm.teamname.marvelous.server.lobbymanager.Participant;
|
import uulm.teamname.marvelous.server.lobbymanager.Participant;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@ -28,7 +30,7 @@ class GameStateSegmentTest {
|
|||||||
var game = mock(GameInstance.class);
|
var game = mock(GameInstance.class);
|
||||||
var request = new RequestBuilder(RequestType.DisconnectRequest).buildGameRequest();
|
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(ArrayList.class))).thenReturn(Optional.of(List.of(event)));
|
||||||
var abort = new AtomicBoolean(false);
|
var abort = new AtomicBoolean(false);
|
||||||
|
|
||||||
var segment = new GameStateSegment(game);
|
var segment = new GameStateSegment(game);
|
||||||
@ -42,8 +44,9 @@ class GameStateSegmentTest {
|
|||||||
|
|
||||||
segment.processRequests(packet, carrier, abort);
|
segment.processRequests(packet, carrier, abort);
|
||||||
|
|
||||||
assertThat(carrier.contains(event)).isTrue();
|
assertThat(packet).isEmpty();
|
||||||
verify(game).checkRequestsAndApply(request);
|
assertThat(carrier).contains(event);
|
||||||
|
verify(game).checkRequestsAndApply(any(Packet.class));
|
||||||
assertThat(abort.get()).isFalse();
|
assertThat(abort.get()).isFalse();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user