use of com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery in project Plan by plan-player-analytics.
the class SessionQueriesTest method playersTableAndPlayerPagePlaytimeMatches.
@RepeatedTest(value = 3, name = "Players table and Player page playtimes match {currentRepetition}/{totalRepetitions}")
default void playersTableAndPlayerPagePlaytimeMatches() {
prepareForSessionSave();
List<FinishedSession> player1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID);
List<FinishedSession> player2Sessions = RandomData.randomSessions(serverUUID(), worlds, player2UUID, playerUUID);
player1Sessions.forEach(session -> db().executeTransaction(new StoreSessionTransaction(session)));
player2Sessions.forEach(session -> db().executeTransaction(new StoreSessionTransaction(session)));
long playtimeThreshold = RandomData.randomLong(TimeUnit.HOURS.toMillis(1L), TimeUnit.DAYS.toMillis(2L));
PlayerContainer playerContainer = db().query(new PlayerContainerQuery(playerUUID));
TablePlayer tablePlayer = db().query(new ServerTablePlayersQuery(serverUUID(), System.currentTimeMillis(), playtimeThreshold, 5)).stream().filter(player -> playerUUID.equals(player.getPlayerUUID())).findAny().orElseThrow(AssertionError::new);
long expected = SessionsMutator.forContainer(playerContainer).toActivePlaytime();
long got = tablePlayer.getActivePlaytime().orElseThrow(AssertionError::new);
assertEquals(expected, got);
}
Aggregations