Search in sources :

Example 31 with FinishedSession

use of com.djrapitops.plan.gathering.domain.FinishedSession in project Plan by plan-player-analytics.

the class SessionQueriesTest method sessionsAreStoredWithAllData.

@Test
default void sessionsAreStoredWithAllData() {
    prepareForSessionSave();
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    execute(DataStoreQueries.storeSession(session));
    forcePersistenceCheck();
    Map<ServerUUID, List<FinishedSession>> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
    List<FinishedSession> savedSessions = sessions.get(serverUUID());
    assertNotNull(savedSessions);
    assertEquals(1, savedSessions.size());
    assertEquals(session, savedSessions.get(0));
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 32 with FinishedSession

use of com.djrapitops.plan.gathering.domain.FinishedSession in project Plan by plan-player-analytics.

the class SessionQueriesTest method testKillTableGetKillsOfServer.

@Test
default void testKillTableGetKillsOfServer() {
    prepareForSessionSave();
    FinishedSession session = RandomData.randomSession(serverUUID(), worlds, playerUUID, player2UUID);
    List<PlayerKill> expected = session.getExtraData(PlayerKills.class).map(PlayerKills::asList).get();
    execute(DataStoreQueries.storeSession(session));
    forcePersistenceCheck();
    Map<ServerUUID, List<FinishedSession>> sessions = db().query(SessionQueries.fetchSessionsOfPlayer(playerUUID));
    List<FinishedSession> savedSessions = sessions.get(serverUUID());
    assertNotNull(savedSessions);
    assertFalse(savedSessions.isEmpty());
    List<PlayerKill> got = savedSessions.get(0).getExtraData(PlayerKills.class).map(PlayerKills::asList).get();
    assertEquals(expected, got);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) PlayerKill(com.djrapitops.plan.gathering.domain.PlayerKill) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Aggregations

FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)32 Test (org.junit.jupiter.api.Test)22 ServerUUID (com.djrapitops.plan.identification.ServerUUID)13 RepeatedTest (org.junit.jupiter.api.RepeatedTest)11 StoreSessionTransaction (com.djrapitops.plan.storage.database.transactions.events.StoreSessionTransaction)10 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)8 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)6 RandomData (utilities.RandomData)6 TestConstants (utilities.TestConstants)6 TablePlayer (com.djrapitops.plan.delivery.domain.TablePlayer)5 List (java.util.List)5 WorldTimes (com.djrapitops.plan.gathering.domain.WorldTimes)4 NetworkTablePlayersQuery (com.djrapitops.plan.storage.database.queries.objects.playertable.NetworkTablePlayersQuery)4 ServerTablePlayersQuery (com.djrapitops.plan.storage.database.queries.objects.playertable.ServerTablePlayersQuery)4 Sql (com.djrapitops.plan.storage.database.sql.building.Sql)4 UsersTable (com.djrapitops.plan.storage.database.sql.tables.UsersTable)4 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 Collection (java.util.Collection)4 TimeUnit (java.util.concurrent.TimeUnit)4