use of com.djrapitops.plan.delivery.domain.mutators.SessionsMutator in project Plan by plan-player-analytics.
the class SessionQueriesTest method sessionPlaytimeIsCalculatedCorrectlyAfterStorage.
@Test
default void sessionPlaytimeIsCalculatedCorrectlyAfterStorage() {
prepareForSessionSave();
FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
long expectedLength = session.getLength();
long sessionEnd = session.getEnd();
execute(DataStoreQueries.storeSession(session));
forcePersistenceCheck();
Map<ServerUUID, List<FinishedSession>> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
assertTrue(sessions.containsKey(serverUUID()));
SessionsMutator sessionsMutator = new SessionsMutator(sessions.get(serverUUID()));
assertEquals(expectedLength, sessionsMutator.toPlaytime());
assertEquals(1, sessionsMutator.count());
SessionsMutator afterTimeSessionsMutator = sessionsMutator.filterSessionsBetween(sessionEnd + 1L, System.currentTimeMillis());
assertEquals(0L, afterTimeSessionsMutator.toPlaytime());
assertEquals(0, afterTimeSessionsMutator.count());
}
Aggregations