Search in sources :

Example 1 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class SessionQueriesTest method serverPreferencePieValuesAreCorrect.

@Test
default void serverPreferencePieValuesAreCorrect() {
    prepareForSessionSave();
    List<FinishedSession> server1Sessions = RandomData.randomSessions(serverUUID(), worlds, playerUUID, player2UUID);
    server1Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session)));
    ServerUUID serverTwoUuid = TestConstants.SERVER_TWO_UUID;
    executeTransactions(new StoreServerInformationTransaction(new Server(serverTwoUuid, TestConstants.SERVER_TWO_NAME, "")));
    db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[0]));
    db().executeTransaction(new WorldNameStoreTransaction(serverTwoUuid, worlds[1]));
    List<FinishedSession> server2Sessions = RandomData.randomSessions(serverTwoUuid, worlds, playerUUID, player2UUID);
    server2Sessions.forEach(session -> execute(DataStoreQueries.storeSession(session)));
    Map<String, Long> expected = Maps.builder(String.class, Long.class).put(TestConstants.SERVER_NAME, new SessionsMutator(server1Sessions).toPlaytime()).put(TestConstants.SERVER_TWO_NAME, new SessionsMutator(server2Sessions).toPlaytime()).build();
    Map<String, Long> results = db().query(SessionQueries.playtimePerServer(Long.MIN_VALUE, Long.MAX_VALUE));
    assertEquals(expected, results);
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Server(com.djrapitops.plan.identification.Server) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) SessionsMutator(com.djrapitops.plan.delivery.domain.mutators.SessionsMutator) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 2 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class SessionQueriesTest method worldNamesAreStored.

@Test
default void worldNamesAreStored() {
    String[] expected = { "Test", "Test2", "Test3" };
    for (String worldName : expected) {
        db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worldName));
    }
    forcePersistenceCheck();
    Collection<String> result = db().query(LargeFetchQueries.fetchAllWorldNames()).get(serverUUID());
    assertEquals(new HashSet<>(Arrays.asList(expected)), result);
}
Also used : WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test)

Example 3 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class SessionQueriesTest method prepareForSessionSave.

default void prepareForSessionSave() {
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[0]));
    db().executeTransaction(new WorldNameStoreTransaction(serverUUID(), worlds[1]));
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    db().executeTransaction(new PlayerServerRegisterTransaction(player2UUID, RandomData::randomTime, TestConstants.PLAYER_TWO_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
}
Also used : WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerServerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)

Example 4 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class ShutdownSaveTest method storeNecessaryInformation.

private void storeNecessaryInformation() throws Exception {
    database.executeTransaction(new RemoveEverythingTransaction());
    ServerUUID serverUUID = TestConstants.SERVER_UUID;
    UUID playerUUID = TestConstants.PLAYER_ONE_UUID;
    String worldName = TestConstants.WORLD_ONE_NAME;
    database.executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID, "-", "")));
    database.executeTransaction(new PlayerRegisterTransaction(playerUUID, () -> 0L, TestConstants.PLAYER_ONE_NAME));
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, worldName)).get();
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) Server(com.djrapitops.plan.identification.Server) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) UUID(java.util.UUID)

Example 5 with WorldNameStoreTransaction

use of com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction in project Plan by plan-player-analytics.

the class ExportJSErrorRegressionTest method savePlayerData.

private static void savePlayerData() {
    DBSystem dbSystem = planSystem.getDatabaseSystem();
    Database database = dbSystem.getDatabase();
    UUID uuid = TestConstants.PLAYER_ONE_UUID;
    database.executeTransaction(new PlayerRegisterTransaction(uuid, RandomData::randomTime, TestConstants.PLAYER_ONE_NAME));
    FinishedSession session = new FinishedSession(uuid, serverUUID, 1000L, 11000L, 500L, new DataMap());
    database.executeTransaction(new WorldNameStoreTransaction(serverUUID, "world"));
    database.executeTransaction(new SessionEndTransaction(session));
}
Also used : SessionEndTransaction(com.djrapitops.plan.storage.database.transactions.events.SessionEndTransaction) DBSystem(com.djrapitops.plan.storage.database.DBSystem) FinishedSession(com.djrapitops.plan.gathering.domain.FinishedSession) Database(com.djrapitops.plan.storage.database.Database) WorldNameStoreTransaction(com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction) PlayerRegisterTransaction(com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction) ServerUUID(com.djrapitops.plan.identification.ServerUUID) DataMap(com.djrapitops.plan.gathering.domain.DataMap)

Aggregations

WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)16 UUID (java.util.UUID)11 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)9 ServerUUID (com.djrapitops.plan.identification.ServerUUID)5 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)4 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)3 Test (org.junit.jupiter.api.Test)3 Player (cn.nukkit.Player)2 DataMap (com.djrapitops.plan.gathering.domain.DataMap)2 Server (com.djrapitops.plan.identification.Server)2 DBSystem (com.djrapitops.plan.storage.database.DBSystem)2 Database (com.djrapitops.plan.storage.database.Database)2 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)2 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)2 PlayerServerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerServerRegisterTransaction)2 SessionEndTransaction (com.djrapitops.plan.storage.database.transactions.events.SessionEndTransaction)2 Player (org.bukkit.entity.Player)2 RepeatedTest (org.junit.jupiter.api.RepeatedTest)2 SessionsMutator (com.djrapitops.plan.delivery.domain.mutators.SessionsMutator)1 HtmlTable (com.djrapitops.plan.delivery.rendering.html.structure.HtmlTable)1