Search in sources :

Example 1 with StoreServerInformationTransaction

use of com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction 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 StoreServerInformationTransaction

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

the class UserInfoQueriesTest method joinAddressQueryHasDistinctPlayers.

@Test
default void joinAddressQueryHasDistinctPlayers() {
    db().executeTransaction(new StoreServerInformationTransaction(new Server(TestConstants.SERVER_TWO_UUID, TestConstants.SERVER_TWO_NAME, "")));
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, serverUUID(), TestConstants.GET_PLAYER_HOSTNAME));
    db().executeTransaction(new PlayerServerRegisterTransaction(playerUUID, () -> TestConstants.REGISTER_TIME, TestConstants.PLAYER_ONE_NAME, TestConstants.SERVER_TWO_UUID, TestConstants.GET_PLAYER_HOSTNAME));
    Map<String, Integer> expected = Collections.singletonMap(TestConstants.GET_PLAYER_HOSTNAME.get(), 1);
    Map<String, Integer> result = db().query(UserInfoQueries.joinAddresses());
    assertEquals(expected, result);
}
Also used : Server(com.djrapitops.plan.identification.Server) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) Test(org.junit.jupiter.api.Test)

Example 3 with StoreServerInformationTransaction

use of com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction 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 4 with StoreServerInformationTransaction

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

the class MySQLTest method setUp.

@BeforeEach
void setUp() {
    TestErrorLogger.throwErrors(true);
    db().executeTransaction(new Patch() {

        @Override
        public boolean hasBeenApplied() {
            return false;
        }

        @Override
        public void applyPatch() {
            dropTable("plan_world_times");
            dropTable("plan_kills");
            dropTable("plan_sessions");
            dropTable("plan_worlds");
            dropTable("plan_users");
        }
    });
    db().executeTransaction(new CreateTablesTransaction());
    db().executeTransaction(new RemoveEverythingTransaction());
    db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), TestConstants.SERVER_NAME, "")));
    assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
Also used : Server(com.djrapitops.plan.identification.Server) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) Patch(com.djrapitops.plan.storage.database.transactions.patches.Patch) CreateTablesTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with StoreServerInformationTransaction

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

the class SQLiteTest method setUp.

@BeforeEach
void setUp() {
    TestErrorLogger.throwErrors(true);
    db().executeTransaction(new Patch() {

        @Override
        public boolean hasBeenApplied() {
            return false;
        }

        @Override
        public void applyPatch() {
            dropTable("plan_world_times");
            dropTable("plan_kills");
            dropTable("plan_sessions");
            dropTable("plan_worlds");
            dropTable("plan_users");
        }
    });
    db().executeTransaction(new CreateTablesTransaction());
    db().executeTransaction(new RemoveEverythingTransaction());
    db().executeTransaction(new StoreServerInformationTransaction(new Server(serverUUID(), "ServerName", "")));
    assertEquals(serverUUID(), ((SQLDB) db()).getServerUUIDSupplier().get());
}
Also used : Server(com.djrapitops.plan.identification.Server) RemoveEverythingTransaction(com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction) StoreServerInformationTransaction(com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction) Patch(com.djrapitops.plan.storage.database.transactions.patches.Patch) CreateTablesTransaction(com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Server (com.djrapitops.plan.identification.Server)9 StoreServerInformationTransaction (com.djrapitops.plan.storage.database.transactions.StoreServerInformationTransaction)9 Test (org.junit.jupiter.api.Test)4 ServerUUID (com.djrapitops.plan.identification.ServerUUID)3 RemoveEverythingTransaction (com.djrapitops.plan.storage.database.transactions.commands.RemoveEverythingTransaction)3 PlayerRegisterTransaction (com.djrapitops.plan.storage.database.transactions.events.PlayerRegisterTransaction)2 WorldNameStoreTransaction (com.djrapitops.plan.storage.database.transactions.events.WorldNameStoreTransaction)2 CreateTablesTransaction (com.djrapitops.plan.storage.database.transactions.init.CreateTablesTransaction)2 Patch (com.djrapitops.plan.storage.database.transactions.patches.Patch)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 User (com.djrapitops.plan.delivery.domain.auth.User)1 SessionsMutator (com.djrapitops.plan.delivery.domain.mutators.SessionsMutator)1 FinishedSession (com.djrapitops.plan.gathering.domain.FinishedSession)1 UserInfo (com.djrapitops.plan.gathering.domain.UserInfo)1 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)1 Transaction (com.djrapitops.plan.storage.database.transactions.Transaction)1 RegisterWebUserTransaction (com.djrapitops.plan.storage.database.transactions.commands.RegisterWebUserTransaction)1 File (java.io.File)1 UUID (java.util.UUID)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1