mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-19 22:51:28 +01:00
Test against one suspected case of #1424
This commit is contained in:
parent
5570a2b938
commit
18e8ccca95
@ -25,20 +25,20 @@ import utilities.TestConstants;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
||||||
|
|
||||||
class SessionCacheTest {
|
class SessionCacheTest {
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
private final UUID uuid = TestConstants.PLAYER_ONE_UUID;
|
private final UUID uuid = TestConstants.PLAYER_ONE_UUID;
|
||||||
private final UUID serverUUID = TestConstants.SERVER_UUID;
|
private final UUID serverUUID = TestConstants.SERVER_UUID;
|
||||||
|
private SessionCache sessionCache;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void setUp() {
|
void setUp() {
|
||||||
session = new Session(uuid, serverUUID, 12345L, "World1", "SURVIVAL");
|
session = new Session(uuid, serverUUID, 12345L, "World1", "SURVIVAL");
|
||||||
|
|
||||||
SessionCache sessionCache = new SessionCache();
|
sessionCache = new SessionCache();
|
||||||
sessionCache.cacheSession(uuid, session);
|
sessionCache.cacheSession(uuid, session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,4 +53,24 @@ class SessionCacheTest {
|
|||||||
assertTrue(cachedSession.isPresent());
|
assertTrue(cachedSession.isPresent());
|
||||||
assertEquals(session, cachedSession.get());
|
assertEquals(session, cachedSession.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sessionsAreRemovedFromCacheOnEnd() {
|
||||||
|
Optional<Session> ended = new SessionCache().endSession(uuid, System.currentTimeMillis());
|
||||||
|
assertTrue(ended.isPresent());
|
||||||
|
for (Session session : SessionCache.getActiveSessions().values()) {
|
||||||
|
fail("Session was still in cache: " + session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void sessionsAreRemovedFromCacheOnStart() {
|
||||||
|
Optional<Session> ended = new SessionCache().cacheSession(uuid, new Session(uuid, serverUUID, 52345L, "World1", "SURVIVAL"));
|
||||||
|
assertTrue(ended.isPresent());
|
||||||
|
for (Session session : SessionCache.getActiveSessions().values()) {
|
||||||
|
if (session.getDate() == 12345L) {
|
||||||
|
fail("Session was still in cache: " + session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user